tiktok-dl/workflows/downloadHashtag.go

37 lines
877 B
Go
Raw Normal View History

package workflows
import (
2020-02-24 23:01:10 +00:00
client "../client"
config "../models/config"
utils "../utils"
"fmt"
"strings"
)
// 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
}
// 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 23:01:10 +00:00
utils.InitOutputDirectory(downloadDir)
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()
}
func GetHashtagJson(url string) {
2020-02-24 23:01:10 +00:00
uploads := client.GetHashtagUploads(url)
fmt.Printf("%s", uploads)
}