2020-01-26 17:44:25 +00:00
|
|
|
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"
|
2020-01-26 17:44:25 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// StartWorkflowByParameter - Start needed workflow by given parameter
|
|
|
|
func StartWorkflowByParameter(url string) {
|
|
|
|
|
|
|
|
// Music
|
|
|
|
if CanUseDownloadMusic(url) {
|
2020-02-24 22:56:19 +00:00
|
|
|
if config.Config.JSONOnly {
|
2020-03-22 00:10:24 +00:00
|
|
|
GetMusicJSON(url)
|
2020-02-24 22:56:19 +00:00
|
|
|
} else {
|
|
|
|
DownloadMusic(url)
|
|
|
|
}
|
2020-01-26 17:44:25 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Single video
|
|
|
|
if CanUseDownloadSingleVideo(url) {
|
|
|
|
DownloadSingleVideo(url)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tiktok user
|
|
|
|
if CanUseDownloadUser(url) {
|
2020-02-24 22:56:19 +00:00
|
|
|
if config.Config.JSONOnly {
|
2020-03-22 00:10:24 +00:00
|
|
|
GetUserVideosJSON(utils.GetUsernameFromString(url))
|
2020-02-24 22:56:19 +00:00
|
|
|
} 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)
|
2020-02-24 22:56:19 +00:00
|
|
|
} else {
|
|
|
|
DownloadHashtag(url)
|
|
|
|
}
|
2020-01-26 17:44:25 +00:00
|
|
|
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)
|
2020-01-26 17:44:25 +00:00
|
|
|
}
|