2 from __future__ import unicode_literals, division
4 from .common import InfoExtractor
5 from ..utils import int_or_none
8 class CrackleIE(InfoExtractor):
9 _GEO_COUNTRIES = ['US']
10 _VALID_URL = r'(?:crackle:|https?://(?:(?:www|m)\.)?crackle\.com/(?:playlist/\d+/|(?:[^/]+/)+))(?P<id>\d+)'
12 'url': 'http://www.crackle.com/comedians-in-cars-getting-coffee/2498934',
16 'title': 'Everybody Respects A Bloody Nose',
17 '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.',
18 'thumbnail': r're:^https?://.*\.jpg',
20 'series': 'Comedians In Cars Getting Coffee',
32 'skip_download': True,
61 # extracted from http://legacyweb-us.crackle.com/flash/ReferrerRedirect.ashx
81 def _real_extract(self, url):
82 video_id = self._match_id(url)
84 config_doc = self._download_xml(
85 'http://legacyweb-us.crackle.com/flash/QueryReferrer.ashx?site=16',
86 video_id, 'Downloading config')
88 item = self._download_xml(
89 'http://legacyweb-us.crackle.com/app/revamp/vidwallcache.aspx?flags=-1&fm=%s' % video_id,
90 video_id, headers=self.geo_verification_headers()).find('i')
91 title = item.attrib['t']
94 formats = self._extract_m3u8_formats(
95 'http://content.uplynk.com/ext/%s/%s.m3u8' % (config_doc.attrib['strUplynkOwnerId'], video_id),
96 video_id, 'mp4', m3u8_id='hls', fatal=None)
98 path = item.attrib.get('p')
100 for width, height in self._THUMBNAIL_RES:
101 res = '%dx%d' % (width, height)
104 'url': 'http://images-us-am.crackle.com/%stnl_%s.jpg' % (path, res),
109 http_base_url = 'http://ahttp.crackle.com/' + path
110 for mfs_path, mfs_info in self._MEDIA_FILE_SLOTS.items():
112 'url': http_base_url + mfs_path,
113 'format_id': 'http-' + mfs_path.split('.')[0],
114 'width': mfs_info['width'],
115 'height': mfs_info['height'],
117 for cc in item.findall('cc'):
118 locale = cc.attrib.get('l')
119 v = cc.attrib.get('v')
121 if locale not in subtitles:
122 subtitles[locale] = []
123 for url_ext, ext in (('vtt', 'vtt'), ('xml', 'tt')):
124 subtitles.setdefault(locale, []).append({
125 'url': '%s/%s%s_%s.%s' % (config_doc.attrib['strSubtitleServer'], path, locale, v, url_ext),
128 self._sort_formats(formats, ('width', 'height', 'tbr', 'format_id'))
133 'description': item.attrib.get('d'),
134 'duration': int(item.attrib.get('r'), 16) / 1000 if item.attrib.get('r') else None,
135 'series': item.attrib.get('sn'),
136 'season_number': int_or_none(item.attrib.get('se')),
137 'episode_number': int_or_none(item.attrib.get('ep')),
138 'thumbnails': thumbnails,
139 'subtitles': subtitles,