]>
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 'only_matching': True,
52 'url': 'http://videa.hu/player?v=8YfIAjxwWGwT8HVQ',
53 'only_matching': True,
55 'url': 'http://videa.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
56 'only_matching': True,
58 'url': 'https://videakid.hu/videok/origo/jarmuvek/supercars-elozes-jAHDWfWSJH5XuFhH',
59 'only_matching': True,
61 'url': 'https://videakid.hu/player?v=8YfIAjxwWGwT8HVQ',
62 'only_matching': True,
64 'url': 'https://videakid.hu/player/v/8YfIAjxwWGwT8HVQ?autoplay=1',
65 'only_matching': True,
67 _STATIC_SECRET
= 'xHb0ZvME5q8CBcoQi6AngerDu3FGO9fkUlwPmLVY_RTzj2hJIS4NasXWKy1td7p'
70 def _extract_urls(webpage
):
71 return [url
for _
, url
in re
.findall(
72 r
'<iframe[^>]+src=(["\'])(?P
<url
>(?
:https?
:)?
//videa\
.hu
/player
\?.*?
\bv
=.+?
)\
1',
76 def rc4(cipher_text, key):
84 j = (j + S[i] + ord(key[i % key_len])) % 256
85 S[i], S[j] = S[j], S[i]
89 for m in range(len(cipher_text)):
92 S[i], S[j] = S[j], S[i]
93 k = S[(S[i] + S[j]) % 256]
94 res += compat_struct_pack('B
', k ^ compat_ord(cipher_text[m]))
98 def _real_extract(self, url):
99 video_id = self._match_id(url)
101 video_page = self._download_webpage(url, video_id)
103 player_url = self._search_regex(
104 r'<iframe
.*?src
="(/player\?[^"]+)"', video_page, 'player url')
105 player_url = urljoin(url, player_url)
106 player_page = self._download_webpage(player_url, video_id)
108 nonce = self._search_regex(
109 r'_xt\s*=\s*"([^
"]+)"', player_page, 'nonce
')
113 for i in range(0, 32):
114 result += s[i - (self._STATIC_SECRET.index(l[i]) - 31)]
116 query = parse_qs(player_url)
117 random_seed = ''.join(random.choice(string.ascii_letters + string.digits) for _ in range(8))
118 query['_s
'] = random_seed
119 query['_t
'] = result[:16]
121 b64_info, handle = self._download_webpage_handle(
122 'http
://videa
.hu
/videaplayer_get_xml
.php
', video_id, query=query)
123 if b64_info.startswith('<?xml
'):
124 info = self._parse_xml(b64_info, video_id)
126 key = result[16:] + random_seed + handle.headers['x
-videa
-xs
']
127 info = self._parse_xml(self.rc4(
128 compat_b64decode(b64_info), key), video_id)
130 video = xpath_element(info, './video
', 'video
')
132 raise ExtractorError(xpath_element(
133 info, './error
', fatal=True), expected=True)
134 sources = xpath_element(
135 info, './video_sources
', 'sources
', fatal=True)
136 hash_values = xpath_element(
137 info, './hash_values
', 'hash values
', fatal=True)
139 title = xpath_text(video, './title
', fatal=True)
142 for source in sources.findall('./video_source
'):
143 source_url = source.text
144 source_name = source.get('name
')
145 source_exp = source.get('exp
')
146 if not (source_url and source_name and source_exp):
148 hash_value = xpath_text(hash_values, 'hash_value_
' + source_name)
151 source_url = update_url_query(source_url, {
153 'expires
': source_exp,
155 f = parse_codecs(source.get('codecs
'))
157 'url
': self._proto_relative_url(source_url),
158 'ext
': mimetype2ext(source.get('mimetype
')) or 'mp4
',
159 'format_id
': source.get('name
'),
160 'width
': int_or_none(source.get('width
')),
161 'height
': int_or_none(source.get('height
')),
164 self._sort_formats(formats)
166 thumbnail = self._proto_relative_url(xpath_text(video, './poster_src
'))
169 is_adult = xpath_text(video, './is_adult_content
', default=None)
171 age_limit = 18 if is_adult == '1' else 0
176 'thumbnail
': thumbnail,
177 'duration
': int_or_none(xpath_text(video, './duration
')),
178 'age_limit
': age_limit,