Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
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...
commit f256ae4073d0cc91c8588f57e2302fcf9f701b9d 1 parent b355777
@willkg authored
Showing with 17 additions and 5 deletions.
  1. +6 −5 apps/videos/feeds.py
  2. +11 −0 apps/videos/models.py
View
11 apps/videos/feeds.py
@@ -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'])
enclosures.append(data)
-
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')
else:
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')
else:
return None
View
11 apps/videos/models.py
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.