]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/go90.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
16 class Go90IE(InfoExtractor
):
17 _VALID_URL
= r
'https?://(?:www\.)?go90\.com/videos/(?P<id>[0-9a-zA-Z]+)'
19 'url': 'https://www.go90.com/videos/84BUqjLpf9D',
20 'md5': 'efa7670dbbbf21a7b07b360652b24a32',
24 'title': 'Daily VICE - Inside The Utah Coalition Against Pornography Convention',
25 'description': 'VICE\'s Karley Sciortino meets with activists who discuss the state\'s strong anti-porn stance. Then, VICE Sports explains NFL contracts.',
26 'timestamp': 1491868800,
27 'upload_date': '20170411',
32 def _real_extract(self
, url
):
33 video_id
= self
._match
_id
(url
)
34 video_data
= self
._download
_json
(
35 'https://www.go90.com/api/view/items/' + video_id
,
37 'Content-Type': 'application/json; charset=utf-8',
38 }, data
=b
'{"client":"web","device_type":"pc"}')
39 if video_data
.get('requires_drm'):
40 raise ExtractorError('This video is DRM protected.', expected
=True)
41 main_video_asset
= video_data
['main_video_asset']
43 episode_number
= int_or_none(video_data
.get('episode_number'))
48 for metadata
in video_data
.get('__children', {}).get('Item', {}).values():
49 if metadata
.get('type') == 'show':
50 series
= metadata
.get('title')
51 elif metadata
.get('type') == 'season':
52 season
= metadata
.get('title')
53 season_id
= metadata
.get('id')
54 season_number
= int_or_none(metadata
.get('season_number'))
56 title
= episode
= video_data
.get('title') or series
57 if series
and series
!= title
:
58 title
= '%s - %s' % (series
, title
)
63 for asset
in video_data
.get('assets'):
64 if asset
.get('id') == main_video_asset
:
65 for source
in asset
.get('sources', []):
66 source_location
= source
.get('location')
67 if not source_location
:
69 source_type
= source
.get('type')
70 if source_type
== 'hls':
71 m3u8_formats
= self
._extract
_m
3u8_formats
(
72 source_location
, video_id
, 'mp4',
73 'm3u8_native', m3u8_id
='hls', fatal
=False)
74 for f
in m3u8_formats
:
75 mobj
= re
.search(r
'/hls-(\d+)-(\d+)K', f
['url'])
77 height
, tbr
= mobj
.groups()
78 height
= int_or_none(height
)
80 'height': f
.get('height') or height
,
81 'width': f
.get('width') or int_or_none(height
/ 9.0 * 16.0 if height
else None),
82 'tbr': f
.get('tbr') or int_or_none(tbr
),
84 formats
.extend(m3u8_formats
)
85 elif source_type
== 'dash':
86 formats
.extend(self
._extract
_mpd
_formats
(
87 source_location
, video_id
, mpd_id
='dash', fatal
=False))
90 'format_id': source
.get('name'),
91 'url': source_location
,
92 'width': int_or_none(source
.get('width')),
93 'height': int_or_none(source
.get('height')),
94 'tbr': int_or_none(source
.get('bitrate')),
97 for caption
in asset
.get('caption_metadata', []):
98 caption_url
= caption
.get('source_url')
101 subtitles
.setdefault(caption
.get('language', 'en'), []).append({
103 'ext': determine_ext(caption_url
, 'vtt'),
105 elif asset
.get('type') == 'image':
106 asset_location
= asset
.get('location')
107 if not asset_location
:
110 'url': asset_location
,
111 'width': int_or_none(asset
.get('width')),
112 'height': int_or_none(asset
.get('height')),
114 self
._sort
_formats
(formats
)
120 'thumbnails': thumbnails
,
121 'description': video_data
.get('short_description'),
122 'like_count': int_or_none(video_data
.get('like_count')),
123 'timestamp': parse_iso8601(video_data
.get('released_at')),
127 'season_id': season_id
,
128 'season_number': season_number
,
129 'episode_number': episode_number
,
130 'subtitles': subtitles
,
131 'age_limit': parse_age_limit(video_data
.get('rating')),