2020-02-24 22:56:19 +00:00
|
|
|
package workflows
|
|
|
|
|
|
|
|
import (
|
2020-02-24 23:01:10 +00:00
|
|
|
client "../client"
|
|
|
|
config "../models/config"
|
|
|
|
utils "../utils"
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
2020-02-24 22:56:19 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// CanUseDownloadHashtag - Test's if this workflow can be used for parameter
|
|
|
|
func CanUseDownloadHashtag(url string) bool {
|
2020-02-24 23:01:10 +00:00
|
|
|
match := strings.Contains(url, "/tag/")
|
|
|
|
return match
|
2020-02-24 22:56:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// DownloadHashtag - Download videos marked with given hashtag
|
|
|
|
func DownloadHashtag(url string) {
|
2020-02-24 23:01:10 +00:00
|
|
|
uploads := client.GetHashtagUploads(url)
|
|
|
|
uploadCount := len(uploads)
|
|
|
|
hashtag := utils.GetHashtagFromURL(url)
|
|
|
|
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, hashtag)
|
2020-02-24 22:56:19 +00:00
|
|
|
|
2020-02-24 23:01:10 +00:00
|
|
|
utils.InitOutputDirectory(downloadDir)
|
2020-02-24 22:56:19 +00:00
|
|
|
|
2020-02-24 23:01:10 +00:00
|
|
|
for index, upload := range uploads {
|
|
|
|
downloadVideo(upload, downloadDir)
|
|
|
|
utils.Logf("\r[%d/%d] Downloaded", index+1, uploadCount)
|
|
|
|
}
|
|
|
|
utils.Log()
|
2020-02-24 22:56:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func GetHashtagJson(url string) {
|
2020-02-24 23:01:10 +00:00
|
|
|
uploads := client.GetHashtagUploads(url)
|
|
|
|
fmt.Printf("%s", uploads)
|
2020-02-24 22:56:19 +00:00
|
|
|
}
|