]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/vupload.py
[FormatSort] `eac3` is better than `ac3`
[yt-dlp.git] / yt_dlp / extractor / vupload.py
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,
10 )
11
12
13 class VuploadIE(InfoExtractor):
14 _VALID_URL = r'https://vupload\.com/v/(?P<id>[a-z0-9]+)'
15 _TESTS = [{
16 'url': 'https://vupload.com/v/u28d0pl2tphy',
17 'md5': '9b42a4a193cca64d80248e58527d83c8',
18 'info_dict': {
19 'id': 'u28d0pl2tphy',
20 'ext': 'mp4',
21 'description': 'md5:e9e6c0045c78cbf0d5bb19a55ce199fb',
22 'title': 'md5:e9e6c0045c78cbf0d5bb19a55ce199fb',
23 }
24 }]
25
26 def _real_extract(self, url):
27 video_id = self._match_id(url)
28 webpage = self._download_webpage(url, video_id)
29
30 title = self._html_search_regex(r'<title>(.+?)</title>', webpage, 'title')
31 video_e = self._html_search_regex(r'\|([a-z0-9]{60})\|', webpage, 'video')
32 video_url = f'https://wurize.megaupload.to/{video_e}/v.mp4'
33 duration = parse_duration(self._html_search_regex(
34 r'<i\s*class=["\']fad\s*fa-clock["\']></i>\s*([\d:]+)\s*</div>', webpage, 'duration', fatal=False))
35 filesize_approx = parse_filesize(self._html_search_regex(
36 r'<i\s*class=["\']fad\s*fa-save["\']></i>\s*([^<]+)\s*</div>', webpage, 'filesize', fatal=False))
37 extra_video_info = extract_attributes(self._html_search_regex(
38 r'(<video[^>]+>)', webpage, 'video_info', fatal=False))
39 description = self._html_search_meta('description', webpage)
40
41 return {
42 'id': video_id,
43 'url': video_url,
44 'duration': duration,
45 'filesize_approx': filesize_approx,
46 'width': int_or_none(extra_video_info.get('width')),
47 'height': int_or_none(extra_video_info.get('height')),
48 'format_id': extra_video_info.get('height', '') + 'p',
49 'title': title,
50 'description': description,
51 }