Skip to content

Commit

Permalink
fix(podcast): gracefully handle no podcast cover URL (#547)
Browse files Browse the repository at this point in the history
* fix(podcast): nil pointer when podcast has no image

* don't download empty cover string

---------

Co-authored-by: sentriz <[email protected]>
  • Loading branch information
superfrink and sentriz authored Nov 16, 2024
1 parent 643ffff commit aef5f92
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion podcast/podcast.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,14 @@ func (p *Podcasts) AddNewPodcast(rssURL string, feed *gofeed.Feed) (*db.Podcast,
}
podcast := db.Podcast{
Description: feed.Description,
ImageURL: feed.Image.URL,
ImageURL: "",
Title: feed.Title,
URL: rssURL,
RootDir: rootDir,
}
if feed.Image != nil {
podcast.ImageURL = feed.Image.URL
}
if err := os.Mkdir(podcast.RootDir, 0o755); err != nil && !os.IsExist(err) {
return nil, err
}
Expand Down Expand Up @@ -316,6 +319,10 @@ func getPodcastEpisodeFilename(podcast *db.Podcast, podcastEpisode *db.PodcastEp
}

func (p *Podcasts) downloadPodcastCover(podcast *db.Podcast) error {
if podcast.ImageURL == "" {
return nil
}

imageURL, err := url.Parse(podcast.ImageURL)
if err != nil {
return fmt.Errorf("parse image url: %w", err)
Expand Down

0 comments on commit aef5f92

Please sign in to comment.