From 5a16cd38e4b32fe379cb536cd039c0b41050173b Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Tue, 18 May 2010 11:28:55 +0200 Subject: [PATCH] Skip images if other content is available (bug 979) In case where RSS feeds provide multiple enclosures per item, we want to skip all image feeds, because we prefer audio/video content to plain images. --- src/gpodder/model.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/gpodder/model.py b/src/gpodder/model.py index aea7f2fc..ee492414 100644 --- a/src/gpodder/model.py +++ b/src/gpodder/model.py @@ -697,8 +697,14 @@ class PodcastEpisode(PodcastModelObject): if entry.get('updated_parsed', None): episode.pubDate = rfc822.mktime_tz(entry.updated_parsed+(0,)) + enclosures = entry.get('enclosures', ()) + audio_available = any(e.get('type', '').startswith('audio/') \ + for e in enclosures) + video_available = any(e.get('type', '').startswith('video/') \ + for e in enclosures) + # Enclosures - for e in entry.get('enclosures', ()): + for e in enclosures: episode.mimetype = e.get('type', 'application/octet-stream') if episode.mimetype == '': # See Maemo bug 10036 @@ -708,6 +714,11 @@ class PodcastEpisode(PodcastModelObject): if '/' not in episode.mimetype: continue + # Skip images in feeds if audio or video is available (bug 979) + if episode.mimetype.startswith('image/') and \ + (audio_available or video_available): + continue + episode.url = util.normalize_feed_url(e.get('href', '')) if not episode.url: continue -- 2.11.4.GIT