mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-06-28 13:45:55 +00:00
Compare commits
No commits in common. "2fd6fc11c48b58debcf23de3914103906d9b0ddb" and "27a4a3cee7d382f3bbc3d43b9f085fb54633a154" have entirely different histories.
2fd6fc11c4
...
27a4a3cee7
@ -6,26 +6,13 @@ from ..utils import (
|
|||||||
float_or_none,
|
float_or_none,
|
||||||
orderedSet,
|
orderedSet,
|
||||||
str_or_none,
|
str_or_none,
|
||||||
|
try_get,
|
||||||
)
|
)
|
||||||
from ..utils.traversal import subs_list_to_dict, traverse_obj
|
|
||||||
|
|
||||||
|
|
||||||
class GloboIE(InfoExtractor):
|
class GloboIE(InfoExtractor):
|
||||||
_VALID_URL = r'(?:globo:|https?://.+?\.globo\.com/(?:[^/]+/))(?P<id>\d{7,})'
|
_VALID_URL = r'(?:globo:|https?://.+?\.globo\.com/(?:[^/]+/)*(?:v/(?:[^/]+/)?|videos/))(?P<id>\d{7,})'
|
||||||
_NETRC_MACHINE = 'globo'
|
_NETRC_MACHINE = 'globo'
|
||||||
_VIDEO_VIEW = '''
|
|
||||||
query getVideoView($videoId: ID!) {
|
|
||||||
video(id: $videoId) {
|
|
||||||
duration
|
|
||||||
description
|
|
||||||
headline
|
|
||||||
title {
|
|
||||||
originProgramId
|
|
||||||
headline
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
'''
|
|
||||||
_TESTS = [{
|
_TESTS = [{
|
||||||
'url': 'https://globoplay.globo.com/v/3607726/',
|
'url': 'https://globoplay.globo.com/v/3607726/',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
@ -60,25 +47,30 @@ class GloboIE(InfoExtractor):
|
|||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
|
||||||
info = self._download_json(
|
video_view = '''
|
||||||
'https://cloud-jarvis.globo.com/graphql', video_id,
|
query getVideoView($videoId: ID!) {
|
||||||
query={
|
video(id: $videoId) {
|
||||||
'operationName': 'getVideoView',
|
duration
|
||||||
'variables': f'{{"videoId":{video_id}}}',
|
description
|
||||||
'query': self._VIDEO_VIEW,
|
headline
|
||||||
}, headers={
|
title {
|
||||||
'content-type': 'application/json',
|
originProgramId
|
||||||
'x-platform-id': 'web',
|
headline
|
||||||
'x-device-id': 'desktop',
|
}
|
||||||
'x-client-version': '2024.12-5',
|
}
|
||||||
})['data']['video']
|
}
|
||||||
|
'''
|
||||||
|
video = self._download_json(
|
||||||
|
f'https://cloud-jarvis.globo.com/graphql?operationName=getVideoView&variables=%7B"videoId":"{video_id}"%7D&query={video_view}', video_id,
|
||||||
|
headers={'content-type': 'application/json', 'x-platform-id': 'web', 'x-device-id': 'desktop', 'x-client-version': '2024.12-5'})['data']['video']
|
||||||
|
title = video['headline']
|
||||||
|
uploader = video['title'].get('headline')
|
||||||
|
uploader_id = str_or_none(video['title'].get('originProgramId'))
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
video = self._download_json(
|
security = self._download_json(
|
||||||
'https://playback.video.globo.com/v4/video-session', video_id,
|
'https://playback.video.globo.com/v4/video-session', video_id, f'Downloading resource info for {video_id}',
|
||||||
f'Downloading resource info for {video_id}',
|
headers={'Content-Type': 'application/json'}, data=json.dumps({
|
||||||
headers={'Content-Type': 'application/json'},
|
|
||||||
data=json.dumps({
|
|
||||||
'player_type': 'desktop',
|
'player_type': 'desktop',
|
||||||
'video_id': video_id,
|
'video_id': video_id,
|
||||||
'quality': 'max',
|
'quality': 'max',
|
||||||
@ -87,26 +79,31 @@ class GloboIE(InfoExtractor):
|
|||||||
'tz': '-03:00',
|
'tz': '-03:00',
|
||||||
'version': 1,
|
'version': 1,
|
||||||
}).encode())
|
}).encode())
|
||||||
|
|
||||||
if traverse_obj(video, ('resource', 'drm_protection_enabled', {bool})):
|
if traverse_obj(video, ('resource', 'drm_protection_enabled', {bool})):
|
||||||
self.report_drm(video_id)
|
self.report_drm(video_id)
|
||||||
|
|
||||||
main_source = video['sources'][0]
|
main_resource = security['sources'][0]
|
||||||
|
resource_url = main_resource['url']
|
||||||
|
|
||||||
formats, subtitles = self._extract_m3u8_formats_and_subtitles(
|
fmts, subtitles = self._extract_m3u8_formats_and_subtitles(
|
||||||
main_source['url'], video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
|
resource_url, video_id, 'mp4', entry_protocol='m3u8_native', m3u8_id='hls', fatal=False)
|
||||||
self._merge_subtitles(traverse_obj(main_source, ('text', ..., {
|
formats.extend(fmts)
|
||||||
'url': ('subtitle', 'srt', 'url', {str}),
|
|
||||||
}, all, {subs_list_to_dict(lang='por')})))
|
subs = try_get(security, lambda x: x['sources'][0]['text']) or {}
|
||||||
|
for sub in subs.items():
|
||||||
|
if sub['subtitle']:
|
||||||
|
subtitles.setdefault(sub or 'por', []).append({
|
||||||
|
'url': sub['subtitle']['srt'].get('url'),
|
||||||
|
})
|
||||||
|
|
||||||
|
duration = float_or_none(video.get('duration'), 1000)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
**traverse_obj(info, {
|
'title': title,
|
||||||
'title': ('headline', {str}),
|
'duration': duration,
|
||||||
'duration': ('duration', {float_or_none(scale=1000)}),
|
'uploader': uploader,
|
||||||
'uploader': ('title', 'headline', {str}),
|
'uploader_id': uploader_id,
|
||||||
'uploader_id': ('title', 'originProgramId', {str_or_none}),
|
|
||||||
}),
|
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'subtitles': subtitles,
|
'subtitles': subtitles,
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user