4 from .common import InfoExtractor
9 _x = lambda p: xpath_with_ns(p, {'smil': 'http://www.w3.org/2005/SMIL21/Language'})
12 class ThePlatformIE(InfoExtractor):
13 _VALID_URL = r'(?:https?://link\.theplatform\.com/s/[^/]+/|theplatform:)(?P<id>[^/\?]+)'
16 # from http://www.metacafe.com/watch/cb-e9I_cZgTgIPd/blackberrys_big_bold_z30/
17 u'url': u'http://link.theplatform.com/s/dJ5BDC/e9I_cZgTgIPd/meta.smil?format=smil&Tracking=true&mbr=true',
19 u'id': u'e9I_cZgTgIPd',
21 u'title': u'Blackberry\'s big, bold Z30',
22 u'description': u'The Z30 is Blackberry\'s biggest, baddest mobile messaging device yet.',
27 u'skip_download': True,
31 def _get_info(self, video_id):
32 smil_url = ('http://link.theplatform.com/s/dJ5BDC/{0}/meta.smil?'
33 'format=smil&mbr=true'.format(video_id))
34 meta = self._download_xml(smil_url, video_id)
35 info_url = 'http://link.theplatform.com/s/dJ5BDC/{0}?format=preview'.format(video_id)
36 info_json = self._download_webpage(info_url, video_id)
37 info = json.loads(info_json)
39 head = meta.find(_x('smil:head'))
40 body = meta.find(_x('smil:body'))
41 base_url = head.find(_x('smil:meta')).attrib['base']
42 switch = body.find(_x('smil:switch'))
44 for f in switch.findall(_x('smil:video')):
48 'play_path': 'mp4:' + attr['src'],
50 'width': int(attr['width']),
51 'height': int(attr['height']),
52 'vbr': int(attr['system-bitrate']),
54 formats.sort(key=lambda f: (f['height'], f['width'], f['vbr']))
58 'title': info['title'],
60 'description': info['description'],
61 'thumbnail': info['defaultThumbnailUrl'],
62 'duration': info['duration']//1000,
65 def _real_extract(self, url):
66 mobj = re.match(self._VALID_URL, url)
67 video_id = mobj.group('id')
68 return self._get_info(video_id)