]>
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 'url': 'https://www.vvvvid.it/show/434/perche-dovrei-guardarlo-di-dario-moccia/437/489048',
70 def _real_initialize(self
):
71 self
._conn
_id
= self
._download
_json
(
72 'https://www.vvvvid.it/user/login',
73 None, headers
=self
.geo_verification_headers())['data']['conn_id']
75 def _download_info(self
, show_id
, path
, video_id
, fatal
=True, query
=None):
77 'conn_id': self
._conn
_id
,
81 response
= self
._download
_json
(
82 'https://www.vvvvid.it/vvvvid/ondemand/%s/%s' % (show_id
, path
),
83 video_id
, headers
=self
.geo_verification_headers(), query
=q
, fatal
=fatal
)
84 if not (response
or fatal
):
86 if response
.get('result') == 'error':
87 raise ExtractorError('%s said: %s' % (
88 self
.IE_NAME
, response
['message']), expected
=True)
89 return response
['data']
91 def _extract_common_video_info(self
, video_data
):
93 'thumbnail': video_data
.get('thumbnail'),
94 'episode_id': str_or_none(video_data
.get('id')),
97 def _real_extract(self
, url
):
98 show_id
, season_id
, video_id
= self
._match
_valid
_url
(url
).groups()
100 response
= self
._download
_info
(
101 show_id
, 'season/%s' % season_id
,
102 video_id
, query
={'video_id': video_id}
)
105 video_data
= list(filter(
106 lambda episode
: episode
.get('video_id') == vid
, response
))[0]
107 title
= video_data
['title']
110 # vvvvid embed_info decryption algorithm is reverse engineered from function $ds(h) at vvvvid.js
112 g
= "MNOPIJKL89+/4567UVWXQRSTEFGHABCDcdefYZabstuvopqr0123wxyzklmnghij"
119 while ((not b
) and o
< m_len
):
128 k
= (m
[o
- 1] << 4) & 255
132 j
= (m
[o
- 1] << 6) & 255
153 for e
in range(c_len
* 2 - 1, -1, -1):
154 a
= c
[e
% c_len
] ^ c
[(e
+ 1) % c_len
]
166 def metadata_from_url(r_url
):
167 if not info
and r_url
:
168 mobj
= re
.search(r
'_(?:S(\d+))?Ep(\d+)', r_url
)
170 info
['episode_number'] = int(mobj
.group(2))
171 season_number
= mobj
.group(1)
173 info
['season_number'] = int(season_number
)
175 video_type
= video_data
.get('video_type')
177 for quality
in ('', '_sd'):
178 embed_code
= video_data
.get('embed_info' + quality
)
181 embed_code
= ds(embed_code
)
182 if video_type
== 'video/kenc':
183 embed_code
= re
.sub(r
'https?(://[^/]+)/z/', r
'https\1/i/', embed_code
).replace('/manifest.f4m', '/master.m3u8')
184 kenc
= self
._download
_json
(
185 'https://www.vvvvid.it/kenc', video_id
, query
={
187 'conn_id': self
._conn
_id
,
189 }, fatal
=False) or {}
190 kenc_message
= kenc
.get('message')
192 embed_code
+= '?' + ds(kenc_message
)
193 formats
.extend(self
._extract
_m
3u8_formats
(
194 embed_code
, video_id
, 'mp4', m3u8_id
='hls', fatal
=False))
195 elif video_type
== 'video/rcs':
196 formats
.extend(self
._extract
_akamai
_formats
(embed_code
, video_id
))
197 elif video_type
== 'video/youtube':
199 '_type': 'url_transparent',
200 'ie_key': YoutubeIE
.ie_key(),
206 formats
.extend(self
._extract
_wowza
_formats
(
207 'http://sb.top-ix.org/videomg/_definst_/mp4:%s/playlist.m3u8' % embed_code
, video_id
))
208 metadata_from_url(embed_code
)
211 self
._sort
_formats
(formats
)
212 info
['formats'] = formats
214 metadata_from_url(video_data
.get('thumbnail'))
215 info
.update(self
._extract
_common
_video
_info
(video_data
))
219 'duration': int_or_none(video_data
.get('length')),
220 'series': video_data
.get('show_title'),
221 'season_id': season_id
,
223 'view_count': int_or_none(video_data
.get('views')),
224 'like_count': int_or_none(video_data
.get('video_likes')),
225 'repost_count': int_or_none(video_data
.get('video_shares')),
230 class VVVVIDShowIE(VVVVIDIE
):
231 _VALID_URL
= r
'(?P<base_url>%s(?P<id>\d+)(?:/(?P<show_title>[^/?&#]+))?)/?(?:[?#&]|$)' % VVVVIDIE
._VALID
_URL
_BASE
233 'url': 'https://www.vvvvid.it/show/156/psyco-pass',
236 'title': 'Psycho-Pass',
237 'description': 'md5:94d572c0bd85894b193b8aebc9a3a806',
239 'playlist_count': 46,
241 'url': 'https://www.vvvvid.it/show/156',
242 'only_matching': True,
245 def _real_extract(self
, url
):
246 base_url
, show_id
, show_title
= self
._match
_valid
_url
(url
).groups()
248 seasons
= self
._download
_info
(
249 show_id
, 'seasons/', show_title
)
251 show_info
= self
._download
_info
(
252 show_id
, 'info/', show_title
, fatal
=False)
258 for season
in (seasons
or []):
259 episodes
= season
.get('episodes') or []
260 playlist_title
= season
.get('name') or show_info
.get('title')
261 for episode
in episodes
:
262 if episode
.get('playable') is False:
264 season_id
= str_or_none(episode
.get('season_id'))
265 video_id
= str_or_none(episode
.get('video_id'))
266 if not (season_id
and video_id
):
268 info
= self
._extract
_common
_video
_info
(episode
)
270 '_type': 'url_transparent',
271 'ie_key': VVVVIDIE
.ie_key(),
272 'url': '/'.join([base_url
, season_id
, video_id
]),
273 'title': episode
.get('title'),
274 'description': episode
.get('description'),
275 'season_id': season_id
,
276 'playlist_title': playlist_title
,
280 return self
.playlist_result(
281 entries
, show_id
, show_info
.get('title'), show_info
.get('description'))