fix podcast nil ITunesExt and escape cover path with slash

Co-authored-by: Alex McGrath <amk@amk.ie>
This commit is contained in:
sentriz
2021-03-30 21:41:22 +01:00
parent e7d4b857f7
commit e9cc2e8ea6

View File

@@ -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 {