NewEpisode: refactor another if else statement and document it.

This commit is contained in:
Jordan Petridis 2018-04-03 20:05:00 +03:00
parent c910e0af40
commit 52cbe67756
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6

View File

@ -196,11 +196,14 @@ impl NewEpisodeMinimal {
let title = item.title().unwrap().trim().to_owned();
let guid = item.guid().map(|s| s.value().trim().to_owned());
let uri = if let Some(url) = item.enclosure().map(|s| url_cleaner(s.url())) {
Some(url)
} else if item.link().is_some() {
item.link().map(|s| url_cleaner(s))
} else {
let uri = item.enclosure()
.map(|s| url_cleaner(s.url()))
// Fallback to Rss.Item.link if enclosure is None.
.or_else(|| item.link().map(|s| url_cleaner(s)));
// If url is still None return an Error as this behaviour is
// compliant with the RSS Spec.
if uri.is_none() {
let err = DataError::ParseEpisodeError {
reason: "No url specified for the item.".into(),
parent_id,