]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/teamcoco.py
3 from .turner
import TurnerBaseIE
15 class TeamcocoIE(TurnerBaseIE
):
16 _VALID_URL
= r
'https?://(?:\w+\.)?teamcoco\.com/(?P<id>([^/]+/)*[^/?#]+)'
19 'url': 'http://teamcoco.com/video/mary-kay-remote',
20 'md5': '55d532f81992f5c92046ad02fec34d7d',
24 'title': 'Conan Becomes A Mary Kay Beauty Consultant',
25 '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 'upload_date': '20140402',
28 'timestamp': 1396407600,
31 'url': 'http://teamcoco.com/video/louis-ck-interview-george-w-bush',
32 'md5': 'cde9ba0fa3506f5f017ce11ead928f9a',
36 'description': 'Louis C.K. got starstruck by George W. Bush, so what? Part one.',
37 'title': 'Louis C.K. Interview Pt. 1 11/3/11',
39 'upload_date': '20111104',
40 'timestamp': 1320405840,
43 'url': 'http://teamcoco.com/video/timothy-olyphant-drinking-whiskey',
47 'title': 'Timothy Olyphant Raises A Toast To “Justified”',
48 'description': 'md5:15501f23f020e793aeca761205e42c24',
49 'upload_date': '20150415',
50 'timestamp': 1429088400,
53 'skip_download': True, # m3u8 downloads
56 'url': 'http://teamcoco.com/video/full-episode-mon-6-1-joel-mchale-jake-tapper-and-musical-guest-courtney-barnett?playlist=x;eyJ0eXBlIjoidGFnIiwiaWQiOjl9',
60 'title': 'Full Episode - Mon. 6/1 - Joel McHale, Jake Tapper, And Musical Guest Courtney Barnett',
61 'description': 'Guests: Joel McHale, Jake Tapper, And Musical Guest Courtney Barnett',
64 'skip_download': True, # m3u8 downloads
66 'skip': 'This video is no longer available.',
68 'url': 'http://teamcoco.com/video/the-conan-audiencey-awards-for-04/25/18',
69 'only_matching': True,
71 'url': 'http://teamcoco.com/italy/conan-jordan-schlansky-hit-the-streets-of-florence',
72 'only_matching': True,
74 'url': 'http://teamcoco.com/haiti/conan-s-haitian-history-lesson',
75 'only_matching': True,
77 'url': 'http://teamcoco.com/israel/conan-hits-the-streets-beaches-of-tel-aviv',
78 'only_matching': True,
80 'url': 'https://conan25.teamcoco.com/video/ice-cube-kevin-hart-conan-share-lyft',
81 'only_matching': True,
96 turnerMediaAuthToken'''
98 def _graphql_call(self
, query_template
, object_type
, object_id
):
99 find_object
= 'find' + object_type
100 return self
._download
_json
(
101 'https://teamcoco.com/graphql', object_id
, data
=json
.dumps({
102 'query': query_template
% (find_object
, object_id
)
103 }).encode(), headers
={
104 'Content-Type': 'application/json',
105 })['data'][find_object
]
107 def _real_extract(self
, url
):
108 display_id
= self
._match
_id
(url
)
110 response
= self
._graphql
_call
('''{
122 ... on NotFoundSlug {
126 }''' % self
._RECORD
_TEMPL
, 'Slug', display_id
)
127 if response
.get('status'):
128 raise ExtractorError('This video is no longer available.', expected
=True)
130 child
= response
.get('child')
132 record
= self
._graphql
_call
('''{
138 }''' % self
._RECORD
_TEMPL
, 'Record', child
['id'])
140 record
= response
['record']
141 video_id
= record
['id']
145 'display_id': display_id
,
146 'title': record
['title'],
147 'thumbnail': record
.get('thumb', {}).get('preview'),
148 'description': record
.get('teaser'),
149 'duration': parse_duration(record
.get('duration')),
150 'timestamp': parse_iso8601(record
.get('publishOn')),
153 media_id
= record
.get('turnerMediaId')
155 self
._initialize
_geo
_bypass
({
158 info
.update(self
._extract
_ngtv
_info
(media_id
, {
159 'accessToken': record
['turnerMediaAuthToken'],
160 'accessTokenType': 'jws',
163 video_sources
= self
._download
_json
(
164 'https://teamcoco.com/_truman/d/' + video_id
,
165 video_id
)['meta']['src']
166 if isinstance(video_sources
, dict):
167 video_sources
= video_sources
.values()
170 get_quality
= qualities(['low', 'sd', 'hd', 'uhd'])
171 for src
in video_sources
:
172 if not isinstance(src
, dict):
174 src_url
= src
.get('src')
177 format_id
= src
.get('label')
178 ext
= determine_ext(src_url
, mimetype2ext(src
.get('type')))
179 if format_id
== 'hls' or ext
== 'm3u8':
180 # compat_urllib_parse.urljoin does not work here
181 if src_url
.startswith('/'):
182 src_url
= 'http://ht.cdn.turner.com/tbs/big/teamcoco' + src_url
183 formats
.extend(self
._extract
_m
3u8_formats
(
184 src_url
, video_id
, 'mp4', m3u8_id
=format_id
, fatal
=False))
186 if src_url
.startswith('/mp4:protected/'):
187 # TODO Correct extraction for these files
189 tbr
= int_or_none(self
._search
_regex
(
190 r
'(\d+)k\.mp4', src_url
, 'tbr', default
=None))
196 'format_id': format_id
,
197 'quality': get_quality(format_id
),
199 self
._sort
_formats
(formats
)
200 info
['formats'] = formats