]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/theplatform.py
cec65261bfffd2a25702634047a99526fa3a7d10
   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
): 
  14     _VALID_URL 
= r
'(?:https?://link\.theplatform\.com/s/[^/]+/|theplatform:)(?P<id>[^/\?]+)' 
  17         # from http://www.metacafe.com/watch/cb-e9I_cZgTgIPd/blackberrys_big_bold_z30/ 
  18         u
'url': u
'http://link.theplatform.com/s/dJ5BDC/e9I_cZgTgIPd/meta.smil?format=smil&Tracking=true&mbr=true', 
  20             u
'id': u
'e9I_cZgTgIPd', 
  22             u
'title': u
'Blackberry\'s big, bold Z30', 
  23             u
'description': u
'The Z30 is Blackberry\'s biggest, baddest mobile messaging device yet.', 
  28             u
'skip_download': True, 
  32     def _get_info(self
, video_id
): 
  33         smil_url 
= ('http://link.theplatform.com/s/dJ5BDC/{0}/meta.smil?' 
  34             'format=smil&mbr=true'.format(video_id
)) 
  35         meta 
= self
._download
_xml
(smil_url
, video_id
) 
  40                 for n 
in meta
.findall(_x('.//smil:ref')) 
  41                 if n
.attrib
.get('title') == u
'Geographic Restriction') 
  45             raise ExtractorError(error_msg
, expected
=True) 
  47         info_url 
= 'http://link.theplatform.com/s/dJ5BDC/{0}?format=preview'.format(video_id
) 
  48         info_json 
= self
._download
_webpage
(info_url
, video_id
) 
  49         info 
= json
.loads(info_json
) 
  51         head 
= meta
.find(_x('smil:head')) 
  52         body 
= meta
.find(_x('smil:body')) 
  53         base_url 
= head
.find(_x('smil:meta')).attrib
['base'] 
  54         switch 
= body
.find(_x('smil:switch')) 
  56         for f 
in switch
.findall(_x('smil:video')): 
  60                 'play_path': 'mp4:' + attr
['src'], 
  62                 'width': int(attr
['width']), 
  63                 'height': int(attr
['height']), 
  64                 'vbr': int(attr
['system-bitrate']), 
  66         formats
.sort(key
=lambda f
: (f
['height'], f
['width'], f
['vbr'])) 
  70             'title': info
['title'], 
  72             'description': info
['description'], 
  73             'thumbnail': info
['defaultThumbnailUrl'], 
  74             'duration': info
['duration']//1000, 
  77     def _real_extract(self
, url
): 
  78         mobj 
= re
.match(self
._VALID
_URL
, url
) 
  79         video_id 
= mobj
.group('id') 
  80         return self
._get
_info
(video_id
)