podcastparser Python Library
repository·master·Indexed 41 days ago
https://github.com/gpodder/podcastparserA Python library for parsing RSS 2.0 and Atom podcast feeds, developed as part of the gPodder project. It supports Paged Feeds (RFC 5005), Podlove Simple Chapters, and the Podcast Index Podcast Namespace, providing a dictionary of parsed podcast and episode data via the podcastparser.parse() function.
What's inside podcastparser
- podcastparser is a Python library designed to provide a simple, fast, and efficient way to parse RSS- and Atom-based podcast feeds. It is part of the gPodder project.
Run unit tests with pytest
masterTo run the unit tests for podcastparser, you must havepytestinstalled. Execute thepytestcommand from the repository's root directory.pytestParse podcast feeds using the Requests library
masterWhen using the
requestslibrary, ensure you setstream=Trueand enabledecode_contenton the raw response to correctly pass the file-like object topodcastparser.parse().import podcastparser import requests url = 'https://example.net/podcast.atom' with requests.get(url, stream=True) as response: response.raw.decode_content = True parsed = podcastparser.parse(url, response.raw) # parsed is a dict import pprint pprint.pprint(parsed)Parse podcast feeds with podcastparser.parse()
masterUse
podcastparser.parse(url, file_object)to parse a podcast feed. The function accepts the feed URL as a string and a file-like object (the response body) as the second argument. The result is a dictionary containing the parsed podcast and episode data.Supported feed types include:
- RSS 2.0
- Atom Syndication Format (RFC 4287)
It also supports specifications like Paged Feeds (RFC 5005), Podlove Simple Chapters, and the Podcast Index Podcast Namespace.
import podcastparser import urllib.request feedurl = 'http://example.com/feed.xml' # Using urllib.request parsed = podcastparser.parse(feedurl, urllib.request.urlopen(feedurl)) # parsed is a dict import pprint pprint.pprint(parsed)Reference: Supported Atom elements and attributes
masterThe following Atom elements and attributes are parsed by
podcastparser.atom:feed atom:feed/atom:title atom:feed/atom:subtitle atom:feed/atom:icon atom:feed/atom:link@href atom:feed/atom:entry atom:feed/atom:entry/atom:id atom:feed/atom:entry/atom:title atom:feed/atom:entry/atom:link@rel=enclosure atom:feed/atom:entry/atom:link@rel=(self|alternate) atom:feed/atom:entry/atom:link@rel=payment atom:feed/atom:entry/atom:content atom:feed/atom:entry/atom:published atom:feed/atom:entry/media:thumbnail atom:feed/atom:entry/media:group/media:thumbnail atom:feed/atom:entry/psc:chapters atom:feed/atom:entry/psc:chapters/psc:chapterReference: Supported RSS elements and attributes
masterThe following RSS elements and attributes are parsed by
podcastparser. Note that whitespace is often squashed for text fields.rss@xml:base rss/channel rss/channel/title rss/channel/link rss/channel/description rss/channel/itunes:summary rss/channel/image/url rss/channel/itunes:image rss/channel/itunes:type rss/channel/itunes:keywords rss/channel/atom:link@rel=payment rss/channel/generator rss/channel/language rss/channel/itunes:author rss/channel/itunes:owner rss/channel/itunes:category rss/channel/itunes:explicit rss/channel/itunes:new-feed-url rss/channel/podcast:locked rss/channel/podcast:funding rss/redirect/newLocation rss/channel/item rss/channel/item/guid rss/channel/item/title rss/channel/item/link rss/channel/item/description rss/channel/item/itunes:summary rss/channel/item/itunes:subtitle rss/channel/item/content:encoded rss/channel/item/itunes:duration rss/channel/item/pubDate rss/channel/item/atom:link@rel=payment rss/channel/item/atom:link@rel=enclosure rss/channel/item/itunes:image rss/channel/item/media:thumbnail rss/channel/item/media:group/media:thumbnail rss/channel/item/media:content rss/channel/item/media:group/media:content rss/channel/item/enclosure rss/channel/item/psc:chapters rss/channel/item/psc:chapters/psc:chapter rss/channel/item/itunes:explicit rss/channel/item/itunes:author rss/channel/item/itunes:season rss/channel/item/itunes:episode rss/channel/item/itunes:episodeType rss/channel/item/podcast:chapters rss/channel/item/podcast:person rss/channel/item/podcast:transcript