- return 'http://mtv.mtvnimages.com/uri/' + uri
-
- def _extract_video_url(self, metadataXml):
- if '/error_country_block.swf' in metadataXml:
- raise ExtractorError(u'This video is not available from your country.', expected=True)
- mdoc = xml.etree.ElementTree.fromstring(metadataXml.encode('utf-8'))
- renditions = mdoc.findall('.//rendition')
-
- # For now, always pick the highest quality.
- rendition = renditions[-1]
-
- try:
- _,_,ext = rendition.attrib['type'].partition('/')
- format = ext + '-' + rendition.attrib['width'] + 'x' + rendition.attrib['height'] + '_' + rendition.attrib['bitrate']
- rtmp_video_url = rendition.find('./src').text
- except KeyError:
- raise ExtractorError('Invalid rendition field.')
- video_url = self._transform_rtmp_url(rtmp_video_url)
- return {'ext': ext, 'url': video_url, 'format': format}
+ search_path = '%s/%s' % (_media_xml_tag('group'), _media_xml_tag('thumbnail'))
+ thumb_node = itemdoc.find(search_path)
+ if thumb_node is None:
+ return None
+ else:
+ return thumb_node.attrib['url']
+
+ def _extract_video_formats(self, mdoc):
+ if re.match(r'.*/error_country_block\.swf$', mdoc.find('.//src').text) is not None:
+ raise ExtractorError('This video is not available from your country.', expected=True)
+
+ formats = []
+ for rendition in mdoc.findall('.//rendition'):
+ try:
+ _, _, ext = rendition.attrib['type'].partition('/')
+ rtmp_video_url = rendition.find('./src').text
+ formats.append({'ext': ext,
+ 'url': self._transform_rtmp_url(rtmp_video_url),
+ 'format_id': rendition.get('bitrate'),
+ 'width': int(rendition.get('width')),
+ 'height': int(rendition.get('height')),
+ })
+ except (KeyError, TypeError):
+ raise ExtractorError('Invalid rendition field.')
+ return formats