NewPodcast: refactor an if else statement and document it.
This commit is contained in:
parent
7a74534285
commit
c910e0af40
@ -91,14 +91,13 @@ impl NewPodcast {
|
|||||||
|
|
||||||
let description = ammonia::clean(chan.description().trim());
|
let description = ammonia::clean(chan.description().trim());
|
||||||
let link = url_cleaner(chan.link());
|
let link = url_cleaner(chan.link());
|
||||||
|
|
||||||
|
// Try to get the itunes img first
|
||||||
let itunes_img = chan.itunes_ext()
|
let itunes_img = chan.itunes_ext()
|
||||||
.and_then(|s| s.image())
|
.and_then(|s| s.image())
|
||||||
.map(|s| s.to_owned());
|
.map(|s| s.to_owned());
|
||||||
let image_uri = if itunes_img.is_some() {
|
// If itunes is None, try to get the channel.image from the rss spec
|
||||||
itunes_img
|
let image_uri = itunes_img.or_else(|| chan.image().map(|s| s.url().to_owned()));
|
||||||
} else {
|
|
||||||
chan.image().map(|s| s.url().to_owned())
|
|
||||||
};
|
|
||||||
|
|
||||||
NewPodcastBuilder::default()
|
NewPodcastBuilder::default()
|
||||||
.title(title)
|
.title(title)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user