]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/theplatform.py
4 from .common
import InfoExtractor
10 _x
= lambda p
: xpath_with_ns(p
, {'smil': 'http://www.w3.org/2005/SMIL21/Language'})
13 class ThePlatformIE(InfoExtractor
):
15 (?:https?://(?:link|player)\.theplatform\.com/[sp]/[^/]+/
16 (?P<config>[^/\?]+/(?:swf|config)/select/)?
17 |theplatform:)(?P<id>[^/\?&]+)'''
20 # from http://www.metacafe.com/watch/cb-e9I_cZgTgIPd/blackberrys_big_bold_z30/
21 u
'url': u
'http://link.theplatform.com/s/dJ5BDC/e9I_cZgTgIPd/meta.smil?format=smil&Tracking=true&mbr=true',
23 u
'id': u
'e9I_cZgTgIPd',
25 u
'title': u
'Blackberry\'s big, bold Z30',
26 u
'description': u
'The Z30 is Blackberry\'s biggest, baddest mobile messaging device yet.',
31 u
'skip_download': True,
35 def _get_info(self
, video_id
, smil_url
):
36 meta
= self
._download
_xml
(smil_url
, video_id
)
41 for n
in meta
.findall(_x('.//smil:ref'))
42 if n
.attrib
.get('title') == u
'Geographic Restriction')
46 raise ExtractorError(error_msg
, expected
=True)
48 info_url
= 'http://link.theplatform.com/s/dJ5BDC/{0}?format=preview'.format(video_id
)
49 info_json
= self
._download
_webpage
(info_url
, video_id
)
50 info
= json
.loads(info_json
)
52 head
= meta
.find(_x('smil:head'))
53 body
= meta
.find(_x('smil:body'))
55 f4m_node
= body
.find(_x('smil:seq/smil:video'))
56 if f4m_node
is not None:
59 # the parameters are from syfy.com, other sites may use others
60 'url': f4m_node
.attrib
['src'] + '?g=UXWGVKRWHFSP&hdcore=3.0.3',
63 base_url
= head
.find(_x('smil:meta')).attrib
['base']
64 switch
= body
.find(_x('smil:switch'))
66 for f
in switch
.findall(_x('smil:video')):
68 width
= int(attr
['width'])
69 height
= int(attr
['height'])
70 vbr
= int(attr
['system-bitrate']) // 1000
71 format_id
= '%dx%d_%dk' % (width
, height
, vbr
)
73 'format_id': format_id
,
75 'play_path': 'mp4:' + attr
['src'],
81 self
._sort
_formats
(formats
)
85 'title': info
['title'],
87 'description': info
['description'],
88 'thumbnail': info
['defaultThumbnailUrl'],
89 'duration': info
['duration']//1000,
92 def _real_extract(self
, url
):
93 mobj
= re
.match(self
._VALID
_URL
, url
)
94 video_id
= mobj
.group('id')
95 if mobj
.group('config'):
96 config_url
= url
+ '&form=json'
97 config_url
= config_url
.replace('swf/', 'config/')
98 config_json
= self
._download
_webpage
(config_url
, video_id
, u
'Downloading config')
99 config
= json
.loads(config_json
)
100 smil_url
= config
['releaseUrl'] + '&format=SMIL&formats=MPEG4'
102 smil_url
= ('http://link.theplatform.com/s/dJ5BDC/{0}/meta.smil?'
103 'format=smil&mbr=true'.format(video_id
))
104 return self
._get
_info
(video_id
, smil_url
)