Skip to content

Commit

Permalink
Ignore image enclosures for audio/video in Media RSS (bug 1430)
Browse files Browse the repository at this point in the history
We have only checked if audio and/or video is available in
normal enclosures. This check is now extended to Media RSS
items, because there are feeds that have the image as
enclosure and the media file as Media RSS content.

Example feed: http://www.rtl.fr/emission/a-la-bonne-heure.rss

(This commit has been merged from the "tres" branch)
  • Loading branch information
thp committed Sep 6, 2011
1 parent c1be188 commit dcdaeac
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/gpodder/model.py
Expand Up @@ -712,10 +712,11 @@ def from_feedparser_entry(entry, channel, mimetype_prefs=''):
episode.pubDate = rfc822.mktime_tz(entry.updated_parsed+(0,))

enclosures = entry.get('enclosures', ())
media_rss_content = entry.get('media_content', ())
audio_available = any(e.get('type', '').startswith('audio/') \
for e in enclosures)
for e in enclosures + media_rss_content)
video_available = any(e.get('type', '').startswith('video/') \
for e in enclosures)
for e in enclosures + media_rss_content)

# Create the list of preferred mime types
mimetype_prefs = mimetype_prefs.split(',')
Expand Down Expand Up @@ -746,6 +747,7 @@ def calculate_preference_value(enclosure):
continue

# Skip images in feeds if audio or video is available (bug 979)
# This must (and does) also look in Media RSS enclosures (bug 1430)
if episode.mimetype.startswith('image/') and \
(audio_available or video_available):
continue
Expand All @@ -762,11 +764,14 @@ def calculate_preference_value(enclosure):
return episode

# Media RSS content
for m in entry.get('media_content', ()):
for m in sorted(media_rss_content, key=calculate_preference_value):
episode.mimetype = m.get('type', 'application/octet-stream')
if '/' not in episode.mimetype:
continue

# XXX: Does Media RSS content also have images? If so, we
# might want to skip these too (see above for enclosures).

episode.url = util.normalize_feed_url(m.get('url', ''))
if not episode.url:
continue
Expand Down

0 comments on commit dcdaeac

Please sign in to comment.