tiktok-dl/workflows/startWorkflowByParameter.go

58 lines
1.0 KiB
Go
Raw Normal View History

package workflows
import (
2020-04-12 01:22:00 +01:00
config "github.com/pikami/tiktok-dl/models/config"
res "github.com/pikami/tiktok-dl/resources"
utils "github.com/pikami/tiktok-dl/utils"
log "github.com/pikami/tiktok-dl/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)
}