mirror of https://github.com/yt-dlp/yt-dlp.git
Compare commits
8 Commits
061669304f
...
86257d48f7
Author | SHA1 | Date |
---|---|---|
danilovsergei | 86257d48f7 | |
bashonly | 5904853ae5 | |
Chris Caruso | c8bf48f3a8 | |
The-MAGI | 351368cb9a | |
sergeidanilov | 523c7e1d44 | |
sergeidanilov | fc46f24dc5 | |
danilovsergei | c29caf1739 | |
danilovsergei | bb9ec9a24d |
|
@ -151,7 +151,7 @@ def _real_extract(self, url):
|
|||
|
||||
class CBCPlayerIE(InfoExtractor):
|
||||
IE_NAME = 'cbc.ca:player'
|
||||
_VALID_URL = r'(?:cbcplayer:|https?://(?:www\.)?cbc\.ca/(?:player/play/|i/caffeine/syndicate/\?mediaId=))(?P<id>(?:\d\.)?\d+)'
|
||||
_VALID_URL = r'(?:cbcplayer:|https?://(?:www\.)?cbc\.ca/(?:player/play/(?:video/)?|i/caffeine/syndicate/\?mediaId=))(?P<id>(?:\d\.)?\d+)'
|
||||
_TESTS = [{
|
||||
'url': 'http://www.cbc.ca/player/play/2683190193',
|
||||
'md5': '64d25f841ddf4ddb28a235338af32e2c',
|
||||
|
@ -277,6 +277,28 @@ class CBCPlayerIE(InfoExtractor):
|
|||
'location': 'Canada',
|
||||
'media_type': 'Full Program',
|
||||
},
|
||||
}, {
|
||||
'url': 'https://www.cbc.ca/player/play/video/1.7194274',
|
||||
'md5': '188b96cf6bdcb2540e178a6caa957128',
|
||||
'info_dict': {
|
||||
'id': '2334524995812',
|
||||
'ext': 'mp4',
|
||||
'title': '#TheMoment a rare white spirit moose was spotted in Alberta',
|
||||
'description': 'md5:18ae269a2d0265c5b0bbe4b2e1ac61a3',
|
||||
'timestamp': 1714788791,
|
||||
'duration': 77.678,
|
||||
'subtitles': {'eng': [{'ext': 'vtt', 'protocol': 'm3u8_native'}]},
|
||||
'thumbnail': 'https://thumbnails.cbc.ca/maven_legacy/thumbnails/201/543/THE_MOMENT.jpg',
|
||||
'uploader': 'CBCC-NEW',
|
||||
'chapters': 'count:0',
|
||||
'upload_date': '20240504',
|
||||
'categories': 'count:3',
|
||||
'series': 'The National',
|
||||
'tags': 'count:15',
|
||||
'creators': ['encoder'],
|
||||
'location': 'Canada',
|
||||
'media_type': 'Excerpt',
|
||||
},
|
||||
}, {
|
||||
'url': 'cbcplayer:1.7159484',
|
||||
'only_matching': True,
|
||||
|
|
|
@ -53,15 +53,19 @@ def _set_auth_info(self, response):
|
|||
CrunchyrollBaseIE._AUTH_EXPIRY = time_seconds(seconds=traverse_obj(response, ('expires_in', {float_or_none}), default=300) - 10)
|
||||
|
||||
def _request_token(self, headers, data, note='Requesting token', errnote='Failed to request token'):
|
||||
try: # TODO: Add impersonation support here
|
||||
try:
|
||||
return self._download_json(
|
||||
f'{self._BASE_URL}/auth/v1/token', None, note=note, errnote=errnote,
|
||||
headers=headers, data=urlencode_postdata(data))
|
||||
headers=headers, data=urlencode_postdata(data), impersonate=True)
|
||||
except ExtractorError as error:
|
||||
if not isinstance(error.cause, HTTPError) or error.cause.status != 403:
|
||||
raise
|
||||
if target := error.cause.response.extensions.get('impersonate'):
|
||||
raise ExtractorError(f'Got HTTP Error 403 when using impersonate target "{target}"')
|
||||
raise ExtractorError(
|
||||
'Request blocked by Cloudflare; navigate to Crunchyroll in your browser, '
|
||||
'Request blocked by Cloudflare. '
|
||||
'Install the required impersonation dependency if possible, '
|
||||
'or else navigate to Crunchyroll in your browser, '
|
||||
'then pass the fresh cookies (with --cookies-from-browser or --cookies) '
|
||||
'and your browser\'s User-Agent (with --user-agent)', expected=True)
|
||||
|
||||
|
|
|
@ -72,15 +72,15 @@ class YouPornIE(InfoExtractor):
|
|||
'id': '16290308',
|
||||
'age_limit': 18,
|
||||
'categories': [],
|
||||
'description': 'md5:00ea70f642f431c379763c17c2f396bc',
|
||||
'description': str, # TODO: detect/remove SEO spam description in ytdl backport
|
||||
'display_id': 'tinderspecial-trailer1',
|
||||
'duration': 298.0,
|
||||
'ext': 'mp4',
|
||||
'upload_date': '20201123',
|
||||
'uploader': 'Ersties',
|
||||
'tags': [],
|
||||
'thumbnail': 'https://fi1.ypncdn.com/202011/23/16290308/original/8/tinderspecial-trailer1-8(m=eaAaaEPbaaaa).jpg',
|
||||
'timestamp': 1606089600,
|
||||
'thumbnail': r're:https://.+\.jpg',
|
||||
'timestamp': 1606147564,
|
||||
'title': 'Tinder In Real Life',
|
||||
'view_count': int,
|
||||
}
|
||||
|
@ -88,11 +88,17 @@ class YouPornIE(InfoExtractor):
|
|||
|
||||
def _real_extract(self, url):
|
||||
video_id, display_id = self._match_valid_url(url).group('id', 'display_id')
|
||||
definitions = self._download_json(
|
||||
f'https://www.youporn.com/api/video/media_definitions/{video_id}/', display_id or video_id)
|
||||
self._set_cookie('.youporn.com', 'age_verified', '1')
|
||||
webpage = self._download_webpage(f'https://www.youporn.com/watch/{video_id}', video_id)
|
||||
definitions = self._search_json(r'\bplayervars\s*:', webpage, 'player vars', video_id)['mediaDefinitions']
|
||||
|
||||
def get_format_data(data, f):
|
||||
return traverse_obj(data, lambda _, v: v['format'] == f and url_or_none(v['videoUrl']))
|
||||
def get_format_data(data, stream_type):
|
||||
info_url = traverse_obj(data, (lambda _, v: v['format'] == stream_type, 'videoUrl', {url_or_none}, any))
|
||||
if not info_url:
|
||||
return []
|
||||
return traverse_obj(
|
||||
self._download_json(info_url, video_id, f'Downloading {stream_type} info JSON', fatal=False),
|
||||
lambda _, v: v['format'] == stream_type and url_or_none(v['videoUrl']))
|
||||
|
||||
formats = []
|
||||
# Try to extract only the actual master m3u8 first, avoiding the duplicate single resolution "master" m3u8s
|
||||
|
@ -123,10 +129,6 @@ def get_format_data(data, f):
|
|||
f['height'] = height
|
||||
formats.append(f)
|
||||
|
||||
webpage = self._download_webpage(
|
||||
'http://www.youporn.com/watch/%s' % video_id, display_id,
|
||||
headers={'Cookie': 'age_verified=1'})
|
||||
|
||||
title = self._html_search_regex(
|
||||
r'(?s)<div[^>]+class=["\']watchVideoTitle[^>]+>(.+?)</div>',
|
||||
webpage, 'title', default=None) or self._og_search_title(
|
||||
|
|
|
@ -1049,6 +1049,34 @@ def _ffmpeg_args_for_chapter(self, number, chapter, info):
|
|||
['-ss', str(chapter['start_time']),
|
||||
'-t', str(chapter['end_time'] - chapter['start_time'])])
|
||||
|
||||
# Extends opts with chapter specific metadata for the supported formats.
|
||||
#
|
||||
# Tested and supported on opus, m4a, webm and mp4.
|
||||
def _set_metadata_arg(self, opts, ext, key, value):
|
||||
if ext == 'opus':
|
||||
# opus file requires a stream to keep title, artist etc metadata.
|
||||
# FFmpegMetadataPP already set metadata and created that stream.
|
||||
# Futher metadata updates should be set on the stream(:s)
|
||||
# -metadata will do nothing and needs to be -metadata:s
|
||||
opts.extend(['-metadata:s', f'{key}={value}'])
|
||||
elif ext in ['m4a', 'webm', 'mp4']:
|
||||
opts.extend(['-metadata', f'{key}={value}'])
|
||||
|
||||
# FFmpeg adds metadata about all chapters from parent file to all split m4a files.
|
||||
# This is incorrect since there must be only single chapter in each file after split.
|
||||
# Such behavior confuses players who think multiple chapters present
|
||||
def _set_out_opts(self, ext, chapter_title, track_number):
|
||||
out_opts = [*self.stream_copy_opts()]
|
||||
out_opts.extend(['-map_metadata', '0'])
|
||||
# exclude chapters metadata but keep everything else
|
||||
out_opts.extend(['-map_chapters', '-1'])
|
||||
|
||||
# replace global title with chapter specific title in split files
|
||||
if chapter_title:
|
||||
self._set_metadata_arg(out_opts, ext, "title", chapter_title)
|
||||
self._set_metadata_arg(out_opts, ext, "track", track_number)
|
||||
return out_opts
|
||||
|
||||
@PostProcessor._restrict_to(images=False)
|
||||
def run(self, info):
|
||||
self._fixup_chapters(info)
|
||||
|
@ -1063,7 +1091,8 @@ def run(self, info):
|
|||
self.to_screen('Splitting video by chapters; %d chapters found' % len(chapters))
|
||||
for idx, chapter in enumerate(chapters):
|
||||
destination, opts = self._ffmpeg_args_for_chapter(idx + 1, chapter, info)
|
||||
self.real_run_ffmpeg([(in_file, opts)], [(destination, self.stream_copy_opts())])
|
||||
out_file_opts = self._set_out_opts(info['ext'], chapter.get('title', ''), str(idx + 1))
|
||||
self.real_run_ffmpeg([(in_file, opts)], [(destination, out_file_opts)])
|
||||
if in_file != info['filepath']:
|
||||
self._delete_downloaded_files(in_file, msg=None)
|
||||
return [], info
|
||||
|
|
Loading…
Reference in New Issue