[cleanup] Make more playlist entries lazy (#11763)
[yt-dlp.git] / yt_dlp / extractor / rockstargames.py
blob02abd482c8d04fb4b65821d37fbdb9002d01b42b
1 from .common import InfoExtractor
2 from ..utils import (
3 int_or_none,
4 parse_iso8601,
8 class RockstarGamesIE(InfoExtractor):
9 _WORKING = False
10 _VALID_URL = r'https?://(?:www\.)?rockstargames\.com/videos(?:/video/|#?/?\?.*\bvideo=)(?P<id>\d+)'
11 _TESTS = [{
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',
18 'description': 'md5:6d31f55f30cb101b5476c4a379e324a3',
19 'thumbnail': r're:^https?://.*\.jpg$',
20 'timestamp': 1464876000,
21 'upload_date': '20160602',
23 }, {
24 'url': 'http://www.rockstargames.com/videos#/?video=48',
25 'only_matching': True,
28 def _real_extract(self, url):
29 video_id = self._match_id(url)
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']
38 title = video['title']
40 formats = []
41 for v in video['files_processed']['video/mp4']:
42 if not v.get('src'):
43 continue
44 resolution = v.get('resolution')
45 height = int_or_none(self._search_regex(
46 r'^(\d+)[pP]$', resolution or '', 'height', default=None))
47 formats.append({
48 'url': self._proto_relative_url(v['src']),
49 'format_id': resolution,
50 'height': height,
53 if not formats:
54 youtube_id = video.get('youtube_id')
55 if youtube_id:
56 return self.url_result(youtube_id, 'Youtube')
58 return {
59 'id': video_id,
60 'title': title,
61 'description': video.get('description'),
62 'thumbnail': self._proto_relative_url(video.get('screencap')),
63 'timestamp': parse_iso8601(video.get('created')),
64 'formats': formats,