]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/vvvvid.py
3 from .common
import InfoExtractor
4 from .youtube
import YoutubeIE
12 class VVVVIDIE(InfoExtractor
):
13 _VALID_URL_BASE
= r
'https?://(?:www\.)?vvvvid\.it/(?:#!)?(?:show|anime|film|series)/'
14 _VALID_URL
= r
'%s(?P<show_id>\d+)/[^/]+/(?P<season_id>\d+)/(?P<id>[0-9]+)' % _VALID_URL_BASE
16 # video_type == 'video/vvvvid'
17 'url': 'https://www.vvvvid.it/#!show/434/perche-dovrei-guardarlo-di-dario-moccia/437/489048/ping-pong',
18 'md5': 'b8d3cecc2e981adc3835adf07f6df91b',
24 'series': '"Perché dovrei guardarlo?" di Dario Moccia',
26 'episode': 'Ping Pong',
34 'skip_download': True,
37 # video_type == 'video/rcs'
38 'url': 'https://www.vvvvid.it/#!show/376/death-note-live-action/377/482493/episodio-01',
39 'md5': '33e0edfba720ad73a8782157fdebc648',
43 'title': 'Episodio 01',
46 'skip_download': True,
49 # video_type == 'video/youtube'
50 'url': 'https://www.vvvvid.it/show/404/one-punch-man/406/486683/trailer',
51 'md5': '33e0edfba720ad73a8782157fdebc648',
56 'upload_date': '20150906',
57 'description': 'md5:a5e802558d35247fee285875328c0b80',
58 'uploader_id': 'BandaiVisual',
59 'uploader': 'BANDAI NAMCO Arts Channel',
62 'skip_download': True,
65 # video_type == 'video/dash'
66 'url': 'https://www.vvvvid.it/show/683/made-in-abyss/1542/693786/nanachi',
73 'skip_download': True,
77 'url': 'https://www.vvvvid.it/show/434/perche-dovrei-guardarlo-di-dario-moccia/437/489048',
82 def _real_initialize(self
):
83 self
._conn
_id
= self
._download
_json
(
84 'https://www.vvvvid.it/user/login',
85 None, headers
=self
.geo_verification_headers())['data']['conn_id']
87 def _download_info(self
, show_id
, path
, video_id
, fatal
=True, query
=None):
89 'conn_id': self
._conn
_id
,
93 response
= self
._download
_json
(
94 'https://www.vvvvid.it/vvvvid/ondemand/%s/%s' % (show_id
, path
),
95 video_id
, headers
=self
.geo_verification_headers(), query
=q
, fatal
=fatal
)
96 if not (response
or fatal
):
98 if response
.get('result') == 'error':
99 raise ExtractorError('%s said: %s' % (
100 self
.IE_NAME
, response
['message']), expected
=True)
101 return response
['data']
103 def _extract_common_video_info(self
, video_data
):
105 'thumbnail': video_data
.get('thumbnail'),
106 'episode_id': str_or_none(video_data
.get('id')),
109 def _real_extract(self
, url
):
110 show_id
, season_id
, video_id
= self
._match
_valid
_url
(url
).groups()
112 response
= self
._download
_info
(
113 show_id
, 'season/%s' % season_id
,
114 video_id
, query
={'video_id': video_id}
)
117 video_data
= list(filter(
118 lambda episode
: episode
.get('video_id') == vid
, response
))[0]
119 title
= video_data
['title']
122 # vvvvid embed_info decryption algorithm is reverse engineered from function $ds(h) at vvvvid.js
124 g
= "MNOPIJKL89+/4567UVWXQRSTEFGHABCDcdefYZabstuvopqr0123wxyzklmnghij"
131 while ((not b
) and o
< m_len
):
140 k
= (m
[o
- 1] << 4) & 255
144 j
= (m
[o
- 1] << 6) & 255
165 for e
in range(c_len
* 2 - 1, -1, -1):
166 a
= c
[e
% c_len
] ^ c
[(e
+ 1) % c_len
]
178 def metadata_from_url(r_url
):
179 if not info
and r_url
:
180 mobj
= re
.search(r
'_(?:S(\d+))?Ep(\d+)', r_url
)
182 info
['episode_number'] = int(mobj
.group(2))
183 season_number
= mobj
.group(1)
185 info
['season_number'] = int(season_number
)
187 video_type
= video_data
.get('video_type')
189 for quality
in ('', '_sd'):
190 embed_code
= video_data
.get('embed_info' + quality
)
193 embed_code
= ds(embed_code
)
194 if video_type
== 'video/kenc':
195 embed_code
= re
.sub(r
'https?(://[^/]+)/z/', r
'https\1/i/', embed_code
).replace('/manifest.f4m', '/master.m3u8')
196 kenc
= self
._download
_json
(
197 'https://www.vvvvid.it/kenc', video_id
, query
={
199 'conn_id': self
._conn
_id
,
201 }, fatal
=False) or {}
202 kenc_message
= kenc
.get('message')
204 embed_code
+= '?' + ds(kenc_message
)
205 formats
.extend(self
._extract
_m
3u8_formats
(
206 embed_code
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False))
207 elif video_type
== 'video/rcs':
208 formats
.extend(self
._extract
_akamai
_formats
(embed_code
, video_id
))
209 elif video_type
== 'video/youtube':
211 '_type': 'url_transparent',
212 'ie_key': YoutubeIE
.ie_key(),
217 elif video_type
== 'video/dash':
218 formats
.extend(self
._extract
_m
3u8_formats
(
219 embed_code
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False))
221 formats
.extend(self
._extract
_wowza
_formats
(
222 'http://sb.top-ix.org/videomg/_definst_/mp4:%s/playlist.m3u8' % embed_code
, video_id
))
223 metadata_from_url(embed_code
)
226 self
._sort
_formats
(formats
)
227 info
['formats'] = formats
229 metadata_from_url(video_data
.get('thumbnail'))
230 info
.update(self
._extract
_common
_video
_info
(video_data
))
234 'duration': int_or_none(video_data
.get('length')),
235 'series': video_data
.get('show_title'),
236 'season_id': season_id
,
238 'view_count': int_or_none(video_data
.get('views')),
239 'like_count': int_or_none(video_data
.get('video_likes')),
240 'repost_count': int_or_none(video_data
.get('video_shares')),
245 class VVVVIDShowIE(VVVVIDIE
):
246 _VALID_URL
= r
'(?P<base_url>%s(?P<id>\d+)(?:/(?P<show_title>[^/?&#]+))?)/?(?:[?#&]|$)' % VVVVIDIE
._VALID
_URL
_BASE
248 'url': 'https://www.vvvvid.it/show/156/psyco-pass',
251 'title': 'Psycho-Pass',
252 'description': 'md5:94d572c0bd85894b193b8aebc9a3a806',
254 'playlist_count': 46,
256 'url': 'https://www.vvvvid.it/show/156',
257 'only_matching': True,
260 def _real_extract(self
, url
):
261 base_url
, show_id
, show_title
= self
._match
_valid
_url
(url
).groups()
263 seasons
= self
._download
_info
(
264 show_id
, 'seasons/', show_title
)
266 show_info
= self
._download
_info
(
267 show_id
, 'info/', show_title
, fatal
=False)
273 for season
in (seasons
or []):
274 episodes
= season
.get('episodes') or []
275 playlist_title
= season
.get('name') or show_info
.get('title')
276 for episode
in episodes
:
277 if episode
.get('playable') is False:
279 season_id
= str_or_none(episode
.get('season_id'))
280 video_id
= str_or_none(episode
.get('video_id'))
281 if not (season_id
and video_id
):
283 info
= self
._extract
_common
_video
_info
(episode
)
285 '_type': 'url_transparent',
286 'ie_key': VVVVIDIE
.ie_key(),
287 'url': '/'.join([base_url
, season_id
, video_id
]),
288 'title': episode
.get('title'),
289 'description': episode
.get('description'),
290 'season_id': season_id
,
291 'playlist_title': playlist_title
,
295 return self
.playlist_result(
296 entries
, show_id
, show_info
.get('title'), show_info
.get('description'))