]>
Commit | Line | Data |
---|---|---|
1 | # coding: utf-8 | |
2 | from __future__ import unicode_literals | |
3 | ||
4 | import re | |
5 | ||
6 | from .common import InfoExtractor | |
7 | from ..utils import ( | |
8 | int_or_none, | |
9 | month_by_abbreviation, | |
10 | parse_filesize, | |
11 | parse_qs, | |
12 | ) | |
13 | ||
14 | ||
15 | class XboxClipsIE(InfoExtractor): | |
16 | _VALID_URL = r'https?://(?:www\.)?(?:xboxclips\.com|gameclips\.io)/(?:video\.php\?.*vid=|[^/]+/)(?P<id>[\da-f]{8}-(?:[\da-f]{4}-){3}[\da-f]{12})' | |
17 | _TESTS = [{ | |
18 | 'url': 'http://xboxclips.com/video.php?uid=2533274823424419&gamertag=Iabdulelah&vid=074a69a9-5faf-46aa-b93b-9909c1720325', | |
19 | 'md5': 'fbe1ec805e920aeb8eced3c3e657df5d', | |
20 | 'info_dict': { | |
21 | 'id': '074a69a9-5faf-46aa-b93b-9909c1720325', | |
22 | 'ext': 'mp4', | |
23 | 'title': 'iAbdulElah playing Titanfall', | |
24 | 'filesize_approx': 26800000, | |
25 | 'upload_date': '20140807', | |
26 | 'duration': 56, | |
27 | } | |
28 | }, { | |
29 | 'url': 'https://gameclips.io/iAbdulElah/074a69a9-5faf-46aa-b93b-9909c1720325', | |
30 | 'only_matching': True, | |
31 | }] | |
32 | ||
33 | def _real_extract(self, url): | |
34 | video_id = self._match_id(url) | |
35 | ||
36 | if '/video.php' in url: | |
37 | qs = parse_qs(url) | |
38 | url = 'https://gameclips.io/%s/%s' % (qs['gamertag'][0], qs['vid'][0]) | |
39 | ||
40 | webpage = self._download_webpage(url, video_id) | |
41 | info = self._parse_html5_media_entries(url, webpage, video_id)[0] | |
42 | ||
43 | title = self._html_search_meta(['og:title', 'twitter:title'], webpage) | |
44 | upload_date = None | |
45 | mobj = re.search( | |
46 | r'>Recorded: (\d{2})-(Jan|Feb|Mar|Apr|May|Ju[nl]|Aug|Sep|Oct|Nov|Dec)-(\d{4})', | |
47 | webpage) | |
48 | if mobj: | |
49 | upload_date = '%s%.2d%s' % (mobj.group(3), month_by_abbreviation(mobj.group(2)), mobj.group(1)) | |
50 | filesize = parse_filesize(self._html_search_regex( | |
51 | r'>Size: ([^<]+)<', webpage, 'file size', fatal=False)) | |
52 | duration = int_or_none(self._html_search_regex( | |
53 | r'>Duration: (\d+) Seconds<', webpage, 'duration', fatal=False)) | |
54 | view_count = int_or_none(self._html_search_regex( | |
55 | r'>Views: (\d+)<', webpage, 'view count', fatal=False)) | |
56 | ||
57 | info.update({ | |
58 | 'id': video_id, | |
59 | 'title': title, | |
60 | 'upload_date': upload_date, | |
61 | 'filesize_approx': filesize, | |
62 | 'duration': duration, | |
63 | 'view_count': view_count, | |
64 | }) | |
65 | return info |