From e9cc2e8ea610686396e27645f3d12dde4ac92baf Mon Sep 17 00:00:00 2001 From: sentriz Date: Tue, 30 Mar 2021 21:41:22 +0100 Subject: [PATCH] fix podcast nil ITunesExt and escape cover path with slash Co-authored-by: Alex McGrath --- server/podcasts/podcasts.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/podcasts/podcasts.go b/server/podcasts/podcasts.go index e2c3b5f..fb9b914 100644 --- a/server/podcasts/podcasts.go +++ b/server/podcasts/podcasts.go @@ -187,7 +187,7 @@ func (p *Podcasts) AddEpisode(podcastID int, item *gofeed.Item) (*db.PodcastEpis } } // if the itunes extension is available, use AddEpisode - if duration == 0 { + if duration == 0 && item.ITunesExt != nil { duration = getSecondsFromString(item.ITunesExt.Duration) } @@ -439,7 +439,7 @@ func (p *Podcasts) downloadPodcastCover(podPath string, podcast *db.Podcast) err if _, err := io.Copy(coverFile, resp.Body); err != nil { return fmt.Errorf("writing podcast cover: %w", err) } - podcastPath := filepath.Clean(podcast.Title) + podcastPath := filepath.Clean(strings.ReplaceAll(podcast.Title, "/", "_")) podcastFilename := fmt.Sprintf("cover%s", ext) podcast.ImagePath = path.Join(podcastPath, podcastFilename) if err := p.DB.Save(podcast).Error; err != nil {