Step 3: feed fetch and parse

Conditional GET plus an RSS-first, Atom-fallback parser normalising both
into one entry model, with iTunes explicit and ttl handling carried over
from the Python. Enclosures are recorded as pending; nothing downloads yet.

GUID falls back guid -> link -> enclosure url -> title rather than hashing
the description as the original did.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RPyeapneuXrCdojsaiXGbe
This commit is contained in:
2026-09-09 20:34:09 +00:00
parent a13f19136c
commit ab2583fc64
6 changed files with 663 additions and 15 deletions

18
tests/data/atom.xml Normal file
View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Atom Cast</title>
<link rel="alternate" href="https://example.org/"/>
<updated>2004-02-29T01:00:00Z</updated>
<id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
<entry>
<title>Atom Episode One</title>
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
<updated>2004-02-29T01:00:00Z</updated>
<published>2004-02-29T01:00:00Z</published>
<link rel="alternate" href="https://example.org/ep/1"/>
<link rel="enclosure" type="audio/mp4" length="9876543" href="https://example.org/ep1.m4a"/>
<summary>An Atom entry carrying an enclosure link.</summary>
<category term="Tech"/>
</entry>
</feed>

37
tests/data/rss2.xml Normal file
View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">
<channel>
<title>Test Cast</title>
<link>https://example.com/</link>
<description>A synthetic feed used by the parser tests.</description>
<ttl>45</ttl>
<itunes:explicit>no</itunes:explicit>
<item>
<title>Episode One</title>
<link>https://example.com/ep/1</link>
<guid isPermaLink="true">https://example.com/ep/1</guid>
<pubDate>Sun, 29 Feb 2004 01:00:00 +0000</pubDate>
<description>&lt;p&gt;First one.&lt;/p&gt;</description>
<category>Tech</category>
<itunes:explicit>no</itunes:explicit>
<enclosure url="https://example.com/ep1.mp3" length="12345678" type="audio/mpeg"/>
</item>
<item>
<title>Episode Two</title>
<guid isPermaLink="false">ep-2-guid</guid>
<pubDate>Mon, 01 Mar 2004 01:00:00 +0000</pubDate>
<description>Salty language.</description>
<itunes:explicit>yes</itunes:explicit>
<enclosure url="https://example.com/ep2.mp3" length="222" type="audio/mpeg"/>
</item>
<item>
<title>Episode Three</title>
<guid isPermaLink="false">ep-3-guid</guid>
<description>Distributed the old way.</description>
<enclosure url="https://example.com/ep3.torrent" length="4096" type="application/x-bittorrent"/>
</item>
</channel>
</rss>