mirror of https://github.com/yt-dlp/yt-dlp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
2.1 KiB
Python
67 lines
2.1 KiB
Python
9 years ago
|
from .common import InfoExtractor
|
||
|
from ..utils import (
|
||
9 years ago
|
int_or_none,
|
||
|
parse_iso8601,
|
||
9 years ago
|
)
|
||
|
|
||
|
|
||
|
class RockstarGamesIE(InfoExtractor):
|
||
9 years ago
|
_VALID_URL = r'https?://(?:www\.)?rockstargames\.com/videos(?:/video/|#?/?\?.*\bvideo=)(?P<id>\d+)'
|
||
|
_TESTS = [{
|
||
9 years ago
|
'url': 'https://www.rockstargames.com/videos/video/11544/',
|
||
|
'md5': '03b5caa6e357a4bd50e3143fc03e5733',
|
||
|
'info_dict': {
|
||
|
'id': '11544',
|
||
|
'ext': 'mp4',
|
||
|
'title': 'Further Adventures in Finance and Felony Trailer',
|
||
|
'description': 'md5:6d31f55f30cb101b5476c4a379e324a3',
|
||
8 years ago
|
'thumbnail': r're:^https?://.*\.jpg$',
|
||
9 years ago
|
'timestamp': 1464876000,
|
||
9 years ago
|
'upload_date': '20160602',
|
||
|
}
|
||
9 years ago
|
}, {
|
||
|
'url': 'http://www.rockstargames.com/videos#/?video=48',
|
||
|
'only_matching': True,
|
||
|
}]
|
||
9 years ago
|
|
||
|
def _real_extract(self, url):
|
||
|
video_id = self._match_id(url)
|
||
|
|
||
9 years ago
|
video = self._download_json(
|
||
|
'https://www.rockstargames.com/videoplayer/videos/get-video.json',
|
||
|
video_id, query={
|
||
|
'id': video_id,
|
||
|
'locale': 'en_us',
|
||
|
})['video']
|
||
|
|
||
|
title = video['title']
|
||
9 years ago
|
|
||
9 years ago
|
formats = []
|
||
|
for video in video['files_processed']['video/mp4']:
|
||
9 years ago
|
if not video.get('src'):
|
||
|
continue
|
||
9 years ago
|
resolution = video.get('resolution')
|
||
|
height = int_or_none(self._search_regex(
|
||
|
r'^(\d+)[pP]$', resolution or '', 'height', default=None))
|
||
9 years ago
|
formats.append({
|
||
|
'url': self._proto_relative_url(video['src']),
|
||
9 years ago
|
'format_id': resolution,
|
||
|
'height': height,
|
||
9 years ago
|
})
|
||
9 years ago
|
|
||
|
if not formats:
|
||
|
youtube_id = video.get('youtube_id')
|
||
|
if youtube_id:
|
||
|
return self.url_result(youtube_id, 'Youtube')
|
||
|
|
||
9 years ago
|
self._sort_formats(formats)
|
||
|
|
||
|
return {
|
||
|
'id': video_id,
|
||
9 years ago
|
'title': title,
|
||
|
'description': video.get('description'),
|
||
|
'thumbnail': self._proto_relative_url(video.get('screencap')),
|
||
|
'timestamp': parse_iso8601(video.get('created')),
|
||
9 years ago
|
'formats': formats,
|
||
|
}
|