]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/videa.py
5 from .common
import InfoExtractor
17 from ..compat
import (
24 class VideaIE(InfoExtractor
):
29 videok/(?:[^/]+/)*[^?#&]+-|
30 (?:videojs_)?player\?.*?\bv=|
36 'url': 'http://videa.hu/videok/allatok/az-orult-kigyasz-285-kigyot-kigyo-8YfIAjxwWGwT8HVQ',
37 'md5': '97a7af41faeaffd9f1fc864a7c7e7603',
39 'id': '8YfIAjxwWGwT8HVQ',
41 'title': 'Az őrült kígyász 285 kígyót enged szabadon',
42 'thumbnail': r
're:^https?://.*',
46 'url': 'http://videa.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH',
47 'md5': 'd57ccd8812c7fd491d33b1eab8c99975',
49 'id': 'jAHDWfWSJH5XuFhH',
51 'title': 'Supercars előzés',
52 'thumbnail': r
're:^https?://.*',
56 'url': 'http://videa.hu/player?v=8YfIAjxwWGwT8HVQ',
57 'md5': '97a7af41faeaffd9f1fc864a7c7e7603',
59 'id': '8YfIAjxwWGwT8HVQ',
61 'title': 'Az őrült kígyász 285 kígyót enged szabadon',
62 'thumbnail': r
're:^https?://.*',
66 'url': 'http://videa.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
67 'only_matching': True,
69 'url': 'https://videakid.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH',
70 'only_matching': True,
72 'url': 'https://videakid.hu/player?v=8YfIAjxwWGwT8HVQ',
73 'only_matching': True,
75 'url': 'https://videakid.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
76 'only_matching': True,
78 _STATIC_SECRET
= 'xHb0ZvME5q8CBcoQi6AngerDu3FGO9fkUlwPmLVY_RTzj2hJIS4NasXWKy1td7p'
81 def _extract_urls(webpage
):
82 return [url
for _
, url
in re
.findall(
83 r
'<iframe[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//videa\
.hu
/player
\?.*?
\bv
=.+?
)\
1',
87 def rc4(cipher_text, key):
95 j = (j + S[i] + ord(key[i % key_len])) % 256
96 S[i], S[j] = S[j], S[i]
100 for m in range(len(cipher_text)):
103 S[i], S[j] = S[j], S[i]
104 k = S[(S[i] + S[j]) % 256]
105 res += compat_struct_pack('B
', k ^ compat_ord(cipher_text[m]))
109 def _real_extract(self, url):
110 video_id = self._match_id(url)
111 video_page = self._download_webpage(url, video_id)
113 if 'videa
.hu
/player
' in url:
115 player_page = video_page
117 player_url = self._search_regex(
118 r'<iframe
.*?src
="(/player\?[^"]+)"', video_page, 'player url')
119 player_url = urljoin(url, player_url)
120 player_page = self._download_webpage(player_url, video_id)
122 nonce = self._search_regex(
123 r'_xt\s*=\s*"([^
"]+)"', player_page, 'nonce
')
127 for i in range(0, 32):
128 result += s[i - (self._STATIC_SECRET.index(l[i]) - 31)]
130 query = parse_qs(player_url)
131 random_seed = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8))
132 query['_s
'] = random_seed
133 query['_t
'] = result[:16]
135 b64_info, handle = self._download_webpage_handle(
136 'http
://videa
.hu
/videaplayer_get_xml
.php
', video_id, query=query)
137 if b64_info.startswith('<?xml
'):
138 info = self._parse_xml(b64_info, video_id)
140 key = result[16:] + random_seed + handle.headers['x
-videa
-xs
']
141 info = self._parse_xml(self.rc4(
142 compat_b64decode(b64_info), key), video_id)
144 video = xpath_element(info, './video
', 'video
')
146 raise ExtractorError(xpath_element(
147 info, './error
', fatal=True), expected=True)
148 sources = xpath_element(
149 info, './video_sources
', 'sources
', fatal=True)
150 hash_values = xpath_element(
151 info, './hash_values
', 'hash values
', fatal=False)
153 title = xpath_text(video, './title
', fatal=True)
156 for source in sources.findall('./video_source
'):
157 source_url = source.text
158 source_name = source.get('name
')
159 source_exp = source.get('exp
')
160 if not (source_url and source_name):
163 xpath_text(hash_values, 'hash_value_
' + source_name)
164 if hash_values is not None else None)
165 if hash_value and source_exp:
166 source_url = update_url_query(source_url, {
168 'expires
': source_exp,
170 f = parse_codecs(source.get('codecs
'))
172 'url
': self._proto_relative_url(source_url),
173 'ext
': mimetype2ext(source.get('mimetype
')) or 'mp4
',
174 'format_id
': source.get('name
'),
175 'width
': int_or_none(source.get('width
')),
176 'height
': int_or_none(source.get('height
')),
179 self._sort_formats(formats)
181 thumbnail = self._proto_relative_url(xpath_text(video, './poster_src
'))
184 is_adult = xpath_text(video, './is_adult_content
', default=None)
186 age_limit = 18 if is_adult == '1' else 0
191 'thumbnail
': thumbnail,
192 'duration
': int_or_none(xpath_text(video, './duration
')),
193 'age_limit
': age_limit,