Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fix YouTube-sourced videos in feeds for Miro

Miro can handle YouTube links which are technically not enclosure-material,
but they need to show up in the "right place". So we put it in an enclosure.

We have it listed last in the list of enclosures if there are others since
any enclosure is better than this one.
  • Loading branch information...
1 parent b355777 commit f256ae4073d0cc91c8588f57e2302fcf9f701b9d @willkg committed
Showing with 17 additions and 5 deletions.
  1. +6 −5 apps/videos/
  2. +11 −0 apps/videos/
11 apps/videos/
@@ -93,12 +93,13 @@ def item_author_name(self, video):
def item_enclosures(self, item):
enclosures = []
for fmt in item.get_available_formats():
- data = {'url': fmt['url'], 'type': fmt['mime_type']}
- if fmt['length']:
+ data = {'url': fmt['url']}
+ if fmt.get('mime_type'):
+ data['mime_type'] = fmt['mime_type']
+ if fmt.get('length'):
data['fileSize'] = str(fmt['length'])
return enclosures
def item_media(self, item):
@@ -124,14 +125,14 @@ def item_enclosure_url(self, item):
def item_enclosure_length(self, item):
fmt = item.get_available_formats()
if fmt:
- return fmt[0]['length']
+ return fmt[0].get('length')
return None
def item_enclosure_mime_type(self, item):
fmt = item.get_available_formats()
if fmt:
- return fmt[0]['mime_type']
+ return fmt[0].get('mime_type')
return None
11 apps/videos/
@@ -287,6 +287,17 @@ def get_available_formats(self):
if url:
result.append({'url': url, 'length': length,
'mime_type': mime_type})
+ # Now we do this goofy thing where if this is a YouTube video
+ # we add it to the list of available formats. That's because
+ # this gets used to build the enclosures for a feed and we
+ # want to make sure this works with Miro.
+ #
+ # We put it last in the list because most options are better
+ # than this one.
+ if self.source_url and 'youtube' in self.source_url.lower():
+ result.append({'url': self.source_url, 'mime_type': 'video/flv'})
return result

0 comments on commit f256ae4

Please sign in to comment.
Something went wrong with that request. Please try again.