]>
jfr.im git - yt-dlp.git/blob - youtube_dlc/extractor/zype.py
2e2e97a0c4454971dab30136518ca26e903b9470
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_HTTPError
17 class ZypeIE(InfoExtractor
):
18 _ID_RE
= r
'[\da-fA-F]+'
19 _COMMON_RE
= r
'//player\.zype\.com/embed/%s\.(?:js|json|html)\?.*?(?:access_token|(?:ap[ip]|player)_key)='
20 _VALID_URL
= r
'https?:%s[^&]+' % (_COMMON_RE
% ('(?P<id>%s)' % _ID_RE
))
22 'url': 'https://player.zype.com/embed/5b400b834b32992a310622b9.js?api_key=jZ9GUhRmxcPvX7M3SlfejB6Hle9jyHTdk2jVxG7wOHPLODgncEKVdPYBhuz9iWXQ&autoplay=false&controls=true&da=false',
23 'md5': 'eaee31d474c76a955bdaba02a505c595',
25 'id': '5b400b834b32992a310622b9',
27 'title': 'Smoky Barbecue Favorites',
28 'thumbnail': r
're:^https?://.*\.jpe?g',
29 'description': 'md5:5ff01e76316bd8d46508af26dc86023b',
30 'timestamp': 1504915200,
31 'upload_date': '20170909',
36 def _extract_urls(webpage
):
39 for mobj
in re
.finditer(
40 r
'<script[^>]+\bsrc=(["\'])(?P
<url
>(?
:https?
:)?
%s.+?
)\
1' % (ZypeIE._COMMON_RE % ZypeIE._ID_RE),
43 def _real_extract(self, url):
44 video_id = self._match_id(url)
47 response = self._download_json(re.sub(
48 r'\
.(?
:js|html
)\?', '.json?
', url), video_id)['response
']
49 except ExtractorError as e:
50 if isinstance(e.cause, compat_HTTPError) and e.cause.code in (400, 401, 403):
51 raise ExtractorError(self._parse_json(
52 e.cause.read().decode(), video_id)['message
'], expected=True)
55 body = response['body
']
56 video = response['video
']
57 title = video['title
']
59 if isinstance(body, dict):
61 for output in body.get('outputs
', []):
62 output_url = output.get('url
')
65 name = output.get('name
')
67 formats = self._extract_m3u8_formats(
68 output_url, video_id, 'mp4
',
69 'm3u8_native
', m3u8_id='hls
', fatal=False)
73 'tbr
': int_or_none(output.get('bitrate
')),
76 if name in ('m4a
', 'mp3
'):
80 'height
': int_or_none(output.get('height
')),
81 'width
': int_or_none(output.get('width
')),
84 text_tracks = body.get('subtitles
') or []
86 m3u8_url = self._search_regex(
87 r'(["\'])(?P<url>(?:(?!\1).)+\.m3u8(?:(?!\1).)*)\1',
88 body, 'm3u8 url', group='url')
89 formats = self._extract_m3u8_formats(
90 m3u8_url, video_id, 'mp4', 'm3u8_native', m3u8_id='hls')
91 text_tracks = self._search_regex(
92 r'textTracks\s*:\s*(\[[^]]+\])',
93 body, 'text tracks', default=None)
95 text_tracks = self._parse_json(
96 text_tracks, video_id, js_to_json, False)
97 self._sort_formats(formats)
101 for text_track in text_tracks:
102 tt_url = dict_get(text_track, ('file', 'src'))
105 subtitles.setdefault(text_track.get('label') or 'English', []).append({
110 for thumbnail in video.get('thumbnails', []):
111 thumbnail_url = thumbnail.get('url')
112 if not thumbnail_url:
115 'url': thumbnail_url,
116 'width': int_or_none(thumbnail.get('width')),
117 'height': int_or_none(thumbnail.get('height')),
122 'display_id': video.get('friendly_title'),
124 'thumbnails': thumbnails,
125 'description': dict_get(video, ('description', 'ott_description', 'short_description')),
126 'timestamp': parse_iso8601(video.get('published_at')),
127 'duration': int_or_none(video.get('duration')),
128 'view_count': int_or_none(video.get('request_count')),
129 'average_rating': int_or_none(video.get('rating')),
130 'season_number': int_or_none(video.get('season')),
131 'episode_number': int_or_none(video.get('episode')),
133 'subtitles': subtitles,