tiktok-dl/workflows/startWorkflowByParameter.go

58 lines
974 B
Go
Raw Normal View History

package workflows
import (
config "../models/config"
res "../resources"
utils "../utils"
2020-03-22 00:10:24 +00:00
log "../utils/log"
)
// StartWorkflowByParameter - Start needed workflow by given parameter
func StartWorkflowByParameter(url string) {
// Music
if CanUseDownloadMusic(url) {
if config.Config.JSONOnly {
2020-03-22 00:10:24 +00:00
GetMusicJSON(url)
} else {
DownloadMusic(url)
}
return
}
// Single video
if CanUseDownloadSingleVideo(url) {
DownloadSingleVideo(url)
return
}
// Tiktok user
if CanUseDownloadUser(url) {
if config.Config.JSONOnly {
2020-03-22 00:10:24 +00:00
GetUserVideosJSON(utils.GetUsernameFromString(url))
} else {
DownloadUser(utils.GetUsernameFromString(url))
}
return
}
// Tiktok hashtag
if CanUseDownloadHashtag(url) {
if config.Config.JSONOnly {
2020-03-22 00:10:24 +00:00
GetHashtagJSON(url)
} else {
DownloadHashtag(url)
}
return
}
2020-03-22 10:38:08 +00:00
// Share URL
if CanUseDownloadShareLink(url) {
DownloadShareLink(url)
return
}
2020-03-22 00:10:24 +00:00
log.LogFatal(res.ErrorCouldNotRecogniseURL, url)
}