Adding ability to specify the maximum download concurrency for the download missing episodes functionality. Defaults to `5` (the current hardcoded value).

pull/214/head
James Luck 2 years ago
parent ee39d847ce
commit d9925a3cf6

@ -104,6 +104,10 @@
<span class="label-body">Base URL (if accessing Podgrab using a URL. Without trailing /. Leave empty if not using or unsure.)</span> <span class="label-body">Base URL (if accessing Podgrab using a URL. Without trailing /. Leave empty if not using or unsure.)</span>
<input type="url" class="u-full-width" name="baseUrl" v-model="baseUrl"> <input type="url" class="u-full-width" name="baseUrl" v-model="baseUrl">
</label> </label>
<label for="maxDownloadConcurrency">
<input type="number" name="maxDownloadConcurrency" v-model="maxDownloadConcurrency">
<span class="label-body">Limit the number of podcasts that can be downloaded simultaneously.</span>
</label>
<input type="submit" value="Save" class="button"> <input type="submit" value="Save" class="button">
@ -181,6 +185,7 @@ var app = new Vue({
downloadEpisodeImages:self.downloadEpisodeImages, downloadEpisodeImages:self.downloadEpisodeImages,
generateNFOFile:self.generateNFOFile, generateNFOFile:self.generateNFOFile,
dontDownloadDeletedFromDisk:self.dontDownloadDeletedFromDisk, dontDownloadDeletedFromDisk:self.dontDownloadDeletedFromDisk,
maxDownloadConcurrency:self.maxDownloadConcurrency,
baseUrl:self.baseUrl, baseUrl:self.baseUrl,
}) })
.then(function(response){ .then(function(response){
@ -225,6 +230,7 @@ var app = new Vue({
downloadEpisodeImages:{{.setting.DownloadEpisodeImages }}, downloadEpisodeImages:{{.setting.DownloadEpisodeImages }},
generateNFOFile:{{ .setting.GenerateNFOFile }}, generateNFOFile:{{ .setting.GenerateNFOFile }},
dontDownloadDeletedFromDisk:{{ .setting.DontDownloadDeletedFromDisk }}, dontDownloadDeletedFromDisk:{{ .setting.DontDownloadDeletedFromDisk }},
maxDownloadConcurrency:{{ .setting.maxDownloadConcurrency }},
baseUrl: {{ .setting.BaseUrl }}, baseUrl: {{ .setting.BaseUrl }},
}, },

@ -31,6 +31,7 @@ type SettingModel struct {
GenerateNFOFile bool `form:"generateNFOFile" json:"generateNFOFile" query:"generateNFOFile"` GenerateNFOFile bool `form:"generateNFOFile" json:"generateNFOFile" query:"generateNFOFile"`
DontDownloadDeletedFromDisk bool `form:"dontDownloadDeletedFromDisk" json:"dontDownloadDeletedFromDisk" query:"dontDownloadDeletedFromDisk"` DontDownloadDeletedFromDisk bool `form:"dontDownloadDeletedFromDisk" json:"dontDownloadDeletedFromDisk" query:"dontDownloadDeletedFromDisk"`
BaseUrl string `form:"baseUrl" json:"baseUrl" query:"baseUrl"` BaseUrl string `form:"baseUrl" json:"baseUrl" query:"baseUrl"`
MaxDownloadConcurrency bool `form:"maxDownloadConcurrency" json:"maxDownloadConcurrency" query:"maxDownloadConcurrency"`
} }
var searchOptions = map[string]string{ var searchOptions = map[string]string{

@ -87,6 +87,7 @@ type Setting struct {
GenerateNFOFile bool `gorm:"default:false"` GenerateNFOFile bool `gorm:"default:false"`
DontDownloadDeletedFromDisk bool `gorm:"default:false"` DontDownloadDeletedFromDisk bool `gorm:"default:false"`
BaseUrl string BaseUrl string
MaxDownloadConcurrency int `gorm:"default:5"`
} }
type Migration struct { type Migration struct {
Base Base

@ -537,7 +537,7 @@ func DownloadMissingEpisodes() error {
SetPodcastItemAsDownloaded(item.ID, url) SetPodcastItemAsDownloaded(item.ID, url)
}(item, *setting) }(item, *setting)
if index%5 == 0 { if index%setting.MaxDownloadConcurrency == 0 {
wg.Wait() wg.Wait()
} }
} }
@ -764,7 +764,7 @@ func GetSearchFromPodcastIndex(pod *podcastindex.Podcast) *model.CommonSearchRes
func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload bool, func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload bool,
appendDateToFileName bool, appendEpisodeNumberToFileName bool, darkMode bool, downloadEpisodeImages bool, appendDateToFileName bool, appendEpisodeNumberToFileName bool, darkMode bool, downloadEpisodeImages bool,
generateNFOFile bool, dontDownloadDeletedFromDisk bool, baseUrl string) error { generateNFOFile bool, dontDownloadDeletedFromDisk bool, baseUrl string, maxDownloadConcurrency int) error {
setting := db.GetOrCreateSetting() setting := db.GetOrCreateSetting()
setting.AutoDownload = autoDownload setting.AutoDownload = autoDownload
@ -777,6 +777,7 @@ func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload b
setting.GenerateNFOFile = generateNFOFile setting.GenerateNFOFile = generateNFOFile
setting.DontDownloadDeletedFromDisk = dontDownloadDeletedFromDisk setting.DontDownloadDeletedFromDisk = dontDownloadDeletedFromDisk
setting.BaseUrl = baseUrl setting.BaseUrl = baseUrl
setting.MaxDownloadConcurrency = maxDownloadConcurrency
return db.UpdateSettings(setting) return db.UpdateSettings(setting)
} }

Loading…
Cancel
Save