Added option to download items from list

This commit is contained in:
Pijus Kamandulis
2020-01-24 19:02:50 +02:00
parent 1782a2f12b
commit 6f8ab8a277
7 changed files with 99 additions and 13 deletions
+41
View File
@@ -0,0 +1,41 @@
package workflows
import (
models "../models"
utils "../utils"
"fmt"
)
// CanUseDownloadBatchFile - Check's if DownloadBatchFile can be used
func CanUseDownloadBatchFile(batchFilePath string) bool {
return batchFilePath != ""
}
// DownloadBatchFile - Download items from batch file
func DownloadBatchFile(batchFilePath string) {
if !utils.CheckIfExists(batchFilePath) {
panic(fmt.Sprintf("File path %s not found.", batchFilePath))
}
utils.ReadFileLineByLine(batchFilePath, downloadItem)
}
func downloadItem(batchItem string) {
if batchItem[0] == '#' {
return
}
// Single video
if CanUseDownloadSingleVideo(batchItem) {
DownloadSingleVideo(batchItem)
return
}
// Tiktok user
if CanUseDownloadUser(batchItem) {
DownloadUser(models.GetUsernameFromString(batchItem))
return
}
panic(fmt.Sprintf("Could not recognise URL format of string %s", batchItem))
}
+1 -1
View File
@@ -16,7 +16,7 @@ func CanUseDownloadSingleVideo(url string) bool {
// DownloadSingleVideo - Downloads single video
func DownloadSingleVideo(url string) {
username := models.GetUsername()
username := models.GetUsernameFromString(url)
upload := client.GetVideoDetails(url)
downloadDir := fmt.Sprintf("%s/%s", models.Config.OutputPath, username)