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, video_id).find('i')
53 title = item.attrib['t']
57 formats = self._extract_m3u8_formats('http://content.uplynk.com/ext/%s/%s.m3u8' % (self._UPLYNK_OWNER_ID, video_id), video_id, 'mp4', fatal=None)
58 path = item.attrib.get('p')
60 thumbnail = self._THUMBNAIL_TEMPLATE % path
61 http_base_url = 'http://ahttp.crackle.com/' + path
62 for mfs_path, mfs_info in self._MEDIA_FILE_SLOTS.items():
64 'url': http_base_url + mfs_path,
65 'format_id': mfs_path.split('.')[0],
66 'width': mfs_info['width'],
67 'height': mfs_info['height'],
69 for cc in item.findall('cc'):
70 locale = cc.attrib.get('l')
71 v = cc.attrib.get('v')
73 if locale not in subtitles:
74 subtitles[locale] = []
75 subtitles[locale] = [{
76 'url': '%s/%s%s_%s.xml' % (self._SUBTITLE_SERVER, path, locale, v),
79 self._sort_formats(formats, ('width', 'height', 'tbr'))
84 'description': item.attrib.get('d'),
85 'duration': int(item.attrib.get('r'), 16) if item.attrib.get('r') else None,
86 'series': item.attrib.get('sn'),
87 'season_number': int_or_none(item.attrib.get('se')),
88 'episode_number': int_or_none(item.attrib.get('ep')),
89 'thumbnail': thumbnail,
90 'subtitles': subtitles,