2 from __future__ import unicode_literals
6 from .common import InfoExtractor
18 class TeamcocoIE(InfoExtractor):
19 _VALID_URL = r'https?://teamcoco\.com/(?P<id>([^/]+/)*[^/?#]+)'
22 'url': 'http://teamcoco.com/video/mary-kay-remote',
23 'md5': '55d532f81992f5c92046ad02fec34d7d',
27 'title': 'Conan Becomes A Mary Kay Beauty Consultant',
28 'description': 'Mary Kay is perhaps the most trusted name in female beauty, so of course Conan is a natural choice to sell their products.',
30 'upload_date': '20140402',
31 'timestamp': 1396407600,
34 'url': 'http://teamcoco.com/video/louis-ck-interview-george-w-bush',
35 'md5': 'cde9ba0fa3506f5f017ce11ead928f9a',
39 'description': 'Louis C.K. got starstruck by George W. Bush, so what? Part one.',
40 'title': 'Louis C.K. Interview Pt. 1 11/3/11',
42 'upload_date': '20111104',
43 'timestamp': 1320405840,
46 'url': 'http://teamcoco.com/video/timothy-olyphant-drinking-whiskey',
50 'title': 'Timothy Olyphant Raises A Toast To “Justified”',
51 'description': 'md5:15501f23f020e793aeca761205e42c24',
52 'upload_date': '20150415',
53 'timestamp': 1429088400,
56 'skip_download': True, # m3u8 downloads
59 'url': 'http://teamcoco.com/video/full-episode-mon-6-1-joel-mchale-jake-tapper-and-musical-guest-courtney-barnett?playlist=x;eyJ0eXBlIjoidGFnIiwiaWQiOjl9',
63 'title': 'Full Episode - Mon. 6/1 - Joel McHale, Jake Tapper, And Musical Guest Courtney Barnett',
64 'description': 'Guests: Joel McHale, Jake Tapper, And Musical Guest Courtney Barnett',
67 'skip_download': True, # m3u8 downloads
69 'skip': 'This video is no longer available.',
71 'url': 'http://teamcoco.com/video/the-conan-audiencey-awards-for-04/25/18',
72 'only_matching': True,
74 'url': 'http://teamcoco.com/italy/conan-jordan-schlansky-hit-the-streets-of-florence',
75 'only_matching': True,
77 'url': 'http://teamcoco.com/haiti/conan-s-haitian-history-lesson',
78 'only_matching': True,
80 'url': 'http://teamcoco.com/israel/conan-hits-the-streets-beaches-of-tel-aviv',
81 'only_matching': True,
85 def _graphql_call(self, query_template, object_type, object_id):
86 find_object = 'find' + object_type
87 return self._download_json(
88 'http://teamcoco.com/graphql/', object_id, data=json.dumps({
89 'query': query_template % (find_object, object_id)
90 }))['data'][find_object]
92 def _real_extract(self, url):
93 display_id = self._match_id(url)
95 response = self._graphql_call('''{
115 ... on NotFoundSlug {
119 }''', 'Slug', display_id)
120 if response.get('status'):
121 raise ExtractorError('This video is no longer available.', expected=True)
123 record = response['record']
124 video_id = record['id']
126 video_sources = self._graphql_call('''{
130 }''', 'RecordVideoSource', video_id) or {}
133 get_quality = qualities(['low', 'sd', 'hd', 'uhd'])
134 for format_id, src in video_sources.get('src', {}).items():
135 if not isinstance(src, dict):
137 src_url = src.get('src')
140 ext = determine_ext(src_url, mimetype2ext(src.get('type')))
141 if format_id == 'hls' or ext == 'm3u8':
142 # compat_urllib_parse.urljoin does not work here
143 if src_url.startswith('/'):
144 src_url = 'http://ht.cdn.turner.com/tbs/big/teamcoco' + src_url
145 formats.extend(self._extract_m3u8_formats(
146 src_url, video_id, 'mp4', m3u8_id=format_id, fatal=False))
148 if src_url.startswith('/mp4:protected/'):
149 # TODO Correct extraction for these files
151 tbr = int_or_none(self._search_regex(
152 r'(\d+)k\.mp4', src_url, 'tbr', default=None))
158 'format_id': format_id,
159 'quality': get_quality(format_id),
162 formats = self._extract_m3u8_formats(
163 record['file']['url'], video_id, 'mp4', fatal=False)
164 self._sort_formats(formats)
168 'display_id': display_id,
170 'title': record['title'],
171 'thumbnail': record.get('thumb', {}).get('preview'),
172 'description': record.get('teaser'),
173 'duration': parse_duration(record.get('duration')),
174 'timestamp': parse_iso8601(record.get('publishOn')),