mirror of
https://github.com/pikami/tiktok-dl.git
synced 2026-01-27 05:32:56 +00:00
formatter
This commit is contained in:
@@ -1,36 +1,36 @@
|
||||
package workflows
|
||||
|
||||
import (
|
||||
client "../client"
|
||||
config "../models/config"
|
||||
utils "../utils"
|
||||
"fmt"
|
||||
"strings"
|
||||
client "../client"
|
||||
config "../models/config"
|
||||
utils "../utils"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// CanUseDownloadHashtag - Test's if this workflow can be used for parameter
|
||||
func CanUseDownloadHashtag(url string) bool {
|
||||
match := strings.Contains(url, "/tag/")
|
||||
return match
|
||||
match := strings.Contains(url, "/tag/")
|
||||
return match
|
||||
}
|
||||
|
||||
// DownloadHashtag - Download videos marked with given hashtag
|
||||
func DownloadHashtag(url string) {
|
||||
uploads := client.GetHashtagUploads(url)
|
||||
uploadCount := len(uploads)
|
||||
hashtag := utils.GetHashtagFromURL(url)
|
||||
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, hashtag)
|
||||
uploads := client.GetHashtagUploads(url)
|
||||
uploadCount := len(uploads)
|
||||
hashtag := utils.GetHashtagFromURL(url)
|
||||
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, hashtag)
|
||||
|
||||
utils.InitOutputDirectory(downloadDir)
|
||||
utils.InitOutputDirectory(downloadDir)
|
||||
|
||||
for index, upload := range uploads {
|
||||
downloadVideo(upload, downloadDir)
|
||||
utils.Logf("\r[%d/%d] Downloaded", index+1, uploadCount)
|
||||
}
|
||||
utils.Log()
|
||||
for index, upload := range uploads {
|
||||
downloadVideo(upload, downloadDir)
|
||||
utils.Logf("\r[%d/%d] Downloaded", index+1, uploadCount)
|
||||
}
|
||||
utils.Log()
|
||||
}
|
||||
|
||||
func GetHashtagJson(url string) {
|
||||
uploads := client.GetHashtagUploads(url)
|
||||
fmt.Printf("%s", uploads)
|
||||
uploads := client.GetHashtagUploads(url)
|
||||
fmt.Printf("%s", uploads)
|
||||
}
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
package workflows
|
||||
|
||||
import (
|
||||
client "../client"
|
||||
config "../models/config"
|
||||
utils "../utils"
|
||||
"fmt"
|
||||
"regexp"
|
||||
client "../client"
|
||||
config "../models/config"
|
||||
utils "../utils"
|
||||
"fmt"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// CanUseDownloadMusic - Check's if DownloadMusic can be used for parameter
|
||||
func CanUseDownloadMusic(url string) bool {
|
||||
match, _ := regexp.MatchString(".com\\/music\\/.+", url)
|
||||
return match
|
||||
match, _ := regexp.MatchString(".com\\/music\\/.+", url)
|
||||
return match
|
||||
}
|
||||
|
||||
// DownloadMusic - Download all videos by given music
|
||||
func DownloadMusic(url string) {
|
||||
uploads := client.GetMusicUploads(url)
|
||||
uploadCount := len(uploads)
|
||||
uploads := client.GetMusicUploads(url)
|
||||
uploadCount := len(uploads)
|
||||
|
||||
for index, upload := range uploads {
|
||||
username := utils.GetUsernameFromString(upload.Uploader)
|
||||
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
|
||||
for index, upload := range uploads {
|
||||
username := utils.GetUsernameFromString(upload.Uploader)
|
||||
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
|
||||
|
||||
utils.InitOutputDirectory(downloadDir)
|
||||
downloadVideo(upload, downloadDir)
|
||||
utils.Logf("\r[%d/%d] Downloaded", index+1, uploadCount)
|
||||
}
|
||||
utils.Log()
|
||||
utils.InitOutputDirectory(downloadDir)
|
||||
downloadVideo(upload, downloadDir)
|
||||
utils.Logf("\r[%d/%d] Downloaded", index+1, uploadCount)
|
||||
}
|
||||
utils.Log()
|
||||
}
|
||||
|
||||
func GetMusicJson(url string) {
|
||||
uploads := client.GetMusicUploadsJson(url)
|
||||
fmt.Printf("%s", uploads)
|
||||
uploads := client.GetMusicUploadsJson(url)
|
||||
fmt.Printf("%s", uploads)
|
||||
}
|
||||
|
||||
@@ -31,5 +31,5 @@ func DownloadUser(username string) {
|
||||
|
||||
func GetUserVideosJson(username string) {
|
||||
uploads := client.GetUserUploadsJson(username)
|
||||
fmt.Printf("%s", uploads)
|
||||
fmt.Printf("%s", uploads)
|
||||
}
|
||||
|
||||
@@ -1,44 +1,44 @@
|
||||
package workflows
|
||||
|
||||
import (
|
||||
client "../client"
|
||||
models "../models"
|
||||
config "../models/config"
|
||||
utils "../utils"
|
||||
"fmt"
|
||||
"regexp"
|
||||
client "../client"
|
||||
models "../models"
|
||||
config "../models/config"
|
||||
utils "../utils"
|
||||
"fmt"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// CanUseDownloadSingleVideo - Check's if DownloadSingleVideo can be used for parameter
|
||||
func CanUseDownloadSingleVideo(url string) bool {
|
||||
match, _ := regexp.MatchString("\\/@.+\\/video\\/[0-9]+", url)
|
||||
return match
|
||||
match, _ := regexp.MatchString("\\/@.+\\/video\\/[0-9]+", url)
|
||||
return match
|
||||
}
|
||||
|
||||
// DownloadSingleVideo - Downloads single video
|
||||
func DownloadSingleVideo(url string) {
|
||||
username := utils.GetUsernameFromString(url)
|
||||
upload := client.GetVideoDetails(url)
|
||||
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
|
||||
username := utils.GetUsernameFromString(url)
|
||||
upload := client.GetVideoDetails(url)
|
||||
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
|
||||
|
||||
utils.InitOutputDirectory(downloadDir)
|
||||
downloadVideo(upload, downloadDir)
|
||||
utils.Log("[1/1] Downloaded\n")
|
||||
utils.InitOutputDirectory(downloadDir)
|
||||
downloadVideo(upload, downloadDir)
|
||||
utils.Log("[1/1] Downloaded\n")
|
||||
}
|
||||
|
||||
// DownloadVideo - Downloads one video
|
||||
func downloadVideo(upload models.Upload, downloadDir string) {
|
||||
uploadID := upload.GetUploadID()
|
||||
downloadPath := fmt.Sprintf("%s/%s.mp4", downloadDir, uploadID)
|
||||
uploadID := upload.GetUploadID()
|
||||
downloadPath := fmt.Sprintf("%s/%s.mp4", downloadDir, uploadID)
|
||||
|
||||
if utils.CheckIfExists(downloadPath) {
|
||||
return
|
||||
}
|
||||
if utils.CheckIfExists(downloadPath) {
|
||||
return
|
||||
}
|
||||
|
||||
utils.DownloadFile(downloadPath, upload.URL)
|
||||
utils.DownloadFile(downloadPath, upload.URL)
|
||||
|
||||
if config.Config.MetaData {
|
||||
metadataPath := fmt.Sprintf("%s/%s.json", downloadDir, uploadID)
|
||||
upload.WriteToFile(metadataPath)
|
||||
}
|
||||
}
|
||||
if config.Config.MetaData {
|
||||
metadataPath := fmt.Sprintf("%s/%s.json", downloadDir, uploadID)
|
||||
upload.WriteToFile(metadataPath)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user