NewEpisode: refactor another if else statement and document it.
This commit is contained in:
parent
c910e0af40
commit
52cbe67756
@ -196,11 +196,14 @@ impl NewEpisodeMinimal {
|
|||||||
let title = item.title().unwrap().trim().to_owned();
|
let title = item.title().unwrap().trim().to_owned();
|
||||||
let guid = item.guid().map(|s| s.value().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())) {
|
let uri = item.enclosure()
|
||||||
Some(url)
|
.map(|s| url_cleaner(s.url()))
|
||||||
} else if item.link().is_some() {
|
// Fallback to Rss.Item.link if enclosure is None.
|
||||||
item.link().map(|s| url_cleaner(s))
|
.or_else(|| item.link().map(|s| url_cleaner(s)));
|
||||||
} else {
|
|
||||||
|
// 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 {
|
let err = DataError::ParseEpisodeError {
|
||||||
reason: "No url specified for the item.".into(),
|
reason: "No url specified for the item.".into(),
|
||||||
parent_id,
|
parent_id,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user