]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/crackle.py
   2 from __future__ 
import unicode_literals
 
   4 from .common 
import InfoExtractor
 
   5 from ..utils 
import int_or_none
 
   8 class CrackleIE(InfoExtractor
): 
   9     _VALID_URL 
= r
'(?:crackle:|https?://(?:www\.)?crackle\.com/(?:playlist/\d+/|(?:[^/]+/)+))(?P<id>\d+)' 
  11         'url': 'http://www.crackle.com/the-art-of-more/2496419', 
  15             'title': 'Heavy Lies the Head', 
  16             'description': 'md5:bb56aa0708fe7b9a4861535f15c3abca', 
  20             'skip_download': True, 
  24     # extracted from http://legacyweb-us.crackle.com/flash/QueryReferrer.ashx 
  25     _SUBTITLE_SERVER 
= 'http://web-us-az.crackle.com' 
  26     _UPLYNK_OWNER_ID 
= 'e8773f7770a44dbd886eee4fca16a66b' 
  27     _THUMBNAIL_TEMPLATE 
= 'http://images-us-am.crackle.com/%stnl_1920x1080.jpg?ts=20140107233116?c=635333335057637614' 
  29     # extracted from http://legacyweb-us.crackle.com/flash/ReferrerRedirect.ashx 
  49     def _real_extract(self
, url
): 
  50         video_id 
= self
._match
_id
(url
) 
  51         item 
= self
._download
_xml
( 
  52             'http://legacyweb-us.crackle.com/app/revamp/vidwallcache.aspx?flags=-1&fm=%s' % video_id
, 
  54         title 
= item
.attrib
['t'] 
  58         formats 
= self
._extract
_m
3u8_formats
( 
  59             'http://content.uplynk.com/ext/%s/%s.m3u8' % (self
._UPLYNK
_OWNER
_ID
, video_id
), 
  60             video_id
, 'mp4', m3u8_id
='hls', fatal
=None) 
  61         path 
= item
.attrib
.get('p') 
  63             thumbnail 
= self
._THUMBNAIL
_TEMPLATE 
% path
 
  64             http_base_url 
= 'http://ahttp.crackle.com/' + path
 
  65             for mfs_path
, mfs_info 
in self
._MEDIA
_FILE
_SLOTS
.items(): 
  67                     'url': http_base_url 
+ mfs_path
, 
  68                     'format_id': 'http-' + mfs_path
.split('.')[0], 
  69                     'width': mfs_info
['width'], 
  70                     'height': mfs_info
['height'], 
  72             for cc 
in item
.findall('cc'): 
  73                 locale 
= cc
.attrib
.get('l') 
  74                 v 
= cc
.attrib
.get('v') 
  76                     if locale 
not in subtitles
: 
  77                         subtitles
[locale
] = [] 
  78                     subtitles
[locale
] = [{ 
  79                         'url': '%s/%s%s_%s.xml' % (self
._SUBTITLE
_SERVER
, path
, locale
, v
), 
  82         self
._sort
_formats
(formats
, ('width', 'height', 'tbr', 'format_id')) 
  87             'description': item
.attrib
.get('d'), 
  88             'duration': int(item
.attrib
.get('r'), 16) if item
.attrib
.get('r') else None, 
  89             'series': item
.attrib
.get('sn'), 
  90             'season_number': int_or_none(item
.attrib
.get('se')), 
  91             'episode_number': int_or_none(item
.attrib
.get('ep')), 
  92             'thumbnail': thumbnail
, 
  93             'subtitles': subtitles
,