]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | parse_iso8601, | |
4 | qualities, | |
5 | ) | |
6 | ||
7 | import re | |
8 | ||
9 | ||
10 | class ClippitIE(InfoExtractor): | |
11 | ||
12 | _VALID_URL = r'https?://(?:www\.)?clippituser\.tv/c/(?P<id>[a-z]+)' | |
13 | _TEST = { | |
14 | 'url': 'https://www.clippituser.tv/c/evmgm', | |
15 | 'md5': '963ae7a59a2ec4572ab8bf2f2d2c5f09', | |
16 | 'info_dict': { | |
17 | 'id': 'evmgm', | |
18 | 'ext': 'mp4', | |
19 | 'title': 'Bye bye Brutus. #BattleBots - Clippit', | |
20 | 'uploader': 'lizllove', | |
21 | 'uploader_url': 'https://www.clippituser.tv/p/lizllove', | |
22 | 'timestamp': 1472183818, | |
23 | 'upload_date': '20160826', | |
24 | 'description': 'BattleBots | ABC', | |
25 | 'thumbnail': r're:^https?://.*\.jpg$', | |
26 | } | |
27 | } | |
28 | ||
29 | def _real_extract(self, url): | |
30 | video_id = self._match_id(url) | |
31 | webpage = self._download_webpage(url, video_id) | |
32 | ||
33 | title = self._html_search_regex(r'<title.*>(.+?)</title>', webpage, 'title') | |
34 | ||
35 | FORMATS = ('sd', 'hd') | |
36 | quality = qualities(FORMATS) | |
37 | formats = [] | |
38 | for format_id in FORMATS: | |
39 | url = self._html_search_regex(r'data-%s-file="(.+?)"' % format_id, | |
40 | webpage, 'url', fatal=False) | |
41 | if not url: | |
42 | continue | |
43 | match = re.search(r'/(?P<height>\d+)\.mp4', url) | |
44 | formats.append({ | |
45 | 'url': url, | |
46 | 'format_id': format_id, | |
47 | 'quality': quality(format_id), | |
48 | 'height': int(match.group('height')) if match else None, | |
49 | }) | |
50 | ||
51 | uploader = self._html_search_regex(r'class="username".*>\s+(.+?)\n', | |
52 | webpage, 'uploader', fatal=False) | |
53 | uploader_url = ('https://www.clippituser.tv/p/' + uploader | |
54 | if uploader else None) | |
55 | ||
56 | timestamp = self._html_search_regex(r'datetime="(.+?)"', | |
57 | webpage, 'date', fatal=False) | |
58 | thumbnail = self._html_search_regex(r'data-image="(.+?)"', | |
59 | webpage, 'thumbnail', fatal=False) | |
60 | ||
61 | return { | |
62 | 'id': video_id, | |
63 | 'title': title, | |
64 | 'formats': formats, | |
65 | 'uploader': uploader, | |
66 | 'uploader_url': uploader_url, | |
67 | 'timestamp': parse_iso8601(timestamp), | |
68 | 'description': self._og_search_description(webpage), | |
69 | 'thumbnail': thumbnail, | |
70 | } |