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