aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2016-06-14 01:11:24 +0700
committerSergey M․ <dstftw@gmail.com>2016-06-14 01:11:24 +0700
commit16b6bd01d238c2c58e3ac7ba91c706261d5810e8 (patch)
tree44b14b22ad141d5f543600b4265cf7f133ca3cc3
parent14d0f4e0f3e1b6a467b6302eb60644535aff4292 (diff)
downloadyoutube-dl-16b6bd01d238c2c58e3ac7ba91c706261d5810e8.tar.xz
[rockstargames] Improve and add Youtube fallback (Closes #9737)
-rw-r--r--youtube_dl/extractor/rockstargames.py55
1 files changed, 35 insertions, 20 deletions
diff --git a/youtube_dl/extractor/rockstargames.py b/youtube_dl/extractor/rockstargames.py
index 427ab153a..48128e219 100644
--- a/youtube_dl/extractor/rockstargames.py
+++ b/youtube_dl/extractor/rockstargames.py
@@ -3,52 +3,67 @@ from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
- qualities,
- parse_iso8601
+ int_or_none,
+ parse_iso8601,
)
class RockstarGamesIE(InfoExtractor):
- _VALID_URL = r'https?://(?:www\.)?rockstargames\.com/videos/video/(?P<id>[0-9]+)'
- _TEST = {
+ _VALID_URL = r'https?://(?:www\.)?rockstargames\.com/videos(?:/video/|#?/?\?.*\bvideo=)(?P<id>\d+)'
+ _TESTS = [{
'url': 'https://www.rockstargames.com/videos/video/11544/',
'md5': '03b5caa6e357a4bd50e3143fc03e5733',
'info_dict': {
'id': '11544',
'ext': 'mp4',
'title': 'Further Adventures in Finance and Felony Trailer',
- 'thumbnail': 're:^https?://.*\.jpg$',
'description': 'md5:6d31f55f30cb101b5476c4a379e324a3',
+ 'thumbnail': 're:^https?://.*\.jpg$',
+ 'timestamp': 1464876000,
'upload_date': '20160602',
- 'timestamp': 1464876000
}
- }
+ }, {
+ 'url': 'http://www.rockstargames.com/videos#/?video=48',
+ 'only_matching': True,
+ }]
def _real_extract(self, url):
video_id = self._match_id(url)
- json_data = self._download_json(
- 'https://www.rockstargames.com/videoplayer/videos/get-video.json?id=%s&locale=en_us' % video_id,
- video_id
- )['video']
- formats = []
+ 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']
- for video in json_data['files_processed']['video/mp4']:
+ formats = []
+ for video in video['files_processed']['video/mp4']:
if not video.get('src'):
continue
- height = video.get('resolution', '').replace('p', '')
-
+ resolution = video.get('resolution')
+ height = int_or_none(self._search_regex(
+ r'^(\d+)[pP]$', resolution or '', 'height', default=None))
formats.append({
'url': self._proto_relative_url(video['src']),
- 'height': int(height) if height.isdigit() else -1,
+ 'format_id': resolution,
+ 'height': height,
})
+
+ if not formats:
+ youtube_id = video.get('youtube_id')
+ if youtube_id:
+ return self.url_result(youtube_id, 'Youtube')
+
self._sort_formats(formats)
return {
'id': video_id,
- 'title': json_data['title'],
- 'description': json_data.get('description'),
+ 'title': title,
+ 'description': video.get('description'),
+ 'thumbnail': self._proto_relative_url(video.get('screencap')),
+ 'timestamp': parse_iso8601(video.get('created')),
'formats': formats,
- 'thumbnail': self._proto_relative_url(json_data.get('screencap')),
- 'timestamp': parse_iso8601(json_data.get('created'))
}