]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/vvvvid.py
778ce8b765ce30db1ed7747f3af9a41491ff4e8e
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from .youtube
import YoutubeIE
15 class VVVVIDIE(InfoExtractor
):
16 _VALID_URL_BASE
= r
'https?://(?:www\.)?vvvvid\.it/(?:#!)?(?:show|anime|film|series)/'
17 _VALID_URL
= r
'%s(?P<show_id>\d+)/[^/]+/(?P<season_id>\d+)/(?P<id>[0-9]+)' % _VALID_URL_BASE
19 # video_type == 'video/vvvvid'
20 'url': 'https://www.vvvvid.it/#!show/434/perche-dovrei-guardarlo-di-dario-moccia/437/489048/ping-pong',
21 'md5': 'b8d3cecc2e981adc3835adf07f6df91b',
27 'series': '"Perché dovrei guardarlo?" di Dario Moccia',
29 'episode': 'Ping Pong',
37 'skip_download': True,
40 # video_type == 'video/rcs'
41 'url': 'https://www.vvvvid.it/#!show/376/death-note-live-action/377/482493/episodio-01',
42 'md5': '33e0edfba720ad73a8782157fdebc648',
46 'title': 'Episodio 01',
49 'skip_download': True,
52 # video_type == 'video/youtube'
53 'url': 'https://www.vvvvid.it/show/404/one-punch-man/406/486683/trailer',
54 'md5': '33e0edfba720ad73a8782157fdebc648',
59 'upload_date': '20150906',
60 'description': 'md5:a5e802558d35247fee285875328c0b80',
61 'uploader_id': 'BandaiVisual',
62 'uploader': 'BANDAI NAMCO Arts Channel',
65 'skip_download': True,
68 'url': 'https://www.vvvvid.it/show/434/perche-dovrei-guardarlo-di-dario-moccia/437/489048',
73 def _real_initialize(self
):
74 self
._conn
_id
= self
._download
_json
(
75 'https://www.vvvvid.it/user/login',
76 None, headers
=self
.geo_verification_headers())['data']['conn_id']
78 def _download_info(self
, show_id
, path
, video_id
, fatal
=True):
79 response
= self
._download
_json
(
80 'https://www.vvvvid.it/vvvvid/ondemand/%s/%s' % (show_id
, path
),
81 video_id
, headers
=self
.geo_verification_headers(), query
={
82 'conn_id': self
._conn
_id
,
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
= re
.match(self
._VALID
_URL
, url
).groups()
100 response
= self
._download
_info
(
101 show_id
, 'season/%s' % season_id
, video_id
)
104 video_data
= list(filter(
105 lambda episode
: episode
.get('video_id') == vid
, response
))[0]
106 title
= video_data
['title']
109 # vvvvid embed_info decryption algorithm is reverse engineered from function $ds(h) at vvvvid.js
111 g
= "MNOPIJKL89+/4567UVWXQRSTEFGHABCDcdefYZabstuvopqr0123wxyzklmnghij"
118 while ((not b
) and o
< m_len
):
127 k
= (m
[o
- 1] << 4) & 255
131 j
= (m
[o
- 1] << 6) & 255
152 for e
in range(c_len
* 2 - 1, -1, -1):
153 a
= c
[e
% c_len
] ^ c
[(e
+ 1) % c_len
]
165 def metadata_from_url(r_url
):
166 if not info
and r_url
:
167 mobj
= re
.search(r
'_(?:S(\d+))?Ep(\d+)', r_url
)
169 info
['episode_number'] = int(mobj
.group(2))
170 season_number
= mobj
.group(1)
172 info
['season_number'] = int(season_number
)
174 video_type
= video_data
.get('video_type')
176 for quality
in ('', '_sd'):
177 embed_code
= video_data
.get('embed_info' + quality
)
180 embed_code
= ds(embed_code
)
181 if video_type
in ('video/rcs', 'video/kenc'):
182 if video_type
== 'video/kenc':
183 kenc
= self
._download
_json
(
184 'https://www.vvvvid.it/kenc', video_id
, query
={
186 'conn_id': self
._conn
_id
,
188 }, fatal
=False) or {}
189 kenc_message
= kenc
.get('message')
191 embed_code
+= '?' + ds(kenc_message
)
192 formats
.extend(self
._extract
_akamai
_formats
(embed_code
, video_id
))
193 elif video_type
== 'video/youtube':
195 '_type': 'url_transparent',
196 'ie_key': YoutubeIE
.ie_key(),
202 formats
.extend(self
._extract
_wowza
_formats
(
203 'http://sb.top-ix.org/videomg/_definst_/mp4:%s/playlist.m3u8' % embed_code
, video_id
))
204 metadata_from_url(embed_code
)
207 self
._sort
_formats
(formats
)
208 info
['formats'] = formats
210 metadata_from_url(video_data
.get('thumbnail'))
211 info
.update(self
._extract
_common
_video
_info
(video_data
))
215 'duration': int_or_none(video_data
.get('length')),
216 'series': video_data
.get('show_title'),
217 'season_id': season_id
,
219 'view_count': int_or_none(video_data
.get('views')),
220 'like_count': int_or_none(video_data
.get('video_likes')),
221 'repost_count': int_or_none(video_data
.get('video_shares')),
226 class VVVVIDShowIE(VVVVIDIE
):
227 _VALID_URL
= r
'(?P<base_url>%s(?P<id>\d+)(?:/(?P<show_title>[^/?&#]+))?)/?(?:[?#&]|$)' % VVVVIDIE
._VALID
_URL
_BASE
229 'url': 'https://www.vvvvid.it/show/156/psyco-pass',
232 'title': 'Psycho-Pass',
233 'description': 'md5:94d572c0bd85894b193b8aebc9a3a806',
235 'playlist_count': 46,
237 'url': 'https://www.vvvvid.it/show/156',
238 'only_matching': True,
241 def _real_extract(self
, url
):
242 base_url
, show_id
, show_title
= re
.match(self
._VALID
_URL
, url
).groups()
244 seasons
= self
._download
_info
(
245 show_id
, 'seasons/', show_title
)
247 show_info
= self
._download
_info
(
248 show_id
, 'info/', show_title
, fatal
=False)
251 for season
in (seasons
or []):
252 episodes
= season
.get('episodes') or []
253 for episode
in episodes
:
254 if episode
.get('playable') is False:
256 season_id
= str_or_none(episode
.get('season_id'))
257 video_id
= str_or_none(episode
.get('video_id'))
258 if not (season_id
and video_id
):
260 info
= self
._extract
_common
_video
_info
(episode
)
263 'ie_key': VVVVIDIE
.ie_key(),
264 'url': '/'.join([base_url
, season_id
, video_id
]),
265 'title': episode
.get('title'),
266 'description': episode
.get('description'),
267 'season_id': season_id
,
271 return self
.playlist_result(
272 entries
, show_id
, show_info
.get('title'), show_info
.get('description'))