2020-01-21 21:46:30 +00:00
|
|
|
package workflows
|
|
|
|
|
|
|
|
import (
|
|
|
|
client "../client"
|
2020-02-07 23:51:17 +00:00
|
|
|
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)
|
2020-02-07 23:51:17 +00:00
|
|
|
uploadCount := len(uploads)
|
|
|
|
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
|
2020-01-21 21:46:30 +00:00
|
|
|
|
|
|
|
utils.InitOutputDirectory(downloadDir)
|
|
|
|
|
2020-02-07 23:51:17 +00:00
|
|
|
for index, upload := range uploads {
|
2020-01-21 21:46:30 +00:00
|
|
|
downloadVideo(upload, downloadDir)
|
2020-02-07 23:51:17 +00:00
|
|
|
utils.Logf("\r[%d/%d] Downloaded", index+1, uploadCount)
|
2020-01-21 21:46:30 +00:00
|
|
|
}
|
2020-02-07 23:51:17 +00:00
|
|
|
utils.Log()
|
2020-01-21 21:46:30 +00:00
|
|
|
}
|
2020-02-24 22:56:19 +00:00
|
|
|
|
|
|
|
func GetUserVideosJson(username string) {
|
|
|
|
uploads := client.GetUserUploadsJson(username)
|
|
|
|
fmt.Printf("%s", uploads)
|
|
|
|
}
|