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