]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/vvvvid.py
4 from .common
import InfoExtractor
5 from .youtube
import YoutubeIE
13 class VVVVIDIE(InfoExtractor
):
14 _VALID_URL_BASE
= r
'https?://(?:www\.)?vvvvid\.it/(?:#!)?(?:show|anime|film|series)/'
15 _VALID_URL
= r
'%s(?P<show_id>\d+)/[^/]+/(?P<season_id>\d+)/(?P<id>[0-9]+)' % _VALID_URL_BASE
17 # video_type == 'video/vvvvid'
18 'url': 'https://www.vvvvid.it/show/498/the-power-of-computing/518/505692/playstation-vr-cambiera-il-nostro-modo-di-giocare',
22 'title': 'Playstation VR cambierà il nostro modo di giocare',
24 'series': 'The Power of Computing',
26 'episode': 'Playstation VR cambierà il nostro modo di giocare',
27 'episode_number': None,
32 'thumbnail': 'https://static.vvvvid.it/img/zoomin/28CA2409-E663-34F0-2B02E72356556EA3_500k.jpg',
35 'skip_download': True,
38 # video_type == 'video/rcs'
39 'url': 'https://www.vvvvid.it/#!show/376/death-note-live-action/377/482493/episodio-01',
43 'title': 'Episodio 01',
46 'skip_download': True,
48 'skip': 'Every video/rcs is not working even in real website',
50 # video_type == 'video/youtube'
51 'url': 'https://www.vvvvid.it/show/404/one-punch-man/406/486683/trailer',
52 'md5': '33e0edfba720ad73a8782157fdebc648',
57 'upload_date': '20150906',
58 'description': 'md5:a5e802558d35247fee285875328c0b80',
59 'uploader_id': '@EMOTIONLabelChannel',
60 'uploader': 'EMOTION Label Channel',
61 'episode_number': None,
69 'channel': 'EMOTION Label Channel',
70 'channel_follower_count': int,
71 'channel_id': 'UCQ5URCSs1f5Cz9rh-cDGxNQ',
72 'channel_url': 'https://www.youtube.com/channel/UCQ5URCSs1f5Cz9rh-cDGxNQ',
77 'live_status': 'not_live',
78 'playable_in_embed': True,
80 'series': 'One-Punch Man',
82 'uploader_url': 'https://www.youtube.com/@EMOTIONLabelChannel',
83 'thumbnail': 'https://i.ytimg.com/vi/RzmFKUDOUgw/maxresdefault.jpg',
86 'skip_download': True,
89 # video_type == 'video/dash'
90 'url': 'https://www.vvvvid.it/show/844/le-bizzarre-avventure-di-jojo-vento-aureo/938/527551/golden-wind',
94 'title': 'Golden Wind',
96 'series': 'Le bizzarre avventure di Jojo - Vento Aureo',
98 'episode': 'Golden Wind',
100 'episode_id': '9089',
104 'thumbnail': 'https://static.vvvvid.it/img/thumbs/Dynit/Jojo/Jojo_S05Ep01-t.jpg',
105 'season': 'Season 5',
109 'skip_download': True,
113 'url': 'https://www.vvvvid.it/show/434/perche-dovrei-guardarlo-di-dario-moccia/437/489048',
114 'only_matching': True
118 @functools.cached_property
121 **self
.geo_verification_headers(),
122 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.50 Safari/537.37',
125 def _real_initialize(self
):
126 self
._conn
_id
= self
._download
_json
(
127 'https://www.vvvvid.it/user/login',
128 None, headers
=self
._headers
)['data']['conn_id']
130 def _download_info(self
, show_id
, path
, video_id
, fatal
=True, query
=None):
132 'conn_id': self
._conn
_id
,
136 response
= self
._download
_json
(
137 'https://www.vvvvid.it/vvvvid/ondemand/%s/%s' % (show_id
, path
),
138 video_id
, headers
=self
._headers
, query
=q
, fatal
=fatal
)
139 if not (response
or fatal
):
141 if response
.get('result') == 'error':
142 raise ExtractorError('%s said: %s' % (
143 self
.IE_NAME
, response
['message']), expected
=True)
144 return response
['data']
146 def _extract_common_video_info(self
, video_data
):
148 'thumbnail': video_data
.get('thumbnail'),
149 'episode_id': str_or_none(video_data
.get('id')),
152 def _real_extract(self
, url
):
153 show_id
, season_id
, video_id
= self
._match
_valid
_url
(url
).groups()
155 response
= self
._download
_info
(
156 show_id
, 'season/%s' % season_id
,
157 video_id
, query
={'video_id': video_id}
)
160 video_data
= list(filter(
161 lambda episode
: episode
.get('video_id') == vid
, response
))[0]
162 title
= video_data
['title']
165 # vvvvid embed_info decryption algorithm is reverse engineered from function $ds(h) at vvvvid.js
167 g
= "MNOPIJKL89+/4567UVWXQRSTEFGHABCDcdefYZabstuvopqr0123wxyzklmnghij"
174 while ((not b
) and o
< m_len
):
183 k
= (m
[o
- 1] << 4) & 255
187 j
= (m
[o
- 1] << 6) & 255
208 for e
in range(c_len
* 2 - 1, -1, -1):
209 a
= c
[e
% c_len
] ^ c
[(e
+ 1) % c_len
]
221 def metadata_from_url(r_url
):
222 if not info
and r_url
:
223 mobj
= re
.search(r
'_(?:S(\d+))?Ep(\d+)', r_url
)
225 info
['episode_number'] = int(mobj
.group(2))
226 season_number
= mobj
.group(1)
228 info
['season_number'] = int(season_number
)
230 video_type
= video_data
.get('video_type')
232 for quality
in ('', '_sd'):
233 embed_code
= video_data
.get('embed_info' + quality
)
236 embed_code
= ds(embed_code
)
237 if video_type
== 'video/kenc':
238 embed_code
= re
.sub(r
'https?(://[^/]+)/z/', r
'https\1/i/', embed_code
).replace('/manifest.f4m', '/master.m3u8')
239 kenc
= self
._download
_json
(
240 'https://www.vvvvid.it/kenc', video_id
, query
={
242 'conn_id': self
._conn
_id
,
244 }, fatal
=False) or {}
245 kenc_message
= kenc
.get('message')
247 embed_code
+= '?' + ds(kenc_message
)
248 formats
.extend(self
._extract
_m
3u8_formats
(
249 embed_code
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False))
250 elif video_type
== 'video/rcs':
251 formats
.extend(self
._extract
_akamai
_formats
(embed_code
, video_id
))
252 elif video_type
== 'video/youtube':
254 '_type': 'url_transparent',
255 'ie_key': YoutubeIE
.ie_key(),
260 elif video_type
== 'video/dash':
261 formats
.extend(self
._extract
_m
3u8_formats
(
262 embed_code
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False))
264 formats
.extend(self
._extract
_wowza
_formats
(
265 'http://sb.top-ix.org/videomg/_definst_/mp4:%s/playlist.m3u8' % embed_code
, video_id
, skip_protocols
=['f4m']))
266 metadata_from_url(embed_code
)
269 info
['formats'] = formats
271 metadata_from_url(video_data
.get('thumbnail'))
272 info
.update(self
._extract
_common
_video
_info
(video_data
))
276 'duration': int_or_none(video_data
.get('length')),
277 'series': video_data
.get('show_title'),
278 'season_id': season_id
,
280 'view_count': int_or_none(video_data
.get('views')),
281 'like_count': int_or_none(video_data
.get('video_likes')),
282 'repost_count': int_or_none(video_data
.get('video_shares')),
287 class VVVVIDShowIE(VVVVIDIE
): # XXX: Do not subclass from concrete IE
288 _VALID_URL
= r
'(?P<base_url>%s(?P<id>\d+)(?:/(?P<show_title>[^/?&#]+))?)/?(?:[?#&]|$)' % VVVVIDIE
._VALID
_URL
_BASE
290 'url': 'https://www.vvvvid.it/show/156/psyco-pass',
293 'title': 'Psycho-Pass',
294 'description': 'md5:94d572c0bd85894b193b8aebc9a3a806',
296 'playlist_count': 46,
298 'url': 'https://www.vvvvid.it/show/156',
299 'only_matching': True,
302 def _real_extract(self
, url
):
303 base_url
, show_id
, show_title
= self
._match
_valid
_url
(url
).groups()
305 seasons
= self
._download
_info
(
306 show_id
, 'seasons/', show_title
)
308 show_info
= self
._download
_info
(
309 show_id
, 'info/', show_title
, fatal
=False)
315 for season
in (seasons
or []):
316 episodes
= season
.get('episodes') or []
317 playlist_title
= season
.get('name') or show_info
.get('title')
318 for episode
in episodes
:
319 if episode
.get('playable') is False:
321 season_id
= str_or_none(episode
.get('season_id'))
322 video_id
= str_or_none(episode
.get('video_id'))
323 if not (season_id
and video_id
):
325 info
= self
._extract
_common
_video
_info
(episode
)
327 '_type': 'url_transparent',
328 'ie_key': VVVVIDIE
.ie_key(),
329 'url': '/'.join([base_url
, season_id
, video_id
]),
330 'title': episode
.get('title'),
331 'description': episode
.get('description'),
332 'season_id': season_id
,
333 'playlist_title': playlist_title
,
337 return self
.playlist_result(
338 entries
, show_id
, show_info
.get('title'), show_info
.get('description'))