1 from __future__ import unicode_literals
6 from .common import InfoExtractor
13 class TeamcocoIE(InfoExtractor):
14 _VALID_URL = r'http://teamcoco\.com/video/(?P<video_id>[0-9]+)?/?(?P<display_id>.*)'
17 'url': 'http://teamcoco.com/video/80187/conan-becomes-a-mary-kay-beauty-consultant',
18 'md5': '3f7746aa0dc86de18df7539903d399ea',
22 'title': 'Conan Becomes A Mary Kay Beauty Consultant',
23 'description': 'Mary Kay is perhaps the most trusted name in female beauty, so of course Conan is a natural choice to sell their products.',
27 'url': 'http://teamcoco.com/video/louis-ck-interview-george-w-bush',
28 'md5': 'cde9ba0fa3506f5f017ce11ead928f9a',
32 'description': 'Louis C.K. got starstruck by George W. Bush, so what? Part one.',
33 'title': 'Louis C.K. Interview Pt. 1 11/3/11',
39 r'"eVar42"\s*:\s*(\d+)',
40 r'Ginger\.TeamCoco\.openInApp\("video",\s*"([^"]+)"',
41 r'"id_not"\s*:\s*(\d+)'
44 def _real_extract(self, url):
45 mobj = re.match(self._VALID_URL, url)
47 display_id = mobj.group('display_id')
48 webpage = self._download_webpage(url, display_id)
50 video_id = mobj.group('video_id')
52 video_id = self._html_search_regex(
53 self._VIDEO_ID_REGEXES, webpage, 'video id')
55 preloads = re.findall(r'"preload":\s*"([^"]+)"', webpage)
57 raise ExtractorError('Preload information could not be extracted')
58 preload = max([(len(p), p) for p in preloads])[1]
59 data = self._parse_json(
60 base64.b64decode(preload.encode('ascii')).decode('utf-8'), video_id)
63 get_quality = qualities(['500k', '480p', '1000k', '720p', '1080p'])
64 for filed in data['files']:
65 if filed['type'] == 'hls':
66 formats.extend(self._extract_m3u8_formats(
67 filed['url'], video_id, ext='mp4'))
69 m_format = re.search(r'(\d+(k|p))\.mp4', filed['url'])
70 if m_format is not None:
71 format_id = m_format.group(1)
73 format_id = filed['bitrate']
76 if filed['bitrate'].isdigit()
83 'format_id': format_id,
84 'quality': get_quality(format_id),
87 self._sort_formats(formats)
91 'display_id': display_id,
93 'title': data['title'],
94 'thumbnail': data.get('thumb', {}).get('href'),
95 'description': data.get('teaser'),
96 'age_limit': self._family_friendly_search(webpage),