tiktok-dl/workflows/downloadUser.go

36 lines
831 B
Go
Raw Normal View History

2020-01-21 21:46:30 +00:00
package workflows
import (
client "../client"
config "../models/config"
2020-01-21 21:46:30 +00:00
utils "../utils"
"fmt"
"strings"
)
// CanUseDownloadUser - Test's if this workflow can be used for parameter
func CanUseDownloadUser(url string) bool {
match := strings.Contains(url, "/")
return !match
}
// DownloadUser - Download all user's videos
func DownloadUser(username string) {
uploads := client.GetUserUploads(username)
uploadCount := len(uploads)
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
2020-01-21 21:46:30 +00:00
utils.InitOutputDirectory(downloadDir)
for index, upload := range uploads {
2020-01-21 21:46:30 +00:00
downloadVideo(upload, downloadDir)
utils.Logf("\r[%d/%d] Downloaded", index+1, uploadCount)
2020-01-21 21:46:30 +00:00
}
utils.Log()
2020-01-21 21:46:30 +00:00
}
func GetUserVideosJson(username string) {
uploads := client.GetUserUploadsJson(username)
fmt.Printf("%s", uploads)
}