]>
Commit | Line | Data |
---|---|---|
1 | from .common import InfoExtractor | |
2 | from ..utils import ( | |
3 | int_or_none, | |
4 | parse_iso8601, | |
5 | ) | |
6 | ||
7 | ||
8 | class RockstarGamesIE(InfoExtractor): | |
9 | _VALID_URL = r'https?://(?:www\.)?rockstargames\.com/videos(?:/video/|#?/?\?.*\bvideo=)(?P<id>\d+)' | |
10 | _TESTS = [{ | |
11 | 'url': 'https://www.rockstargames.com/videos/video/11544/', | |
12 | 'md5': '03b5caa6e357a4bd50e3143fc03e5733', | |
13 | 'info_dict': { | |
14 | 'id': '11544', | |
15 | 'ext': 'mp4', | |
16 | 'title': 'Further Adventures in Finance and Felony Trailer', | |
17 | 'description': 'md5:6d31f55f30cb101b5476c4a379e324a3', | |
18 | 'thumbnail': r're:^https?://.*\.jpg$', | |
19 | 'timestamp': 1464876000, | |
20 | 'upload_date': '20160602', | |
21 | } | |
22 | }, { | |
23 | 'url': 'http://www.rockstargames.com/videos#/?video=48', | |
24 | 'only_matching': True, | |
25 | }] | |
26 | ||
27 | def _real_extract(self, url): | |
28 | video_id = self._match_id(url) | |
29 | ||
30 | video = self._download_json( | |
31 | 'https://www.rockstargames.com/videoplayer/videos/get-video.json', | |
32 | video_id, query={ | |
33 | 'id': video_id, | |
34 | 'locale': 'en_us', | |
35 | })['video'] | |
36 | ||
37 | title = video['title'] | |
38 | ||
39 | formats = [] | |
40 | for video in video['files_processed']['video/mp4']: | |
41 | if not video.get('src'): | |
42 | continue | |
43 | resolution = video.get('resolution') | |
44 | height = int_or_none(self._search_regex( | |
45 | r'^(\d+)[pP]$', resolution or '', 'height', default=None)) | |
46 | formats.append({ | |
47 | 'url': self._proto_relative_url(video['src']), | |
48 | 'format_id': resolution, | |
49 | 'height': height, | |
50 | }) | |
51 | ||
52 | if not formats: | |
53 | youtube_id = video.get('youtube_id') | |
54 | if youtube_id: | |
55 | return self.url_result(youtube_id, 'Youtube') | |
56 | ||
57 | return { | |
58 | 'id': video_id, | |
59 | 'title': title, | |
60 | 'description': video.get('description'), | |
61 | 'thumbnail': self._proto_relative_url(video.get('screencap')), | |
62 | 'timestamp': parse_iso8601(video.get('created')), | |
63 | 'formats': formats, | |
64 | } |