]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/videa.py
2 from __future__
import unicode_literals
8 from .common
import InfoExtractor
18 from ..compat
import (
25 class VideaIE(InfoExtractor
):
30 videok/(?:[^/]+/)*[^?#&]+-|
31 (?:videojs_)?player\?.*?\bv=|
37 'url': 'http://videa.hu/videok/allatok/az-orult-kigyasz-285-kigyot-kigyo-8YfIAjxwWGwT8HVQ',
38 'md5': '97a7af41faeaffd9f1fc864a7c7e7603',
40 'id': '8YfIAjxwWGwT8HVQ',
42 'title': 'Az őrült kígyász 285 kígyót enged szabadon',
43 'thumbnail': r
're:^https?://.*',
47 'url': 'http://videa.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH',
48 'only_matching': True,
50 'url': 'http://videa.hu/player?v=8YfIAjxwWGwT8HVQ',
51 'only_matching': True,
53 'url': 'http://videa.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
54 'only_matching': True,
56 'url': 'https://videakid.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH',
57 'only_matching': True,
59 'url': 'https://videakid.hu/player?v=8YfIAjxwWGwT8HVQ',
60 'only_matching': True,
62 'url': 'https://videakid.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
63 'only_matching': True,
65 _STATIC_SECRET
= 'xHb0ZvME5q8CBcoQi6AngerDu3FGO9fkUlwPmLVY_RTzj2hJIS4NasXWKy1td7p'
68 def _extract_urls(webpage
):
69 return [url
for _
, url
in re
.findall(
70 r
'<iframe[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//videa\
.hu
/player
\?.*?
\bv
=.+?
)\
1',
74 def rc4(cipher_text, key):
82 j = (j + S[i] + ord(key[i % key_len])) % 256
83 S[i], S[j] = S[j], S[i]
87 for m in range(len(cipher_text)):
90 S[i], S[j] = S[j], S[i]
91 k = S[(S[i] + S[j]) % 256]
92 res += compat_struct_pack('B
', k ^ compat_ord(cipher_text[m]))
96 def _real_extract(self, url):
97 video_id = self._match_id(url)
98 query = {'v': video_id}
99 player_page = self._download_webpage(
100 'https
://videa
.hu
/player
', video_id, query=query)
102 nonce = self._search_regex(
103 r'_xt\s
*=\s
*"([^"]+)"', player_page, 'nonce')
107 for i in range(0, 32):
108 result += s[i - (self._STATIC_SECRET.index(l[i]) - 31)]
110 random_seed = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8))
111 query['_s'] = random_seed
112 query['_t'] = result[:16]
114 b64_info, handle = self._download_webpage_handle(
115 'http://videa.hu/videaplayer_get_xml.php', video_id, query=query)
116 if b64_info.startswith('<?xml'):
117 info = self._parse_xml(b64_info, video_id)
119 key = result[16:] + random_seed + handle.headers['x-videa-xs']
120 info = self._parse_xml(self.rc4(
121 compat_b64decode(b64_info), key), video_id)
123 video = xpath_element(info, './video', 'video')
125 raise ExtractorError(xpath_element(
126 info, './error', fatal=True), expected=True)
127 sources = xpath_element(
128 info, './video_sources', 'sources', fatal=True)
129 hash_values = xpath_element(
130 info, './hash_values', 'hash values', fatal=True)
132 title = xpath_text(video, './title', fatal=True)
135 for source in sources.findall('./video_source'):
136 source_url = source.text
137 source_name = source.get('name')
138 source_exp = source.get('exp')
139 if not (source_url and source_name and source_exp):
141 hash_value = xpath_text(hash_values, 'hash_value_' + source_name)
144 source_url = update_url_query(source_url, {
146 'expires': source_exp,
148 f = parse_codecs(source.get('codecs'))
150 'url': self._proto_relative_url(source_url),
151 'ext': mimetype2ext(source.get('mimetype')) or 'mp4',
152 'format_id': source.get('name'),
153 'width': int_or_none(source.get('width')),
154 'height': int_or_none(source.get('height')),
157 self._sort_formats(formats)
159 thumbnail = self._proto_relative_url(xpath_text(video, './poster_src'))
162 is_adult = xpath_text(video, './is_adult_content', default=None)
164 age_limit = 18 if is_adult == '1' else 0
169 'thumbnail': thumbnail,
170 'duration': int_or_none(xpath_text(video, './duration')),
171 'age_limit': age_limit,