2 from __future__ import unicode_literals, division
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/comedians-in-cars-getting-coffee/2498934',
15 'title': 'Everybody Respects A Bloody Nose',
16 'description': 'Jerry is kaffeeklatsching in L.A. with funnyman J.B. Smoove (Saturday Night Live, Real Husbands of Hollywood). They’re headed for brew at 10 Speed Coffee in a 1964 Studebaker Avanti.',
17 'thumbnail': 're:^https?://.*\.jpg',
19 'series': 'Comedians In Cars Getting Coffee',
30 'skip_download': True,
34 # extracted from http://legacyweb-us.crackle.com/flash/ReferrerRedirect.ashx
35 _THUMBNAIL_TEMPLATE = 'http://images-us-am.crackle.com/%stnl_1920x1080.jpg?ts=20140107233116?c=635333335057637614'
55 def _real_extract(self, url):
56 video_id = self._match_id(url)
58 config_doc = self._download_xml(
59 'http://legacyweb-us.crackle.com/flash/QueryReferrer.ashx?site=16',
60 video_id, 'Downloading config')
62 item = self._download_xml(
63 'http://legacyweb-us.crackle.com/app/revamp/vidwallcache.aspx?flags=-1&fm=%s' % video_id,
65 title = item.attrib['t']
68 formats = self._extract_m3u8_formats(
69 'http://content.uplynk.com/ext/%s/%s.m3u8' % (config_doc.attrib['strUplynkOwnerId'], video_id),
70 video_id, 'mp4', m3u8_id='hls', fatal=None)
72 path = item.attrib.get('p')
74 thumbnail = self._THUMBNAIL_TEMPLATE % path
75 http_base_url = 'http://ahttp.crackle.com/' + path
76 for mfs_path, mfs_info in self._MEDIA_FILE_SLOTS.items():
78 'url': http_base_url + mfs_path,
79 'format_id': 'http-' + mfs_path.split('.')[0],
80 'width': mfs_info['width'],
81 'height': mfs_info['height'],
83 for cc in item.findall('cc'):
84 locale = cc.attrib.get('l')
85 v = cc.attrib.get('v')
87 if locale not in subtitles:
88 subtitles[locale] = []
89 subtitles[locale] = [{
90 'url': '%s/%s%s_%s.xml' % (config_doc.attrib['strSubtitleServer'], path, locale, v),
93 self._sort_formats(formats, ('width', 'height', 'tbr', 'format_id'))
98 'description': item.attrib.get('d'),
99 'duration': int(item.attrib.get('r'), 16) / 1000 if item.attrib.get('r') else None,
100 'series': item.attrib.get('sn'),
101 'season_number': int_or_none(item.attrib.get('se')),
102 'episode_number': int_or_none(item.attrib.get('ep')),
103 'thumbnail': thumbnail,
104 'subtitles': subtitles,