]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/videa.py
6 from .common
import InfoExtractor
7 from ..compat
import compat_b64decode
, compat_ord
21 class VideaIE(InfoExtractor
):
26 videok/(?:[^/]+/)*[^?#&]+-|
27 (?:videojs_)?player\?.*?\bv=|
33 'url': 'http://videa.hu/videok/allatok/az-orult-kigyasz-285-kigyot-kigyo-8YfIAjxwWGwT8HVQ',
34 'md5': '97a7af41faeaffd9f1fc864a7c7e7603',
36 'id': '8YfIAjxwWGwT8HVQ',
38 'title': 'Az őrült kígyász 285 kígyót enged szabadon',
39 'thumbnail': r
're:^https?://.*',
43 'url': 'http://videa.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH',
44 'md5': 'd57ccd8812c7fd491d33b1eab8c99975',
46 'id': 'jAHDWfWSJH5XuFhH',
48 'title': 'Supercars előzés',
49 'thumbnail': r
're:^https?://.*',
53 'url': 'http://videa.hu/player?v=8YfIAjxwWGwT8HVQ',
54 'md5': '97a7af41faeaffd9f1fc864a7c7e7603',
56 'id': '8YfIAjxwWGwT8HVQ',
58 'title': 'Az őrült kígyász 285 kígyót enged szabadon',
59 'thumbnail': r
're:^https?://.*',
63 'url': 'http://videa.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
64 'only_matching': True,
66 'url': 'https://videakid.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH',
67 'only_matching': True,
69 'url': 'https://videakid.hu/player?v=8YfIAjxwWGwT8HVQ',
70 'only_matching': True,
72 'url': 'https://videakid.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
73 'only_matching': True,
75 _STATIC_SECRET
= 'xHb0ZvME5q8CBcoQi6AngerDu3FGO9fkUlwPmLVY_RTzj2hJIS4NasXWKy1td7p'
78 def _extract_urls(webpage
):
79 return [url
for _
, url
in re
.findall(
80 r
'<iframe[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//videa\
.hu
/player
\?.*?
\bv
=.+?
)\
1',
84 def rc4(cipher_text, key):
92 j = (j + S[i] + ord(key[i % key_len])) % 256
93 S[i], S[j] = S[j], S[i]
97 for m in range(len(cipher_text)):
100 S[i], S[j] = S[j], S[i]
101 k = S[(S[i] + S[j]) % 256]
102 res += struct.pack('B
', k ^ compat_ord(cipher_text[m]))
106 def _real_extract(self, url):
107 video_id = self._match_id(url)
108 video_page = self._download_webpage(url, video_id)
110 if 'videa
.hu
/player
' in url:
112 player_page = video_page
114 player_url = self._search_regex(
115 r'<iframe
.*?src
="(/player\?[^"]+)"', video_page, 'player url')
116 player_url = urljoin(url, player_url)
117 player_page = self._download_webpage(player_url, video_id)
119 nonce = self._search_regex(
120 r'_xt\s*=\s*"([^
"]+)"', player_page, 'nonce
')
124 for i in range(0, 32):
125 result += s[i - (self._STATIC_SECRET.index(l[i]) - 31)]
127 query = parse_qs(player_url)
128 random_seed = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8))
129 query['_s
'] = random_seed
130 query['_t
'] = result[:16]
132 b64_info, handle = self._download_webpage_handle(
133 'http
://videa
.hu
/videaplayer_get_xml
.php
', video_id, query=query)
134 if b64_info.startswith('<?xml
'):
135 info = self._parse_xml(b64_info, video_id)
137 key = result[16:] + random_seed + handle.headers['x
-videa
-xs
']
138 info = self._parse_xml(self.rc4(
139 compat_b64decode(b64_info), key), video_id)
141 video = xpath_element(info, './video
', 'video
')
143 raise ExtractorError(xpath_element(
144 info, './error
', fatal=True), expected=True)
145 sources = xpath_element(
146 info, './video_sources
', 'sources
', fatal=True)
147 hash_values = xpath_element(
148 info, './hash_values
', 'hash values
', fatal=False)
150 title = xpath_text(video, './title
', fatal=True)
153 for source in sources.findall('./video_source
'):
154 source_url = source.text
155 source_name = source.get('name
')
156 source_exp = source.get('exp
')
157 if not (source_url and source_name):
160 xpath_text(hash_values, 'hash_value_
' + source_name)
161 if hash_values is not None else None)
162 if hash_value and source_exp:
163 source_url = update_url_query(source_url, {
165 'expires
': source_exp,
167 f = parse_codecs(source.get('codecs
'))
169 'url
': self._proto_relative_url(source_url),
170 'ext
': mimetype2ext(source.get('mimetype
')) or 'mp4
',
171 'format_id
': source.get('name
'),
172 'width
': int_or_none(source.get('width
')),
173 'height
': int_or_none(source.get('height
')),
176 self._sort_formats(formats)
178 thumbnail = self._proto_relative_url(xpath_text(video, './poster_src
'))
181 is_adult = xpath_text(video, './is_adult_content
', default=None)
183 age_limit = 18 if is_adult == '1' else 0
188 'thumbnail
': thumbnail,
189 'duration
': int_or_none(xpath_text(video, './duration
')),
190 'age_limit
': age_limit,