cleaned code, flags
This commit is contained in:
@@ -102,9 +102,9 @@ func DownloadSeason(url string, seasonName string, subtitleLang string, maxConcu
|
||||
id := ExtractContentId(url)
|
||||
data := GetContentPageData(id)
|
||||
var wg sync.WaitGroup
|
||||
|
||||
currentConcurrent := 1
|
||||
|
||||
|
||||
currentConcurrent := 1
|
||||
|
||||
title := data.Data.MainContent.Title
|
||||
seasonList := data.Data.SeasonList
|
||||
if seasonList.Type != "seasonal" {
|
||||
@@ -116,18 +116,18 @@ func DownloadSeason(url string, seasonName string, subtitleLang string, maxConcu
|
||||
for _, seasonContent := range season.Contents {
|
||||
parentDirName := title
|
||||
_ = os.Mkdir(parentDirName, os.ModePerm) // dont care if directory fails to create
|
||||
|
||||
if currentConcurrent < maxConcurrent {
|
||||
wg.Add(1)
|
||||
currentConcurrent++
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
fmt.Println("Running in parallel")
|
||||
DownloadSingle(seasonContent.Url, subtitleLang, parentDirName)
|
||||
}()
|
||||
} else {
|
||||
DownloadSingle(seasonContent.Url, subtitleLang, parentDirName)
|
||||
}
|
||||
|
||||
if currentConcurrent < maxConcurrent {
|
||||
wg.Add(1)
|
||||
currentConcurrent++
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
fmt.Println("Running in parallel")
|
||||
DownloadSingle(seasonContent.Url, subtitleLang, parentDirName)
|
||||
}()
|
||||
} else {
|
||||
DownloadSingle(seasonContent.Url, subtitleLang, parentDirName)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ func TestDownloadUrl(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
t.Fatalf("bad status: %s", resp.Status)
|
||||
t.Fatalf("bad status: %s", resp.Status)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user