mirror of
https://github.com/pikami/tiktok-dl.git
synced 2024-11-25 09:15:41 +00:00
Fixed circular dependency issue
This commit is contained in:
parent
f9d35e3bf2
commit
af7972685e
@ -1,10 +1,11 @@
|
|||||||
package models
|
package models
|
||||||
|
|
||||||
import (
|
import (
|
||||||
testUtil "../unitTestUtil"
|
|
||||||
utils "../utils"
|
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
testUtil "../unitTestUtil"
|
||||||
|
fileio "../utils/fileio"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParseUploads(t *testing.T) {
|
func TestParseUploads(t *testing.T) {
|
||||||
@ -62,7 +63,7 @@ func TestWriteToFile(t *testing.T) {
|
|||||||
|
|
||||||
upload.WriteToFile(filePath)
|
upload.WriteToFile(filePath)
|
||||||
|
|
||||||
actual := utils.ReadFileToString(filePath)
|
actual := fileio.ReadFileToString(filePath)
|
||||||
tu.AssertString(actual, expected, "File content")
|
tu.AssertString(actual, expected, "File content")
|
||||||
|
|
||||||
os.Remove(filePath)
|
os.Remove(filePath)
|
||||||
|
@ -3,6 +3,7 @@ package utils
|
|||||||
import (
|
import (
|
||||||
models "../models"
|
models "../models"
|
||||||
config "../models/config"
|
config "../models/config"
|
||||||
|
fileio "./fileio"
|
||||||
log "./log"
|
log "./log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -18,7 +19,7 @@ func IsItemInArchive(upload models.Upload) bool {
|
|||||||
func RemoveArchivedItems(uploads []models.Upload) []models.Upload {
|
func RemoveArchivedItems(uploads []models.Upload) []models.Upload {
|
||||||
archiveFilePath := config.Config.ArchiveFilePath
|
archiveFilePath := config.Config.ArchiveFilePath
|
||||||
|
|
||||||
if archiveFilePath == "" || !CheckIfExists(archiveFilePath) {
|
if archiveFilePath == "" || !fileio.CheckIfExists(archiveFilePath) {
|
||||||
return uploads
|
return uploads
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ func RemoveArchivedItems(uploads []models.Upload) []models.Upload {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lenBeforeRemoval := len(uploads)
|
lenBeforeRemoval := len(uploads)
|
||||||
ReadFileLineByLine(archiveFilePath, removeArchivedItemsDelegate)
|
fileio.ReadFileLineByLine(archiveFilePath, removeArchivedItemsDelegate)
|
||||||
|
|
||||||
removedCount := lenBeforeRemoval - len(uploads)
|
removedCount := lenBeforeRemoval - len(uploads)
|
||||||
if removedCount > 0 {
|
if removedCount > 0 {
|
||||||
@ -49,5 +50,5 @@ func AddItemToArchive(uploadID string) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
AppendToFile(uploadID, archiveFilePath)
|
fileio.AppendToFile(uploadID, archiveFilePath)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
checkErr "./checkErr"
|
checkErr "../checkErr"
|
||||||
)
|
)
|
||||||
|
|
||||||
type delegateString func(string)
|
type delegateString func(string)
|
@ -2,7 +2,7 @@ package workflows
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
res "../resources"
|
res "../resources"
|
||||||
utils "../utils"
|
fileio "../utils/fileio"
|
||||||
log "../utils/log"
|
log "../utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -13,11 +13,11 @@ func CanUseDownloadBatchFile(batchFilePath string) bool {
|
|||||||
|
|
||||||
// DownloadBatchFile - Download items from batch file
|
// DownloadBatchFile - Download items from batch file
|
||||||
func DownloadBatchFile(batchFilePath string) {
|
func DownloadBatchFile(batchFilePath string) {
|
||||||
if !utils.CheckIfExists(batchFilePath) {
|
if !fileio.CheckIfExists(batchFilePath) {
|
||||||
log.LogFatal(res.ErrorPathNotFound, batchFilePath)
|
log.LogFatal(res.ErrorPathNotFound, batchFilePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
utils.ReadFileLineByLine(batchFilePath, downloadItem)
|
fileio.ReadFileLineByLine(batchFilePath, downloadItem)
|
||||||
}
|
}
|
||||||
|
|
||||||
func downloadItem(batchItem string) {
|
func downloadItem(batchItem string) {
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
config "../models/config"
|
config "../models/config"
|
||||||
res "../resources"
|
res "../resources"
|
||||||
utils "../utils"
|
utils "../utils"
|
||||||
|
fileio "../utils/fileio"
|
||||||
log "../utils/log"
|
log "../utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ func DownloadHashtag(url string) {
|
|||||||
hashtag := utils.GetHashtagFromURL(url)
|
hashtag := utils.GetHashtagFromURL(url)
|
||||||
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, hashtag)
|
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, hashtag)
|
||||||
|
|
||||||
utils.InitOutputDirectory(downloadDir)
|
fileio.InitOutputDirectory(downloadDir)
|
||||||
|
|
||||||
for index, upload := range uploads {
|
for index, upload := range uploads {
|
||||||
downloadVideo(upload, downloadDir)
|
downloadVideo(upload, downloadDir)
|
||||||
|
@ -8,6 +8,7 @@ import (
|
|||||||
config "../models/config"
|
config "../models/config"
|
||||||
res "../resources"
|
res "../resources"
|
||||||
utils "../utils"
|
utils "../utils"
|
||||||
|
fileio "../utils/fileio"
|
||||||
log "../utils/log"
|
log "../utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ func DownloadMusic(url string) {
|
|||||||
username := utils.GetUsernameFromString(upload.Uploader)
|
username := utils.GetUsernameFromString(upload.Uploader)
|
||||||
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
|
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
|
||||||
|
|
||||||
utils.InitOutputDirectory(downloadDir)
|
fileio.InitOutputDirectory(downloadDir)
|
||||||
downloadVideo(upload, downloadDir)
|
downloadVideo(upload, downloadDir)
|
||||||
log.Logf("\r[%d/%d] Downloaded", index+1, uploadCount)
|
log.Logf("\r[%d/%d] Downloaded", index+1, uploadCount)
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
config "../models/config"
|
config "../models/config"
|
||||||
res "../resources"
|
res "../resources"
|
||||||
utils "../utils"
|
utils "../utils"
|
||||||
|
fileio "../utils/fileio"
|
||||||
log "../utils/log"
|
log "../utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ func DownloadUser(username string) {
|
|||||||
|
|
||||||
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
|
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
|
||||||
|
|
||||||
utils.InitOutputDirectory(downloadDir)
|
fileio.InitOutputDirectory(downloadDir)
|
||||||
|
|
||||||
for index, upload := range uploads {
|
for index, upload := range uploads {
|
||||||
downloadVideo(upload, downloadDir)
|
downloadVideo(upload, downloadDir)
|
||||||
|
@ -9,6 +9,7 @@ import (
|
|||||||
config "../models/config"
|
config "../models/config"
|
||||||
res "../resources"
|
res "../resources"
|
||||||
utils "../utils"
|
utils "../utils"
|
||||||
|
fileio "../utils/fileio"
|
||||||
log "../utils/log"
|
log "../utils/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,7 +33,7 @@ func DownloadSingleVideo(url string) {
|
|||||||
}
|
}
|
||||||
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
|
downloadDir := fmt.Sprintf("%s/%s", config.Config.OutputPath, username)
|
||||||
|
|
||||||
utils.InitOutputDirectory(downloadDir)
|
fileio.InitOutputDirectory(downloadDir)
|
||||||
downloadVideo(upload, downloadDir)
|
downloadVideo(upload, downloadDir)
|
||||||
log.Log("[1/1] Downloaded\n")
|
log.Log("[1/1] Downloaded\n")
|
||||||
}
|
}
|
||||||
@ -42,7 +43,7 @@ func downloadVideo(upload models.Upload, downloadDir string) {
|
|||||||
uploadID := upload.GetUploadID()
|
uploadID := upload.GetUploadID()
|
||||||
downloadPath := fmt.Sprintf("%s/%s.mp4", downloadDir, uploadID)
|
downloadPath := fmt.Sprintf("%s/%s.mp4", downloadDir, uploadID)
|
||||||
|
|
||||||
if utils.CheckIfExists(downloadPath) {
|
if fileio.CheckIfExists(downloadPath) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user