2 from __future__ import unicode_literals
6 from .common import InfoExtractor
14 class VVVVIDIE(InfoExtractor):
15 _VALID_URL = r'https?://(?:www\.)?vvvvid\.it/#!(?:show|anime|film|series)/(?P<show_id>\d+)/[^/]+/(?P<season_id>\d+)/(?P<id>[0-9]+)'
17 # video_type == 'video/vvvvid'
18 'url': 'https://www.vvvvid.it/#!show/434/perche-dovrei-guardarlo-di-dario-moccia/437/489048/ping-pong',
19 'md5': 'b8d3cecc2e981adc3835adf07f6df91b',
26 # video_type == 'video/rcs'
27 'url': 'https://www.vvvvid.it/#!show/376/death-note-live-action/377/482493/episodio-01',
28 'md5': '33e0edfba720ad73a8782157fdebc648',
32 'title': 'Episodio 01',
37 def _real_initialize(self):
39 user = self._downloader.cache.load('vvvvid', 'user') or {}
40 self._conn_id = user.get('conn_id')
42 self._conn_id = self._download_json(
43 'https://www.vvvvid.it/user/login',
44 None, headers=self.geo_verification_headers())['data']['conn_id']
45 self._downloader.cache.store(
47 'conn_id': self._conn_id,
50 def _real_extract(self, url):
51 show_id, season_id, video_id = re.match(self._VALID_URL, url).groups()
52 response = self._download_json(
53 'https://www.vvvvid.it/vvvvid/ondemand/%s/season/%s' % (show_id, season_id),
54 video_id, headers=self.geo_verification_headers(), query={
55 'conn_id': self._conn_id,
57 if response['result'] == 'error':
58 raise ExtractorError('%s said: %s' % (
59 self.IE_NAME, response['message']), expected=True)
62 video_data = list(filter(
63 lambda episode: episode.get('video_id') == vid, response['data']))[0]
66 # vvvvid embed_info decryption algorithm is reverse engineered from function $ds(h) at vvvvid.js
68 g = "MNOPIJKL89+/4567UVWXQRSTEFGHABCDcdefYZabstuvopqr0123wxyzklmnghij"
75 while ((not b) and o < m_len):
84 k = (m[o - 1] << 4) & 255
88 j = (m[o - 1] << 6) & 255
109 for e in range(c_len * 2 - 1, -1, -1):
110 a = c[e % c_len] ^ c[(e + 1) % c_len]
120 for quality in ('_sd', ''):
121 embed_code = video_data.get('embed_info' + quality)
124 embed_code = ds(embed_code)
125 video_type = video_data.get('video_type')
126 if video_type in ('video/rcs', 'video/kenc'):
127 formats.extend(self._extract_akamai_formats(
128 embed_code, video_id))
130 formats.extend(self._extract_wowza_formats(
131 'http://sb.top-ix.org/videomg/_definst_/mp4:%s/playlist.m3u8' % embed_code, video_id))
132 self._sort_formats(formats)
136 'title': video_data['title'],
138 'thumbnail': video_data.get('thumbnail'),
139 'duration': int_or_none(video_data.get('length')),
140 'series': video_data.get('show_title'),
141 'season_id': season_id,
142 'season_number': video_data.get('season_number'),
143 'episode_id': str_or_none(video_data.get('id')),
144 'epidode_number': int_or_none(video_data.get('number')),
145 'episode_title': video_data['title'],
146 'view_count': int_or_none(video_data.get('views')),
147 'like_count': int_or_none(video_data.get('video_likes')),