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