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.',
28 'url': 'http://teamcoco.com/video/louis-ck-interview-george-w-bush',
29 'md5': 'cde9ba0fa3506f5f017ce11ead928f9a',
33 'description': 'Louis C.K. got starstruck by George W. Bush, so what? Part one.',
34 'title': 'Louis C.K. Interview Pt. 1 11/3/11',
41 r'"eVar42"\s*:\s*(\d+)',
42 r'Ginger\.TeamCoco\.openInApp\("video",\s*"([^"]+)"',
43 r'"id_not"\s*:\s*(\d+)'
46 def _real_extract(self, url):
47 mobj = re.match(self._VALID_URL, url)
49 display_id = mobj.group('display_id')
50 webpage = self._download_webpage(url, display_id)
52 video_id = mobj.group('video_id')
54 video_id = self._html_search_regex(
55 self._VIDEO_ID_REGEXES, webpage, 'video id')
57 preloads = re.findall(r'"preload":\s*"([^"]+)"', webpage)
59 raise ExtractorError('Preload information could not be extracted')
60 preload = max([(len(p), p) for p in preloads])[1]
61 data = self._parse_json(
62 base64.b64decode(preload.encode('ascii')).decode('utf-8'), video_id)
65 get_quality = qualities(['500k', '480p', '1000k', '720p', '1080p'])
66 for filed in data['files']:
67 if filed['type'] == 'hls':
68 formats.extend(self._extract_m3u8_formats(
69 filed['url'], video_id, ext='mp4'))
71 m_format = re.search(r'(\d+(k|p))\.mp4', filed['url'])
72 if m_format is not None:
73 format_id = m_format.group(1)
75 format_id = filed['bitrate']
78 if filed['bitrate'].isdigit()
85 'format_id': format_id,
86 'quality': get_quality(format_id),
89 self._sort_formats(formats)
93 'display_id': display_id,
95 'title': data['title'],
96 'thumbnail': data.get('thumb', {}).get('href'),
97 'description': data.get('teaser'),
98 'duration': data.get('duration'),
99 'age_limit': self._family_friendly_search(webpage),