fix(podcast): gracefully handle no podcast cover URL (#547)
* fix(podcast): nil pointer when podcast has no image * don't download empty cover string --------- Co-authored-by: sentriz <senan@senan.xyz>
This commit is contained in:
+8
-1
@@ -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
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user