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