]>
jfr.im git - yt-dlp.git/blob - youtube_dlc/extractor/vvvvid.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class VVVVIDIE(InfoExtractor
):
15 _VALID_URL_BASE
= r
'https?://(?:www\.)?vvvvid\.it/(?:#!)?(?:show|anime|film|series)/'
16 _VALID_URL
= r
'%s(?P<show_id>\d+)/[^/]+/(?P<season_id>\d+)/(?P<id>[0-9]+)' % _VALID_URL_BASE
18 # video_type == 'video/vvvvid'
19 'url': 'https://www.vvvvid.it/#!show/434/perche-dovrei-guardarlo-di-dario-moccia/437/489048/ping-pong',
20 'md5': 'b8d3cecc2e981adc3835adf07f6df91b',
26 'series': '"Perché dovrei guardarlo?" di Dario Moccia',
28 'episode': 'Ping Pong',
36 'skip_download': True,
39 # video_type == 'video/rcs'
40 'url': 'https://www.vvvvid.it/#!show/376/death-note-live-action/377/482493/episodio-01',
41 'md5': '33e0edfba720ad73a8782157fdebc648',
45 'title': 'Episodio 01',
48 'skip_download': True,
51 'url': 'https://www.vvvvid.it/show/434/perche-dovrei-guardarlo-di-dario-moccia/437/489048',
56 def _real_initialize(self
):
57 self
._conn
_id
= self
._download
_json
(
58 'https://www.vvvvid.it/user/login',
59 None, headers
=self
.geo_verification_headers())['data']['conn_id']
61 def _download_info(self
, show_id
, path
, video_id
, fatal
=True):
62 response
= self
._download
_json
(
63 'https://www.vvvvid.it/vvvvid/ondemand/%s/%s' % (show_id
, path
),
64 video_id
, headers
=self
.geo_verification_headers(), query
={
65 'conn_id': self
._conn
_id
,
67 if not (response
or fatal
):
69 if response
.get('result') == 'error':
70 raise ExtractorError('%s said: %s' % (
71 self
.IE_NAME
, response
['message']), expected
=True)
72 return response
['data']
74 def _extract_common_video_info(self
, video_data
):
76 'thumbnail': video_data
.get('thumbnail'),
77 'episode_id': str_or_none(video_data
.get('id')),
80 def _real_extract(self
, url
):
81 show_id
, season_id
, video_id
= re
.match(self
._VALID
_URL
, url
).groups()
83 response
= self
._download
_info
(
84 show_id
, 'season/%s' % season_id
, video_id
)
87 video_data
= list(filter(
88 lambda episode
: episode
.get('video_id') == vid
, response
))[0]
89 title
= video_data
['title']
92 # vvvvid embed_info decryption algorithm is reverse engineered from function $ds(h) at vvvvid.js
94 g
= "MNOPIJKL89+/4567UVWXQRSTEFGHABCDcdefYZabstuvopqr0123wxyzklmnghij"
101 while ((not b
) and o
< m_len
):
110 k
= (m
[o
- 1] << 4) & 255
114 j
= (m
[o
- 1] << 6) & 255
135 for e
in range(c_len
* 2 - 1, -1, -1):
136 a
= c
[e
% c_len
] ^ c
[(e
+ 1) % c_len
]
148 def metadata_from_url(r_url
):
149 if not info
and r_url
:
150 mobj
= re
.search(r
'_(?:S(\d+))?Ep(\d+)', r_url
)
152 info
['episode_number'] = int(mobj
.group(2))
153 season_number
= mobj
.group(1)
155 info
['season_number'] = int(season_number
)
157 for quality
in ('_sd', ''):
158 embed_code
= video_data
.get('embed_info' + quality
)
161 embed_code
= ds(embed_code
)
162 video_type
= video_data
.get('video_type')
163 if video_type
in ('video/rcs', 'video/kenc'):
164 if video_type
== 'video/kenc':
165 kenc
= self
._download
_json
(
166 'https://www.vvvvid.it/kenc', video_id
, query
={
168 'conn_id': self
._conn
_id
,
170 }, fatal
=False) or {}
171 kenc_message
= kenc
.get('message')
173 embed_code
+= '?' + ds(kenc_message
)
174 formats
.extend(self
._extract
_akamai
_formats
(embed_code
, video_id
))
176 formats
.extend(self
._extract
_wowza
_formats
(
177 'http://sb.top-ix.org/videomg/_definst_/mp4:%s/playlist.m3u8' % embed_code
, video_id
))
178 metadata_from_url(embed_code
)
180 self
._sort
_formats
(formats
)
182 metadata_from_url(video_data
.get('thumbnail'))
183 info
.update(self
._extract
_common
_video
_info
(video_data
))
188 'duration': int_or_none(video_data
.get('length')),
189 'series': video_data
.get('show_title'),
190 'season_id': season_id
,
192 'view_count': int_or_none(video_data
.get('views')),
193 'like_count': int_or_none(video_data
.get('video_likes')),
194 'repost_count': int_or_none(video_data
.get('video_shares')),
199 class VVVVIDShowIE(VVVVIDIE
):
200 _VALID_URL
= r
'(?P<base_url>%s(?P<id>\d+)(?:/(?P<show_title>[^/?&#]+))?)/?(?:[?#&]|$)' % VVVVIDIE
._VALID
_URL
_BASE
202 'url': 'https://www.vvvvid.it/show/156/psyco-pass',
205 'title': 'Psycho-Pass',
206 'description': 'md5:94d572c0bd85894b193b8aebc9a3a806',
208 'playlist_count': 46,
210 'url': 'https://www.vvvvid.it/show/156',
211 'only_matching': True,
214 def _real_extract(self
, url
):
215 base_url
, show_id
, show_title
= re
.match(self
._VALID
_URL
, url
).groups()
217 seasons
= self
._download
_info
(
218 show_id
, 'seasons/', show_title
)
220 show_info
= self
._download
_info
(
221 show_id
, 'info/', show_title
, fatal
=False)
224 for season
in (seasons
or []):
225 episodes
= season
.get('episodes') or []
226 for episode
in episodes
:
227 if episode
.get('playable') is False:
229 season_id
= str_or_none(episode
.get('season_id'))
230 video_id
= str_or_none(episode
.get('video_id'))
231 if not (season_id
and video_id
):
233 info
= self
._extract
_common
_video
_info
(episode
)
236 'ie_key': VVVVIDIE
.ie_key(),
237 'url': '/'.join([base_url
, season_id
, video_id
]),
238 'title': episode
.get('title'),
239 'description': episode
.get('description'),
240 'season_id': season_id
,
244 return self
.playlist_result(
245 entries
, show_id
, show_info
.get('title'), show_info
.get('description'))