]>
Commit | Line | Data |
---|---|---|
ebf2fb4d | 1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
3 | parse_duration, | |
4 | parse_filesize, | |
5 | extract_attributes, | |
6 | int_or_none, | |
b515b37c | 7 | js_to_json |
ebf2fb4d | 8 | ) |
9 | ||
10 | ||
11 | class VuploadIE(InfoExtractor): | |
12 | _VALID_URL = r'https://vupload\.com/v/(?P<id>[a-z0-9]+)' | |
13 | _TESTS = [{ | |
14 | 'url': 'https://vupload.com/v/u28d0pl2tphy', | |
15 | 'md5': '9b42a4a193cca64d80248e58527d83c8', | |
16 | 'info_dict': { | |
17 | 'id': 'u28d0pl2tphy', | |
18 | 'ext': 'mp4', | |
19 | 'description': 'md5:e9e6c0045c78cbf0d5bb19a55ce199fb', | |
20 | 'title': 'md5:e9e6c0045c78cbf0d5bb19a55ce199fb', | |
21 | } | |
22 | }] | |
23 | ||
24 | def _real_extract(self, url): | |
25 | video_id = self._match_id(url) | |
26 | webpage = self._download_webpage(url, video_id) | |
27 | ||
04f3fd2c | 28 | title = self._html_extract_title(webpage) |
b515b37c | 29 | video_json = self._parse_json(self._html_search_regex(r'sources:\s*(.+?]),', webpage, 'video'), video_id, transform_source=js_to_json) |
30 | formats = [] | |
31 | for source in video_json: | |
32 | if source['src'].endswith('.m3u8'): | |
33 | formats.extend(self._extract_m3u8_formats(source['src'], video_id, m3u8_id='hls')) | |
ebf2fb4d | 34 | duration = parse_duration(self._html_search_regex( |
35 | r'<i\s*class=["\']fad\s*fa-clock["\']></i>\s*([\d:]+)\s*</div>', webpage, 'duration', fatal=False)) | |
36 | filesize_approx = parse_filesize(self._html_search_regex( | |
37 | r'<i\s*class=["\']fad\s*fa-save["\']></i>\s*([^<]+)\s*</div>', webpage, 'filesize', fatal=False)) | |
38 | extra_video_info = extract_attributes(self._html_search_regex( | |
39 | r'(<video[^>]+>)', webpage, 'video_info', fatal=False)) | |
40 | description = self._html_search_meta('description', webpage) | |
41 | ||
42 | return { | |
43 | 'id': video_id, | |
b515b37c | 44 | 'formats': formats, |
ebf2fb4d | 45 | 'duration': duration, |
46 | 'filesize_approx': filesize_approx, | |
47 | 'width': int_or_none(extra_video_info.get('width')), | |
48 | 'height': int_or_none(extra_video_info.get('height')), | |
49 | 'format_id': extra_video_info.get('height', '') + 'p', | |
50 | 'title': title, | |
51 | 'description': description, | |
52 | } |