Skip to content

Commit edf81fb

Browse files
authored
Merge pull request #109 from CrociDB/bug/podcast-link
bug: podcast download link not available
2 parents 7578ed7 + 30f05e8 commit edf81fb

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

src/core/feed/feedparser.rs

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,22 @@ pub fn get_feed_entries_doc(
175175
return true;
176176
}
177177

178+
if t.tag_name().name() == "enclosure"
179+
&& let Some(text) = t.attribute("url")
180+
&& let Ok(url) = Url::parse(text)
181+
&& (url.scheme() == "http" || url.scheme() == "https")
182+
{
183+
return true;
184+
}
185+
178186
t.tag_name().name() == "link"
179187
})
180188
.and_then(|t| {
181189
if t.text().is_none() {
190+
if t.attribute("url").is_some() {
191+
return t.attribute("url");
192+
}
193+
182194
t.attribute("href")
183195
} else {
184196
t.text()
@@ -689,7 +701,7 @@ mod tests {
689701
</feed>"#;
690702

691703
let entries = get_feed_entries_doc(xml, "Channel Author")
692-
.expect("failed to parse RSS entries with entry-level authors");
704+
.expect("failed to parse feed youtube style");
693705
assert_eq!(entries.len(), 1);
694706

695707
let entry = &entries[0];
@@ -699,4 +711,42 @@ mod tests {
699711
assert_eq!(entry.author, "Some Youtube Author");
700712
assert_eq!(entry.description, "This is a description!");
701713
}
714+
715+
#[test]
716+
fn get_feed_entries_podcast_style() {
717+
let xml = r#"<?xml version="1.0" encoding="UTF-8"?>
718+
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
719+
<channel>
720+
<atom:link href="https://podcast_link.com" rel="self" type="application/rss+xml"/>
721+
<title>Podcast Title</title>
722+
<link>https://podcast_link.com</link>
723+
<item>
724+
<title>Podcast Entry Title</title>
725+
<description>Podcast Entry Description</description>
726+
<pubDate>Fri, 05 Dec 2025 18:27:00 -0000</pubDate>
727+
<itunes:episodeType>full</itunes:episodeType>
728+
<itunes:author>Podcast Author</itunes:author>
729+
<itunes:image href="https://podcast_link.com/thumbnail"/>
730+
<itunes:subtitle></itunes:subtitle>
731+
<itunes:summary>Podcast Entry Description #1</itunes:summary>
732+
<content:encoded>Podcast Content Data</content:encoded>
733+
<itunes:duration>4634</itunes:duration>
734+
<itunes:explicit>no</itunes:explicit>
735+
<guid isPermaLink="false"><![CDATA[1bae995c-d208-11f0-8bf7-cb6936959f42]]></guid>
736+
<enclosure url="https://podcast_link.com/audio" length="0" type="audio/mpeg"/>
737+
</item>
738+
</channel>
739+
</rss>"#;
740+
741+
let entries = get_feed_entries_doc(xml, "Channel Author")
742+
.expect("failed to parse feed podcasty style");
743+
assert_eq!(entries.len(), 1);
744+
745+
let entry = &entries[0];
746+
747+
assert_eq!(entry.title, "Podcast Entry Title");
748+
assert_eq!(entry.url, "https://podcast_link.com/audio");
749+
assert_eq!(entry.author, "Podcast Author");
750+
assert_eq!(entry.description, "Podcast Entry Description");
751+
}
702752
}

0 commit comments

Comments
 (0)