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
= rf
'{_VALID_URL_BASE}(?P<show_id>\d+)/[^/]+/(?P<season_id>\d+)/(?P<id>[0-9]+)'
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',
31 'thumbnail': 'https://static.vvvvid.it/img/zoomin/28CA2409-E663-34F0-2B02E72356556EA3_500k.jpg',
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',
42 'title': 'Episodio 01',
45 'skip_download': True,
47 'skip': 'Every video/rcs is not working even in real website',
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': '@EMOTIONLabelChannel',
59 'uploader': 'EMOTION Label Channel',
67 'channel': 'EMOTION Label Channel',
68 'channel_follower_count': int,
69 'channel_id': 'UCQ5URCSs1f5Cz9rh-cDGxNQ',
70 'channel_url': 'https://www.youtube.com/channel/UCQ5URCSs1f5Cz9rh-cDGxNQ',
75 'live_status': 'not_live',
76 'playable_in_embed': True,
78 'series': 'One-Punch Man',
80 'uploader_url': 'https://www.youtube.com/@EMOTIONLabelChannel',
81 'thumbnail': 'https://i.ytimg.com/vi/RzmFKUDOUgw/maxresdefault.jpg',
84 'skip_download': True,
87 # video_type == 'video/dash'
88 'url': 'https://www.vvvvid.it/show/844/le-bizzarre-avventure-di-jojo-vento-aureo/938/527551/golden-wind',
92 'title': 'Golden Wind',
94 'series': 'Le bizzarre avventure di Jojo - Vento Aureo',
96 'episode': 'Golden Wind',
102 'thumbnail': 'https://static.vvvvid.it/img/thumbs/Dynit/Jojo/Jojo_S05Ep01-t.jpg',
103 'season': 'Season 5',
107 'skip_download': True,
111 'url': 'https://www.vvvvid.it/show/434/perche-dovrei-guardarlo-di-dario-moccia/437/489048',
112 'only_matching': True,
116 @functools.cached_property
119 **self
.geo_verification_headers(),
120 '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',
123 def _real_initialize(self
):
124 self
._conn
_id
= self
._download
_json
(
125 'https://www.vvvvid.it/user/login',
126 None, headers
=self
._headers
)['data']['conn_id']
128 def _download_info(self
, show_id
, path
, video_id
, fatal
=True, query
=None):
130 'conn_id': self
._conn
_id
,
134 response
= self
._download
_json
(
135 f
'https://www.vvvvid.it/vvvvid/ondemand/{show_id}/{path}',
136 video_id
, headers
=self
._headers
, query
=q
, fatal
=fatal
)
137 if not (response
or fatal
):
139 if response
.get('result') == 'error':
140 raise ExtractorError('{} said: {}'.format(
141 self
.IE_NAME
, response
['message']), expected
=True)
142 return response
['data']
144 def _extract_common_video_info(self
, video_data
):
146 'thumbnail': video_data
.get('thumbnail'),
147 'episode_id': str_or_none(video_data
.get('id')),
150 def _real_extract(self
, url
):
151 show_id
, season_id
, video_id
= self
._match
_valid
_url
(url
).groups()
153 response
= self
._download
_info
(
154 show_id
, f
'season/{season_id}',
155 video_id
, query
={'video_id': video_id
})
158 video_data
= next(filter(
159 lambda episode
: episode
.get('video_id') == vid
, response
))
160 title
= video_data
['title']
163 # vvvvid embed_info decryption algorithm is reverse engineered from function $ds(h) at vvvvid.js
165 g
= 'MNOPIJKL89+/4567UVWXQRSTEFGHABCDcdefYZabstuvopqr0123wxyzklmnghij'
172 while ((not b
) and o
< m_len
):
181 k
= (m
[o
- 1] << 4) & 255
185 j
= (m
[o
- 1] << 6) & 255
206 for e
in range(c_len
* 2 - 1, -1, -1):
207 a
= c
[e
% c_len
] ^ c
[(e
+ 1) % c_len
]
219 def metadata_from_url(r_url
):
220 if not info
and r_url
:
221 mobj
= re
.search(r
'_(?:S(\d+))?Ep(\d+)', r_url
)
223 info
['episode_number'] = int(mobj
.group(2))
224 season_number
= mobj
.group(1)
226 info
['season_number'] = int(season_number
)
228 video_type
= video_data
.get('video_type')
230 for quality
in ('', '_sd'):
231 embed_code
= video_data
.get('embed_info' + quality
)
234 embed_code
= ds(embed_code
)
235 if video_type
== 'video/kenc':
236 embed_code
= re
.sub(r
'https?(://[^/]+)/z/', r
'https\1/i/', embed_code
).replace('/manifest.f4m', '/master.m3u8')
237 kenc
= self
._download
_json
(
238 'https://www.vvvvid.it/kenc', video_id
, query
={
240 'conn_id': self
._conn
_id
,
242 }, fatal
=False) or {}
243 kenc_message
= kenc
.get('message')
245 embed_code
+= '?' + ds(kenc_message
)
246 formats
.extend(self
._extract
_m
3u8_formats
(
247 embed_code
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False))
248 elif video_type
== 'video/rcs':
249 formats
.extend(self
._extract
_akamai
_formats
(embed_code
, video_id
))
250 elif video_type
== 'video/youtube':
252 '_type': 'url_transparent',
253 'ie_key': YoutubeIE
.ie_key(),
258 elif video_type
== 'video/dash':
259 formats
.extend(self
._extract
_m
3u8_formats
(
260 embed_code
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False))
262 formats
.extend(self
._extract
_wowza
_formats
(
263 f
'http://sb.top-ix.org/videomg/_definst_/mp4:{embed_code}/playlist.m3u8', video_id
, skip_protocols
=['f4m']))
264 metadata_from_url(embed_code
)
267 info
['formats'] = formats
269 metadata_from_url(video_data
.get('thumbnail'))
270 info
.update(self
._extract
_common
_video
_info
(video_data
))
274 'duration': int_or_none(video_data
.get('length')),
275 'series': video_data
.get('show_title'),
276 'season_id': season_id
,
278 'view_count': int_or_none(video_data
.get('views')),
279 'like_count': int_or_none(video_data
.get('video_likes')),
280 'repost_count': int_or_none(video_data
.get('video_shares')),
285 class VVVVIDShowIE(VVVVIDIE
): # XXX: Do not subclass from concrete IE
286 _VALID_URL
= rf
'(?P<base_url>{VVVVIDIE._VALID_URL_BASE}(?P<id>\d+)(?:/(?P<show_title>[^/?&#]+))?)/?(?:[?#&]|$)'
288 'url': 'https://www.vvvvid.it/show/156/psyco-pass',
291 'title': 'Psycho-Pass',
292 'description': 'md5:94d572c0bd85894b193b8aebc9a3a806',
294 'playlist_count': 46,
296 'url': 'https://www.vvvvid.it/show/156',
297 'only_matching': True,
300 def _real_extract(self
, url
):
301 base_url
, show_id
, show_title
= self
._match
_valid
_url
(url
).groups()
303 seasons
= self
._download
_info
(
304 show_id
, 'seasons/', show_title
)
306 show_info
= self
._download
_info
(
307 show_id
, 'info/', show_title
, fatal
=False)
313 for season
in (seasons
or []):
314 episodes
= season
.get('episodes') or []
315 playlist_title
= season
.get('name') or show_info
.get('title')
316 for episode
in episodes
:
317 if episode
.get('playable') is False:
319 season_id
= str_or_none(episode
.get('season_id'))
320 video_id
= str_or_none(episode
.get('video_id'))
321 if not (season_id
and video_id
):
323 info
= self
._extract
_common
_video
_info
(episode
)
325 '_type': 'url_transparent',
326 'ie_key': VVVVIDIE
.ie_key(),
327 'url': '/'.join([base_url
, season_id
, video_id
]),
328 'title': episode
.get('title'),
329 'description': episode
.get('description'),
330 'season_id': season_id
,
331 'playlist_title': playlist_title
,
335 return self
.playlist_result(
336 entries
, show_id
, show_info
.get('title'), show_info
.get('description'))