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