|
|
@ -198,7 +198,7 @@ func getItunesImageUrl(body []byte) string {
|
|
|
|
func AddPodcast(url string) (db.Podcast, error) {
|
|
|
|
func AddPodcast(url string) (db.Podcast, error) {
|
|
|
|
var podcast db.Podcast
|
|
|
|
var podcast db.Podcast
|
|
|
|
err := db.GetPodcastByURL(url, &podcast)
|
|
|
|
err := db.GetPodcastByURL(url, &podcast)
|
|
|
|
|
|
|
|
setting := db.GetOrCreateSetting()
|
|
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
|
data, body, err := FetchURL(url)
|
|
|
|
data, body, err := FetchURL(url)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
@ -221,6 +221,9 @@ func AddPodcast(url string) (db.Podcast, error) {
|
|
|
|
|
|
|
|
|
|
|
|
err = db.CreatePodcast(&podcast)
|
|
|
|
err = db.CreatePodcast(&podcast)
|
|
|
|
go DownloadPodcastCoverImage(podcast.Image, podcast.Title)
|
|
|
|
go DownloadPodcastCoverImage(podcast.Image, podcast.Title)
|
|
|
|
|
|
|
|
if setting.GenerateNFOFile {
|
|
|
|
|
|
|
|
go CreateNfoFile(&podcast)
|
|
|
|
|
|
|
|
}
|
|
|
|
return podcast, err
|
|
|
|
return podcast, err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -617,6 +620,9 @@ func DeletePodcastEpisodes(id string) error {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for _, item := range podcastItems {
|
|
|
|
for _, item := range podcastItems {
|
|
|
|
DeleteFile(item.DownloadPath)
|
|
|
|
DeleteFile(item.DownloadPath)
|
|
|
|
|
|
|
|
if item.LocalImage != "" {
|
|
|
|
|
|
|
|
DeleteFile(item.LocalImage)
|
|
|
|
|
|
|
|
}
|
|
|
|
SetPodcastItemAsNotDownloaded(item.ID, db.Deleted)
|
|
|
|
SetPodcastItemAsNotDownloaded(item.ID, db.Deleted)
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -719,7 +725,7 @@ func GetSearchFromPodcastIndex(pod *podcastindex.Podcast) *model.CommonSearchRes
|
|
|
|
return p
|
|
|
|
return p
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload bool, appendDateToFileName bool, appendEpisodeNumberToFileName bool, darkMode bool, downloadEpisodeImages bool) error {
|
|
|
|
func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload bool, appendDateToFileName bool, appendEpisodeNumberToFileName bool, darkMode bool, downloadEpisodeImages bool, generateNFOFile bool) error {
|
|
|
|
setting := db.GetOrCreateSetting()
|
|
|
|
setting := db.GetOrCreateSetting()
|
|
|
|
|
|
|
|
|
|
|
|
setting.AutoDownload = autoDownload
|
|
|
|
setting.AutoDownload = autoDownload
|
|
|
@ -729,6 +735,7 @@ func UpdateSettings(downloadOnAdd bool, initialDownloadCount int, autoDownload b
|
|
|
|
setting.AppendEpisodeNumberToFileName = appendEpisodeNumberToFileName
|
|
|
|
setting.AppendEpisodeNumberToFileName = appendEpisodeNumberToFileName
|
|
|
|
setting.DarkMode = darkMode
|
|
|
|
setting.DarkMode = darkMode
|
|
|
|
setting.DownloadEpisodeImages = downloadEpisodeImages
|
|
|
|
setting.DownloadEpisodeImages = downloadEpisodeImages
|
|
|
|
|
|
|
|
setting.GenerateNFOFile = generateNFOFile
|
|
|
|
|
|
|
|
|
|
|
|
return db.UpdateSettings(setting)
|
|
|
|
return db.UpdateSettings(setting)
|
|
|
|
}
|
|
|
|
}
|
|
|
|