]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/meta.py
[ie/box] Fix formats extraction (#8649)
[yt-dlp.git] / yt_dlp / extractor / meta.py
1 from .common import InfoExtractor
2 from .pladform import PladformIE
3 from ..utils import (
4 unescapeHTML,
5 int_or_none,
6 ExtractorError,
7 )
8
9
10 class METAIE(InfoExtractor):
11 _VALID_URL = r'https?://video\.meta\.ua/(?:iframe/)?(?P<id>[0-9]+)'
12 _TESTS = [{
13 'url': 'http://video.meta.ua/5502115.video',
14 'md5': '71b6f3ee274bef16f1ab410f7f56b476',
15 'info_dict': {
16 'id': '5502115',
17 'ext': 'mp4',
18 'title': 'Sony Xperia Z camera test [HQ]',
19 'description': 'Xperia Z shoots video in FullHD HDR.',
20 'uploader_id': 'nomobile',
21 'uploader': 'CHЁZA.TV',
22 'upload_date': '20130211',
23 },
24 'add_ie': ['Youtube'],
25 }, {
26 'url': 'http://video.meta.ua/iframe/5502115',
27 'only_matching': True,
28 }, {
29 # pladform embed
30 'url': 'http://video.meta.ua/7121015.video',
31 'only_matching': True,
32 }]
33
34 def _real_extract(self, url):
35 video_id = self._match_id(url)
36 webpage = self._download_webpage(url, video_id)
37
38 st_html5 = self._search_regex(
39 r"st_html5\s*=\s*'#([^']+)'", webpage, 'uppod html5 st', default=None)
40
41 if st_html5:
42 # uppod st decryption algorithm is reverse engineered from function un(s) at uppod.js
43 json_str = ''
44 for i in range(0, len(st_html5), 3):
45 json_str += '&#x0%s;' % st_html5[i:i + 3]
46 uppod_data = self._parse_json(unescapeHTML(json_str), video_id)
47 error = uppod_data.get('customnotfound')
48 if error:
49 raise ExtractorError('%s said: %s' % (self.IE_NAME, error), expected=True)
50
51 video_url = uppod_data['file']
52 info = {
53 'id': video_id,
54 'url': video_url,
55 'title': uppod_data.get('comment') or self._og_search_title(webpage),
56 'description': self._og_search_description(webpage, default=None),
57 'thumbnail': uppod_data.get('poster') or self._og_search_thumbnail(webpage),
58 'duration': int_or_none(self._og_search_property(
59 'video:duration', webpage, default=None)),
60 }
61 if 'youtube.com/' in video_url:
62 info.update({
63 '_type': 'url_transparent',
64 'ie_key': 'Youtube',
65 })
66 return info
67
68 pladform_url = PladformIE._extract_url(webpage)
69 if pladform_url:
70 return self.url_result(pladform_url)