]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/videa.py
2 from __future__
import unicode_literals
8 from .common
import InfoExtractor
20 from ..compat
import (
27 class VideaIE(InfoExtractor
):
32 videok/(?:[^/]+/)*[^?#&]+-|
33 (?:videojs_)?player\?.*?\bv=|
39 'url': 'http://videa.hu/videok/allatok/az-orult-kigyasz-285-kigyot-kigyo-8YfIAjxwWGwT8HVQ',
40 'md5': '97a7af41faeaffd9f1fc864a7c7e7603',
42 'id': '8YfIAjxwWGwT8HVQ',
44 'title': 'Az őrült kígyász 285 kígyót enged szabadon',
45 'thumbnail': r
're:^https?://.*',
49 'url': 'http://videa.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH',
50 'md5': 'd57ccd8812c7fd491d33b1eab8c99975',
52 'id': 'jAHDWfWSJH5XuFhH',
54 'title': 'Supercars előzés',
55 'thumbnail': r
're:^https?://.*',
59 'url': 'http://videa.hu/player?v=8YfIAjxwWGwT8HVQ',
60 'md5': '97a7af41faeaffd9f1fc864a7c7e7603',
62 'id': '8YfIAjxwWGwT8HVQ',
64 'title': 'Az őrült kígyász 285 kígyót enged szabadon',
65 'thumbnail': r
're:^https?://.*',
69 'url': 'http://videa.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
70 'only_matching': True,
72 'url': 'https://videakid.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH',
73 'only_matching': True,
75 'url': 'https://videakid.hu/player?v=8YfIAjxwWGwT8HVQ',
76 'only_matching': True,
78 'url': 'https://videakid.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
79 'only_matching': True,
81 _STATIC_SECRET
= 'xHb0ZvME5q8CBcoQi6AngerDu3FGO9fkUlwPmLVY_RTzj2hJIS4NasXWKy1td7p'
84 def _extract_urls(webpage
):
85 return [url
for _
, url
in re
.findall(
86 r
'<iframe[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//videa\
.hu
/player
\?.*?
\bv
=.+?
)\
1',
90 def rc4(cipher_text, key):
98 j = (j + S[i] + ord(key[i % key_len])) % 256
99 S[i], S[j] = S[j], S[i]
103 for m in range(len(cipher_text)):
106 S[i], S[j] = S[j], S[i]
107 k = S[(S[i] + S[j]) % 256]
108 res += compat_struct_pack('B
', k ^ compat_ord(cipher_text[m]))
112 def _real_extract(self, url):
113 video_id = self._match_id(url)
114 video_page = self._download_webpage(url, video_id)
116 if 'videa
.hu
/player
' in url:
118 player_page = video_page
120 player_url = self._search_regex(
121 r'<iframe
.*?src
="(/player\?[^"]+)"', video_page, 'player url')
122 player_url = urljoin(url, player_url)
123 player_page = self._download_webpage(player_url, video_id)
125 nonce = self._search_regex(
126 r'_xt\s*=\s*"([^
"]+)"', player_page, 'nonce
')
130 for i in range(0, 32):
131 result += s[i - (self._STATIC_SECRET.index(l[i]) - 31)]
133 query = parse_qs(player_url)
134 random_seed = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8))
135 query['_s
'] = random_seed
136 query['_t
'] = result[:16]
138 b64_info, handle = self._download_webpage_handle(
139 'http
://videa
.hu
/videaplayer_get_xml
.php
', video_id, query=query)
140 if b64_info.startswith('<?xml
'):
141 info = self._parse_xml(b64_info, video_id)
143 key = result[16:] + random_seed + handle.headers['x
-videa
-xs
']
144 info = self._parse_xml(self.rc4(
145 compat_b64decode(b64_info), key), video_id)
147 video = xpath_element(info, './video
', 'video
')
149 raise ExtractorError(xpath_element(
150 info, './error
', fatal=True), expected=True)
151 sources = xpath_element(
152 info, './video_sources
', 'sources
', fatal=True)
153 hash_values = xpath_element(
154 info, './hash_values
', 'hash values
', fatal=False)
156 title = xpath_text(video, './title
', fatal=True)
159 for source in sources.findall('./video_source
'):
160 source_url = source.text
161 source_name = source.get('name
')
162 source_exp = source.get('exp
')
163 if not (source_url and source_name):
166 xpath_text(hash_values, 'hash_value_
' + source_name)
167 if hash_values is not None else None)
168 if hash_value and source_exp:
169 source_url = update_url_query(source_url, {
171 'expires
': source_exp,
173 f = parse_codecs(source.get('codecs
'))
175 'url
': self._proto_relative_url(source_url),
176 'ext
': mimetype2ext(source.get('mimetype
')) or 'mp4
',
177 'format_id
': source.get('name
'),
178 'width
': int_or_none(source.get('width
')),
179 'height
': int_or_none(source.get('height
')),
182 self._sort_formats(formats)
184 thumbnail = self._proto_relative_url(xpath_text(video, './poster_src
'))
187 is_adult = xpath_text(video, './is_adult_content
', default=None)
189 age_limit = 18 if is_adult == '1' else 0
194 'thumbnail
': thumbnail,
195 'duration
': int_or_none(xpath_text(video, './duration
')),
196 'age_limit
': age_limit,