Internal youtube support and the youtube-dl extension both cause the
youtube feed URL to be fetched three times per update. Caching the feed
data from feedcore allows internal support to only load the feed once.
The lru_cache removes one of the youtube-dl fetches, not perfect, but
two is better than three. I saw a 40% decrease in update times when
using the internal youtube code.
Throwing an exception from get_channel_id_url() prevents get_cover() and
get_channel_desc() from attempting to fetch a None URL, and provides
more accurate errors.
The lru_cache on get_youtube_id() saves 1ms per youtube channel when
updating. Which adds up with a lot of channels, and might be more on
slower devices.
now a requests.Response is returned instead of the file-like object from urllib.
Fixed all usages of util.urlopen: it simplifies getting json, text encoding detection.
In particular feedcore (responsible for fetching feeds) is simplified.
This is a first pass and could benefit from better usage of the requests api
(Sessions for instance, to keep connection pools)
TODO: download.py
https://bugs.gpodder.org/show_bug.cgi?id=2023 is very annoying, as podcast stopped updating quietly (as long as the offending entry is in the feed). It was also confusing as adding such a failed.
Example taken from http://www.br-online.de/podcast/kalenderblatt/cast.xml
<item>
<title>Kaufhaus Schocken in Stuttgart abgerissen - 02.05.1960</title>
<pubDate>Mon, 02 May 1960 09:05:01 +0100</pubDate>
<description>Das Auge kauft mit! Das gilt nicht nur für die Ware, sondern für das Shoppingerlebnis insgesamt. Das denkt sich Salman Schocken und baut seine Kaufhäuser zu architektonischen Meisterwerken aus. Autorin: Leo Hoffmann</description>
<link>http://cdn-storage.br.de/iLCpbHJGNL9zu6i6NL97bmWH_-by/_-ZS/9-k6528G/600502_0905_radioWissen_Kaufhaus-Schocken-in-Stuttgart-abgerissen.mp3</link>
<enclosure url="http://cdn-storage.br.de/iLCpbHJGNL9zu6i6NL97bmWH_-by/_-ZS/9-k6528G/600502_0905_radioWissen_Kaufhaus-Schocken-in-Stuttgart-abgerissen.mp3" length="3434832" type="audio/mpeg"/>
<guid isPermaLink="false">600502_0905_radioWissen_Kaufhaus-Schocken-in-Stuttgart-abgerissen.mp3</guid>
<itunes:author>Bayern 2</itunes:author>
<itunes:summary>Das Auge kauft mit! Das gilt nicht nur für die Ware, sondern für das Shoppingerlebnis insgesamt. Das denkt sich Salman Schocken und baut seine Kaufhäuser zu architektonischen Meisterwerken aus. Autorin: Leo Hoffmann</itunes:summary>
<itunes:keywords>Kaufhaus Schocken, Stuttgart, Salman Schocken, Einzelhandel, Shopping, Architektur, Erich Mendelsohn, Wissen, Geschichte, Das Kalenderblatt, radioWissen, Feuilleton, Podcast, Bayern 2, Bayerischer Rundfunk</itunes:keywords>
<itunes:duration>00:03:34</itunes:duration>
</item>
Thanks to Ilkka Laukkanen for the initial feature
request and for Kurt McKee and Stefan Kögl for the
implementation in feedparser (since 5.0).
This feature will only work with feedparser >= 5.0,
but will gracefully degrade (ignore RSS redirects)
with older versions of feedparser.