NewPodcast: refactor an if else statement and document it.

This commit is contained in:
Jordan Petridis 2018-04-03 19:55:40 +03:00
parent 7a74534285
commit c910e0af40
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6

View File

@ -91,14 +91,13 @@ impl NewPodcast {
let description = ammonia::clean(chan.description().trim());
let link = url_cleaner(chan.link());
// Try to get the itunes img first
let itunes_img = chan.itunes_ext()
.and_then(|s| s.image())
.map(|s| s.to_owned());
let image_uri = if itunes_img.is_some() {
itunes_img
} else {
chan.image().map(|s| s.url().to_owned())
};
// If itunes is None, try to get the channel.image from the rss spec
let image_uri = itunes_img.or_else(|| chan.image().map(|s| s.url().to_owned()));
NewPodcastBuilder::default()
.title(title)