mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-06-15 10:52:57 +00:00
Compare commits
9 Commits
2026.06.09
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b23046bbc8 | ||
|
|
9055188250 | ||
|
|
b05b408d10 | ||
|
|
a2483524fb | ||
|
|
707537a039 | ||
|
|
7937a139cf | ||
|
|
cb309b3293 | ||
|
|
e47691215f | ||
|
|
a541df1ea5 |
@@ -395,6 +395,7 @@ banned-from = [
|
||||
"yt_dlp.utils.bytes_to_intlist".msg = "Use `list` instead."
|
||||
"yt_dlp.utils.intlist_to_bytes".msg = "Use `bytes` instead."
|
||||
"yt_dlp.utils.jwt_encode_hs256".msg = "Use `yt_dlp.utils.jwt_encode` instead."
|
||||
"yt_dlp.utils.make_dir".msg = "Use `yt_dlp.utils.make_parent_dirs` instead."
|
||||
"yt_dlp.utils.decodeArgument".msg = "Do not use"
|
||||
"yt_dlp.utils.decodeFilename".msg = "Do not use"
|
||||
"yt_dlp.utils.encodeFilename".msg = "Do not use"
|
||||
|
||||
@@ -327,6 +327,12 @@ class TestUtil(unittest.TestCase):
|
||||
with self.assertRaises(_UnsafeExtensionError):
|
||||
prepend_extension('abc.unexpected_ext', ext, 'ext')
|
||||
|
||||
# Test allow-unsafe-ext compat option
|
||||
_UnsafeExtensionError._enabled = False
|
||||
self.assertEqual(prepend_extension('abc.ext', 'un/safe'), 'abc.un/safe.ext')
|
||||
# Re-enable sanitization for other tests
|
||||
_UnsafeExtensionError._enabled = True
|
||||
|
||||
def test_replace_extension(self):
|
||||
self.assertEqual(replace_extension('abc.ext', 'temp'), 'abc.temp')
|
||||
self.assertEqual(replace_extension('abc.ext', 'temp', 'ext'), 'abc.temp')
|
||||
@@ -345,6 +351,12 @@ class TestUtil(unittest.TestCase):
|
||||
with self.assertRaises(_UnsafeExtensionError):
|
||||
replace_extension('abc.unexpected_ext', ext, 'ext')
|
||||
|
||||
# Test allow-unsafe-ext compat option
|
||||
_UnsafeExtensionError._enabled = False
|
||||
self.assertEqual(replace_extension('abc.ext', 'bin'), 'abc.bin')
|
||||
# Re-enable sanitization for other tests
|
||||
_UnsafeExtensionError._enabled = True
|
||||
|
||||
def test_subtitles_filename(self):
|
||||
self.assertEqual(subtitles_filename('abc.ext', 'en', 'vtt'), 'abc.en.vtt')
|
||||
self.assertEqual(subtitles_filename('abc.ext', 'en', 'vtt', 'ext'), 'abc.en.vtt')
|
||||
@@ -2160,6 +2172,10 @@ Line 1
|
||||
headers6 = HTTPHeaderDict(a=1, b=2)
|
||||
self.assertEqual(pickle.loads(pickle.dumps(headers6)), headers6)
|
||||
|
||||
headers7 = HTTPHeaderDict()
|
||||
headers7 |= {'X-dlp': 'data'}
|
||||
self.assertEqual(headers7.sensitive(), {'X-dlp': 'data'})
|
||||
|
||||
def test_extract_basic_auth(self):
|
||||
assert extract_basic_auth('http://:foo.bar') == ('http://:foo.bar', None)
|
||||
assert extract_basic_auth('http://foo.bar') == ('http://foo.bar', None)
|
||||
|
||||
@@ -139,7 +139,7 @@ from .utils import (
|
||||
join_nonempty,
|
||||
locked_file,
|
||||
make_archive_id,
|
||||
make_dir,
|
||||
make_parent_dirs,
|
||||
number_of_digits,
|
||||
orderedSet,
|
||||
orderedSet_from_options,
|
||||
@@ -2036,7 +2036,12 @@ class YoutubeDL:
|
||||
raise Exception(f'Invalid result type: {result_type}')
|
||||
|
||||
def _ensure_dir_exists(self, path):
|
||||
return make_dir(path, self.report_error)
|
||||
try:
|
||||
make_parent_dirs(path)
|
||||
return True
|
||||
except OSError as e:
|
||||
self.report_error(f'Unable to create directory: {e}')
|
||||
return False
|
||||
|
||||
@staticmethod
|
||||
def _playlist_infodict(ie_result, strict=False, **kwargs):
|
||||
|
||||
@@ -619,7 +619,7 @@ def validate_options(opts):
|
||||
warnings.append(
|
||||
'Using allow-unsafe-ext opens you up to potential attacks. '
|
||||
'Use with great care!')
|
||||
_UnsafeExtensionError.sanitize_extension = lambda x, prepend=False: x
|
||||
_UnsafeExtensionError._enabled = False
|
||||
|
||||
return warnings, deprecation_warnings
|
||||
|
||||
|
||||
@@ -209,7 +209,7 @@ class CurlFD(ExternalFD):
|
||||
return False
|
||||
|
||||
cls.exe = path
|
||||
cls._curl_version = version_tuple(parts[1])
|
||||
cls._curl_version = version_tuple(parts[1], lenient=True)
|
||||
return path
|
||||
|
||||
def _make_cmd(self, tmpfilename, info_dict):
|
||||
|
||||
@@ -421,6 +421,7 @@ class BandcampWeeklyIE(BandcampIE): # XXX: Do not subclass from concrete IE
|
||||
'id': '224',
|
||||
'ext': 'mp3',
|
||||
'title': 'Bandcamp Weekly, 2017-04-04',
|
||||
'episode': 'Magic Moments',
|
||||
'description': 'md5:5d48150916e8e02d030623a48512c874',
|
||||
'thumbnail': 'https://f4.bcbits.com/img/9982549_0.jpg',
|
||||
'series': 'Bandcamp Weekly',
|
||||
@@ -440,22 +441,23 @@ class BandcampWeeklyIE(BandcampIE): # XXX: Do not subclass from concrete IE
|
||||
def _real_extract(self, url):
|
||||
show_id = self._match_id(url)
|
||||
show_data = self._download_json(
|
||||
'https://bandcamp.com/api/bcradio_api/1/get_show',
|
||||
'https://bandcamp.com/api/player/2/player_data_web',
|
||||
show_id, 'Downloading radio show JSON',
|
||||
data=json.dumps({'id': show_id}).encode(),
|
||||
headers={'Content-Type': 'application/json'})
|
||||
data=json.dumps({'item_id': int(show_id), 'item_type': 'radio'}).encode(),
|
||||
headers={'Content-Type': 'application/json'})['tracklist']
|
||||
audio_data = show_data['compiledTrack']
|
||||
|
||||
stream_url = audio_data['streamUrl']
|
||||
format_id = traverse_obj(stream_url, ({parse_qs}, 'enc', -1))
|
||||
encoding, _, bitrate_str = (format_id or '').partition('-')
|
||||
|
||||
series_title = show_data.get('title')
|
||||
series_title = show_data.get('subtitle')
|
||||
release_timestamp = unified_timestamp(show_data.get('date'))
|
||||
|
||||
return {
|
||||
'id': show_id,
|
||||
'episode_id': show_id,
|
||||
'episode': show_data.get('title'),
|
||||
'title': join_nonempty(series_title, strftime_or_none(release_timestamp, '%Y-%m-%d'), delim=', '),
|
||||
'series': series_title,
|
||||
'thumbnail': format_field(show_data, 'imageId', 'https://f4.bcbits.com/img/%s_0.jpg', default=None),
|
||||
|
||||
@@ -65,8 +65,9 @@ class PatreonBaseIE(InfoExtractor):
|
||||
|
||||
class PatreonIE(PatreonBaseIE):
|
||||
IE_NAME = 'patreon'
|
||||
_VALID_URL = r'https?://(?:www\.)?patreon\.com/(?:creation\?hid=|posts/(?:[\w-]+-)?)(?P<id>\d+)'
|
||||
_VALID_URL = r'https?://(?:www\.)?patreon\.com/(?:creation\?hid=|(?:[^/?#]+/)?posts/(?:[\w-]+-)?)(?P<id>\d+)'
|
||||
_TESTS = [{
|
||||
# FIXME: Fails due to no description extracted
|
||||
'url': 'http://www.patreon.com/creation?hid=743933',
|
||||
'md5': 'e25505eec1053a6e6813b8ed369875cc',
|
||||
'info_dict': {
|
||||
@@ -107,17 +108,17 @@ class PatreonIE(PatreonBaseIE):
|
||||
'id': 'SU4fj_aEMVw',
|
||||
'ext': 'mp4',
|
||||
'title': 'I\'m on Patreon!',
|
||||
'uploader': 'TraciJHines',
|
||||
'uploader': 'Traci Oden',
|
||||
'thumbnail': 're:^https?://.*$',
|
||||
'upload_date': '20150211',
|
||||
'description': 'md5:8af6425f50bd46fbf29f3db0fc3a8364',
|
||||
'uploader_id': '@TraciHinesMusic',
|
||||
'uploader_id': '@TraciOden',
|
||||
'categories': ['Entertainment'],
|
||||
'duration': 282,
|
||||
'view_count': int,
|
||||
'tags': 'count:39',
|
||||
'age_limit': 0,
|
||||
'channel': 'TraciJHines',
|
||||
'channel': 'Traci Oden',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCGLim4T2loE5rwCMdpCIPVg',
|
||||
'live_status': 'not_live',
|
||||
'like_count': int,
|
||||
@@ -125,7 +126,7 @@ class PatreonIE(PatreonBaseIE):
|
||||
'availability': 'public',
|
||||
'channel_follower_count': int,
|
||||
'playable_in_embed': True,
|
||||
'uploader_url': 'https://www.youtube.com/@TraciHinesMusic',
|
||||
'uploader_url': 'https://www.youtube.com/@TraciOden',
|
||||
'comment_count': int,
|
||||
'channel_is_verified': True,
|
||||
'chapters': 'count:4',
|
||||
@@ -157,6 +158,7 @@ class PatreonIE(PatreonBaseIE):
|
||||
},
|
||||
'skip': 'Patron-only content',
|
||||
}, {
|
||||
# FIXME: Fails due to no description extracted
|
||||
# m3u8 video (https://github.com/yt-dlp/yt-dlp/issues/2277)
|
||||
'url': 'https://www.patreon.com/posts/video-sketchbook-32452882',
|
||||
'info_dict': {
|
||||
@@ -220,6 +222,7 @@ class PatreonIE(PatreonBaseIE):
|
||||
'channel_id': '2147162',
|
||||
'uploader_url': 'https://www.patreon.com/yaboyroshi',
|
||||
},
|
||||
'skip': 'HTTP Error 401 for m3u8 request; site now requires login to play the video',
|
||||
}, {
|
||||
# NSFW vimeo embed URL
|
||||
'url': 'https://www.patreon.com/posts/4k-spiderman-4k-96414599',
|
||||
@@ -242,6 +245,7 @@ class PatreonIE(PatreonBaseIE):
|
||||
},
|
||||
'params': {'skip_download': 'm3u8'},
|
||||
'expected_warnings': ['Failed to parse XML: not well-formed'],
|
||||
'skip': 'Video removed',
|
||||
}, {
|
||||
# multiple attachments/embeds
|
||||
'url': 'https://www.patreon.com/posts/holy-wars-solos-100601977',
|
||||
@@ -285,6 +289,7 @@ class PatreonIE(PatreonBaseIE):
|
||||
},
|
||||
'params': {'getcomments': True},
|
||||
}, {
|
||||
# FIXME: Error: No supported media found in this post
|
||||
# Inlined media in post; uses _extract_from_media_api
|
||||
'url': 'https://www.patreon.com/posts/scottfalco-146966245',
|
||||
'info_dict': {
|
||||
@@ -304,6 +309,26 @@ class PatreonIE(PatreonBaseIE):
|
||||
'timestamp': 1767061800,
|
||||
'upload_date': '20251230',
|
||||
},
|
||||
}, {
|
||||
# FIXME: need to extract description
|
||||
'url': 'https://www.patreon.com/Insanimate/posts/meatcanyon-in-142663524',
|
||||
'md5': '132332e3bb345f75d8b471242346dee6',
|
||||
'info_dict': {
|
||||
'id': '142663524',
|
||||
'ext': 'mp4',
|
||||
'title': 'Meatcanyon in Playground',
|
||||
'uploader': 'Insanimate',
|
||||
'uploader_id': '2828146',
|
||||
'uploader_url': 'https://www.patreon.com/Insanimate',
|
||||
'channel_id': '6260877',
|
||||
'channel_url': 'https://www.patreon.com/Insanimate',
|
||||
'channel_follower_count': int,
|
||||
'comment_count': int,
|
||||
'like_count': int,
|
||||
'thumbnail': 're:^https?://.*$',
|
||||
'timestamp': 1762101034,
|
||||
'upload_date': '20251102',
|
||||
},
|
||||
}]
|
||||
_RETURN_TYPE = 'video'
|
||||
_HTTP_HEADERS = {
|
||||
@@ -357,7 +382,7 @@ class PatreonIE(PatreonBaseIE):
|
||||
post = self._call_api(
|
||||
f'posts/{video_id}', video_id, query={
|
||||
'fields[media]': 'download_url,mimetype,size_bytes,file_name',
|
||||
'fields[post]': 'comment_count,content,embed,image,like_count,post_file,published_at,title,current_user_can_view',
|
||||
'fields[post]': 'comment_count,content,content_teaser_text,cleaned_teaser_text,embed,image,like_count,post_file,published_at,title,current_user_can_view',
|
||||
'fields[user]': 'full_name,url',
|
||||
'fields[post_tag]': 'value',
|
||||
'fields[campaign]': 'url,name,patron_count',
|
||||
@@ -367,7 +392,7 @@ class PatreonIE(PatreonBaseIE):
|
||||
attributes = post['data']['attributes']
|
||||
info = traverse_obj(attributes, {
|
||||
'title': ('title', {str.strip}),
|
||||
'description': ('content', {clean_html}),
|
||||
'description': (('content', 'content_teaser_text', 'cleaned_teaser_text'), {clean_html}, any),
|
||||
'thumbnail': ('image', ('large_url', 'url'), {url_or_none}, any),
|
||||
'timestamp': ('published_at', {parse_iso8601}),
|
||||
'like_count': ('like_count', {int_or_none}),
|
||||
|
||||
@@ -4,6 +4,7 @@ import re
|
||||
from .common import InfoExtractor
|
||||
from ..utils import (
|
||||
OnDemandPagedList,
|
||||
filter_dict,
|
||||
format_field,
|
||||
int_or_none,
|
||||
parse_resolution,
|
||||
@@ -1358,7 +1359,7 @@ class PeerTubeIE(InfoExtractor):
|
||||
'ext': 'mp4',
|
||||
'title': 'E2E tests',
|
||||
'categories': ['Unknown'],
|
||||
'channel': 'Main chocobozzz channel',
|
||||
'channel': 'Chocobozzz test channel',
|
||||
'channel_id': '5187',
|
||||
'channel_url': 'https://peertube2.cpy.re/video-channels/chocobozzz_channel',
|
||||
'description': 'md5:67daf92c833c41c95db874e18fcb2786',
|
||||
@@ -1382,7 +1383,7 @@ class PeerTubeIE(InfoExtractor):
|
||||
'ext': 'mp4',
|
||||
'title': 'E2E tests',
|
||||
'categories': ['Unknown'],
|
||||
'channel': 'Main chocobozzz channel',
|
||||
'channel': 'Chocobozzz test channel',
|
||||
'channel_id': '5187',
|
||||
'channel_url': 'https://peertube2.cpy.re/video-channels/chocobozzz_channel',
|
||||
'description': 'md5:67daf92c833c41c95db874e18fcb2786',
|
||||
@@ -1406,7 +1407,7 @@ class PeerTubeIE(InfoExtractor):
|
||||
'ext': 'mp4',
|
||||
'title': 'E2E tests',
|
||||
'categories': ['Unknown'],
|
||||
'channel': 'Main chocobozzz channel',
|
||||
'channel': 'Chocobozzz test channel',
|
||||
'channel_id': '5187',
|
||||
'channel_url': 'https://peertube2.cpy.re/video-channels/chocobozzz_channel',
|
||||
'description': 'md5:67daf92c833c41c95db874e18fcb2786',
|
||||
@@ -1452,6 +1453,36 @@ class PeerTubeIE(InfoExtractor):
|
||||
}, {
|
||||
'url': 'peertube:framatube.org:b37a5b9f-e6b5-415c-b700-04a5cd6ec205',
|
||||
'only_matching': True,
|
||||
}, {
|
||||
'url': 'https://videos.john-livingston.fr/w/mna1A6SxZ94cra4hMtjRQm',
|
||||
'md5': '6a5faad22916e41ba4078ef59c33bc9f',
|
||||
'info_dict': {
|
||||
'id': 'mna1A6SxZ94cra4hMtjRQm',
|
||||
'ext': 'mp4',
|
||||
'title': 'test yt-dlp',
|
||||
'description': 'md5:d8556ee790ad9b3fac6f0bb3eb5b67bd',
|
||||
'thumbnail': r're:https?://videos.john-livingston\.fr/lazy-static/thumbnails/.+\.jpg',
|
||||
'timestamp': 1780645286,
|
||||
'upload_date': '20260605',
|
||||
'uploader': 'John Livingston',
|
||||
'uploader_id': '5',
|
||||
'uploader_url': 'https://videos.john-livingston.fr/accounts/john',
|
||||
'channel': 'john_livingston',
|
||||
'channel_id': '4',
|
||||
'channel_url': 'https://videos.john-livingston.fr/video-channels/john_livingston',
|
||||
'license': 'Unknown',
|
||||
'duration': 16,
|
||||
'view_count': int,
|
||||
'like_count': int,
|
||||
'dislike_count': int,
|
||||
'tags': 'count:0',
|
||||
'categories': ['Unknown'],
|
||||
},
|
||||
'params': {
|
||||
'videopassword': 'thepassword',
|
||||
'format': '600p',
|
||||
},
|
||||
'expected_warnings': ['Ignoring subtitle tracks found in the HLS manifest'],
|
||||
}]
|
||||
_WEBPAGE_TESTS = [{
|
||||
'url': 'https://video.macver.org/w/6gvhZpUGQVd4SQ6oYDc9pC',
|
||||
@@ -1492,6 +1523,9 @@ class PeerTubeIE(InfoExtractor):
|
||||
'>We are sorry but it seems that PeerTube is not compatible with your web browser.<')):
|
||||
return 'peertube:{}:{}'.format(*mobj.group('host', 'id'))
|
||||
|
||||
def _get_headers(self):
|
||||
return filter_dict({'x-peertube-video-password': self.get_param('videopassword')})
|
||||
|
||||
@classmethod
|
||||
def _extract_embed_urls(cls, url, webpage):
|
||||
embeds = tuple(super()._extract_embed_urls(url, webpage))
|
||||
@@ -1505,7 +1539,7 @@ class PeerTubeIE(InfoExtractor):
|
||||
def _call_api(self, host, video_id, path, note=None, errnote=None, fatal=True):
|
||||
return self._download_json(
|
||||
self._API_BASE % (host, video_id, path), video_id,
|
||||
note=note, errnote=errnote, fatal=fatal)
|
||||
note=note, errnote=errnote, fatal=fatal, headers=self._get_headers())
|
||||
|
||||
def _get_subtitles(self, host, video_id):
|
||||
captions = self._call_api(
|
||||
@@ -1545,7 +1579,7 @@ class PeerTubeIE(InfoExtractor):
|
||||
if playlist_url := url_or_none(playlist.get('playlistUrl')):
|
||||
is_live = True
|
||||
formats.extend(self._extract_m3u8_formats(
|
||||
playlist_url, video_id, fatal=False, live=True))
|
||||
playlist_url, video_id, fatal=False, live=True, headers=self._get_headers()))
|
||||
playlist_files = playlist.get('files')
|
||||
if not (playlist_files and isinstance(playlist_files, list)):
|
||||
continue
|
||||
@@ -1629,6 +1663,8 @@ class PeerTubeIE(InfoExtractor):
|
||||
'subtitles': subtitles,
|
||||
'is_live': is_live,
|
||||
'webpage_url': webpage_url,
|
||||
# Headers are needed for ALL format requests, but not thumbnails
|
||||
'http_headers': self._get_headers(),
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1037,8 +1037,10 @@ class YoutubeBaseInfoExtractor(InfoExtractor):
|
||||
return next_continuation
|
||||
|
||||
return traverse_obj(renderer, (
|
||||
('contents', 'items', 'rows', 'subThreads'), ..., 'continuationItemRenderer',
|
||||
('continuationEndpoint', ('button', 'buttonRenderer', 'command')),
|
||||
('contents', 'items', 'rows', 'subThreads'), ..., (
|
||||
('continuationItemRenderer', ('continuationEndpoint', ('button', 'buttonRenderer', 'command'))),
|
||||
('continuationItemViewModel', 'continuationCommand', 'innertubeCommand'),
|
||||
),
|
||||
), get_all=False, expected_type=cls._extract_continuation_ep_data)
|
||||
|
||||
@classmethod
|
||||
|
||||
@@ -1032,14 +1032,14 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
'playlist_mincount': 94,
|
||||
'info_dict': {
|
||||
'id': 'UCqj7Cz7revf5maW9g5pgNcg',
|
||||
'title': 'Igor Kleiner - Playlists',
|
||||
'description': r're:(?s)Добро пожаловать на мой канал! Здесь вы найдете видео .{504}/a1/50b/10a$',
|
||||
'uploader': 'Igor Kleiner ',
|
||||
'title': 'Igor DS: ИИ, Наука и Творчество - Playlists',
|
||||
'description': r're:(?s)Добро пожаловать! Здесь сложные технологии встречаются.+\n$',
|
||||
'uploader': 'Igor DS: ИИ, Наука и Творчество ',
|
||||
'uploader_id': '@IgorDataScience',
|
||||
'uploader_url': 'https://www.youtube.com/@IgorDataScience',
|
||||
'channel': 'Igor Kleiner ',
|
||||
'channel': 'Igor DS: ИИ, Наука и Творчество ',
|
||||
'channel_id': 'UCqj7Cz7revf5maW9g5pgNcg',
|
||||
'tags': 'count:23',
|
||||
'tags': 'count:19',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCqj7Cz7revf5maW9g5pgNcg',
|
||||
'channel_follower_count': int,
|
||||
},
|
||||
@@ -1049,14 +1049,13 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
'playlist_mincount': 94,
|
||||
'info_dict': {
|
||||
'id': 'UCqj7Cz7revf5maW9g5pgNcg',
|
||||
'title': 'Igor Kleiner - Playlists',
|
||||
'description': r're:(?s)Добро пожаловать на мой канал! Здесь вы найдете видео .{504}/a1/50b/10a$',
|
||||
'uploader': 'Igor Kleiner ',
|
||||
'title': 'Igor DS: ИИ, Наука и Творчество - Playlists',
|
||||
'description': r're:(?s)Добро пожаловать! Здесь сложные технологии встречаются.+\n$',
|
||||
'uploader_id': '@IgorDataScience',
|
||||
'uploader_url': 'https://www.youtube.com/@IgorDataScience',
|
||||
'tags': 'count:23',
|
||||
'tags': 'count:19',
|
||||
'channel_id': 'UCqj7Cz7revf5maW9g5pgNcg',
|
||||
'channel': 'Igor Kleiner ',
|
||||
'channel': 'Igor DS: ИИ, Наука и Творчество ',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCqj7Cz7revf5maW9g5pgNcg',
|
||||
'channel_follower_count': int,
|
||||
},
|
||||
@@ -1139,90 +1138,89 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
'playlist_count': 0,
|
||||
}, {
|
||||
'note': 'Home tab',
|
||||
'url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w/featured',
|
||||
'url': 'https://www.youtube.com/channel/UCTwECeGqMZee77BjdoYtI2Q/featured',
|
||||
'info_dict': {
|
||||
'id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'title': 'lex will - Home',
|
||||
'description': 'md5:2163c5d0ff54ed5f598d6a7e6211e488',
|
||||
'uploader': 'lex will',
|
||||
'uploader_id': '@lexwill718',
|
||||
'channel': 'lex will',
|
||||
'tags': ['bible', 'history', 'prophesy'],
|
||||
'uploader_url': 'https://www.youtube.com/@lexwill718',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'channel_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'id': 'UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'title': 'Creative Commons - Home',
|
||||
'description': 'md5:7cfc22824277588d26a66054f22d93c8',
|
||||
'uploader': 'Creative Commons',
|
||||
'uploader_id': '@creativecommons',
|
||||
'uploader_url': 'https://www.youtube.com/@creativecommons',
|
||||
'channel': 'Creative Commons',
|
||||
'channel_id': 'UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'channel_follower_count': int,
|
||||
'tags': ['creative commons', 'remix', 'culture', 'nonprofit'],
|
||||
},
|
||||
'playlist_mincount': 2,
|
||||
'playlist_mincount': 6,
|
||||
}, {
|
||||
'note': 'Videos tab',
|
||||
'url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w/videos',
|
||||
'url': 'https://www.youtube.com/channel/UCTwECeGqMZee77BjdoYtI2Q/videos',
|
||||
'info_dict': {
|
||||
'id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'title': 'lex will - Videos',
|
||||
'description': 'md5:2163c5d0ff54ed5f598d6a7e6211e488',
|
||||
'uploader': 'lex will',
|
||||
'uploader_id': '@lexwill718',
|
||||
'tags': ['bible', 'history', 'prophesy'],
|
||||
'channel_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'channel_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'uploader_url': 'https://www.youtube.com/@lexwill718',
|
||||
'channel': 'lex will',
|
||||
'id': 'UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'title': 'Creative Commons - Videos',
|
||||
'description': 'md5:7cfc22824277588d26a66054f22d93c8',
|
||||
'uploader': 'Creative Commons',
|
||||
'uploader_id': '@creativecommons',
|
||||
'uploader_url': 'https://www.youtube.com/@creativecommons',
|
||||
'channel': 'Creative Commons',
|
||||
'channel_id': 'UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'channel_follower_count': int,
|
||||
'tags': ['creative commons', 'remix', 'culture', 'nonprofit'],
|
||||
},
|
||||
'playlist_mincount': 975,
|
||||
'playlist_mincount': 239,
|
||||
}, {
|
||||
'note': 'Videos tab, sorted by popular',
|
||||
'url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w/videos?view=0&sort=p&flow=grid',
|
||||
'url': 'https://www.youtube.com/channel/UCTwECeGqMZee77BjdoYtI2Q/videos?view=0&sort=p&flow=grid',
|
||||
'info_dict': {
|
||||
'id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'title': 'lex will - Videos',
|
||||
'description': 'md5:2163c5d0ff54ed5f598d6a7e6211e488',
|
||||
'uploader': 'lex will',
|
||||
'uploader_id': '@lexwill718',
|
||||
'channel_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'uploader_url': 'https://www.youtube.com/@lexwill718',
|
||||
'channel': 'lex will',
|
||||
'tags': ['bible', 'history', 'prophesy'],
|
||||
'channel_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'id': 'UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'title': 'Creative Commons - Videos',
|
||||
'description': 'md5:7cfc22824277588d26a66054f22d93c8',
|
||||
'uploader': 'Creative Commons',
|
||||
'uploader_id': '@creativecommons',
|
||||
'uploader_url': 'https://www.youtube.com/@creativecommons',
|
||||
'channel': 'Creative Commons',
|
||||
'channel_id': 'UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'channel_follower_count': int,
|
||||
'tags': ['creative commons', 'remix', 'culture', 'nonprofit'],
|
||||
},
|
||||
'playlist_mincount': 199,
|
||||
'playlist_mincount': 239,
|
||||
}, {
|
||||
'note': 'Playlists tab',
|
||||
'url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w/playlists',
|
||||
'url': 'https://www.youtube.com/channel/UCTwECeGqMZee77BjdoYtI2Q/playlists',
|
||||
'info_dict': {
|
||||
'id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'title': 'lex will - Playlists',
|
||||
'description': 'md5:2163c5d0ff54ed5f598d6a7e6211e488',
|
||||
'uploader': 'lex will',
|
||||
'uploader_id': '@lexwill718',
|
||||
'uploader_url': 'https://www.youtube.com/@lexwill718',
|
||||
'channel': 'lex will',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'channel_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'tags': ['bible', 'history', 'prophesy'],
|
||||
'id': 'UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'title': 'Creative Commons - Playlists',
|
||||
'description': 'md5:7cfc22824277588d26a66054f22d93c8',
|
||||
'uploader': 'Creative Commons',
|
||||
'uploader_id': '@creativecommons',
|
||||
'uploader_url': 'https://www.youtube.com/@creativecommons',
|
||||
'channel': 'Creative Commons',
|
||||
'channel_id': 'UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCTwECeGqMZee77BjdoYtI2Q',
|
||||
'channel_follower_count': int,
|
||||
'tags': ['creative commons', 'remix', 'culture', 'nonprofit'],
|
||||
},
|
||||
'playlist_mincount': 17,
|
||||
'playlist_mincount': 20,
|
||||
}, {
|
||||
'note': 'Posts tab',
|
||||
'url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w/community',
|
||||
'url': 'https://www.youtube.com/channel/UCtS3BcCw-tITPFYSvkbP0Bg/posts',
|
||||
'info_dict': {
|
||||
'id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'title': 'lex will - Posts',
|
||||
'description': 'md5:2163c5d0ff54ed5f598d6a7e6211e488',
|
||||
'channel': 'lex will',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'channel_id': 'UCKfVa3S1e4PHvxWcwyMMg8w',
|
||||
'tags': ['bible', 'history', 'prophesy'],
|
||||
'id': 'UCtS3BcCw-tITPFYSvkbP0Bg',
|
||||
'title': 'Office Hours Live with Tim Heidecker - Posts',
|
||||
'description': 'md5:01ec1460ea6c6e2aa47d3be9c756559c',
|
||||
'uploader': 'Office Hours Live with Tim Heidecker',
|
||||
'uploader_id': '@OfficeHoursLive',
|
||||
'uploader_url': 'https://www.youtube.com/@OfficeHoursLive',
|
||||
'channel': 'Office Hours Live with Tim Heidecker',
|
||||
'channel_id': 'UCtS3BcCw-tITPFYSvkbP0Bg',
|
||||
'channel_url': 'https://www.youtube.com/channel/UCtS3BcCw-tITPFYSvkbP0Bg',
|
||||
'channel_follower_count': int,
|
||||
'uploader_url': 'https://www.youtube.com/@lexwill718',
|
||||
'uploader_id': '@lexwill718',
|
||||
'uploader': 'lex will',
|
||||
'tags': 'count:17',
|
||||
},
|
||||
'playlist_mincount': 18,
|
||||
'skip': 'This Community isn\'t available',
|
||||
'playlist_mincount': 145,
|
||||
}, {
|
||||
# TODO: fix channel_is_verified extraction
|
||||
'note': 'Search tab',
|
||||
@@ -1272,6 +1270,7 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
},
|
||||
'playlist_count': 96,
|
||||
}, {
|
||||
# TODO: fix availability extraction
|
||||
'note': 'Large playlist',
|
||||
'url': 'https://www.youtube.com/playlist?list=UUBABnxM4Ar9ten8Mdjj1j0Q',
|
||||
'info_dict': {
|
||||
@@ -1296,6 +1295,8 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
'url': 'http://www.youtube.com/user/NASAgovVideo/videos',
|
||||
'only_matching': True,
|
||||
}, {
|
||||
# TODO: fix availability extraction
|
||||
# The 'note' below is outdated: there is no longer a "Load more" button
|
||||
'note': 'Buggy playlist: the webpage has a "Load more" button but it doesn\'t have more videos',
|
||||
'url': 'https://www.youtube.com/playlist?list=UUXw-G3eDE9trcvY2sBMM_aA',
|
||||
'info_dict': {
|
||||
@@ -1313,7 +1314,7 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
'uploader': 'Interstellar Movie',
|
||||
'uploader_url': 'https://www.youtube.com/@InterstellarMovie',
|
||||
},
|
||||
'playlist_mincount': 21,
|
||||
'playlist_mincount': 10,
|
||||
}, {
|
||||
# TODO: fix availability extraction
|
||||
'note': 'Playlist with "show unavailable videos" button',
|
||||
@@ -1336,6 +1337,7 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
'playlist_mincount': 150,
|
||||
'expected_warnings': [r'[Uu]navailable videos (are|will be) hidden'],
|
||||
}, {
|
||||
# TODO: fix availability extraction
|
||||
'note': 'Playlist with unavailable videos in page 7',
|
||||
'url': 'https://www.youtube.com/playlist?list=UU8l9frL61Yl5KFOl87nIm2w',
|
||||
'info_dict': {
|
||||
@@ -1407,7 +1409,7 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
}, {
|
||||
'url': 'https://www.youtube.com/channel/UCoMdktPbSTixAyNGwb-UYkQ/live',
|
||||
'info_dict': {
|
||||
'id': 'VFGoUmo74wE', # This will keep changing
|
||||
'id': 'ubIX-TwVqZI', # This will keep changing
|
||||
'ext': 'mp4',
|
||||
'title': str,
|
||||
'upload_date': r're:\d{8}',
|
||||
@@ -1586,6 +1588,7 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
'playlist_count': 50,
|
||||
'expected_warnings': ['YouTube Music is not directly supported'],
|
||||
}, {
|
||||
# TODO: investigate test failing on differing channel*/uploader*/view_count
|
||||
'note': 'unlisted single video playlist',
|
||||
'url': 'https://www.youtube.com/playlist?list=PLt5yu3-wZAlQLfIN0MMgp0wVV6MP3bM4_',
|
||||
'info_dict': {
|
||||
@@ -1809,7 +1812,7 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
'title': 'Not Just Bikes - Shorts',
|
||||
'tags': 'count:10',
|
||||
'channel_url': 'https://www.youtube.com/channel/UC0intLFzLaudFG-xAvUEO-A',
|
||||
'description': 'md5:295758591d0d43d8594277be54584da7',
|
||||
'description': 'md5:2cb3ccdafa58608fa016f1de4930ec54',
|
||||
'channel_follower_count': int,
|
||||
'channel_id': 'UC0intLFzLaudFG-xAvUEO-A',
|
||||
'channel': 'Not Just Bikes',
|
||||
@@ -1831,8 +1834,8 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
'channel': '中村悠一',
|
||||
'channel_follower_count': int,
|
||||
'description': 'md5:76b312b48a26c3b0e4d90e2dfc1b417d',
|
||||
'uploader_url': 'https://www.youtube.com/@Yuichi-Nakamura',
|
||||
'uploader_id': '@Yuichi-Nakamura',
|
||||
'uploader_url': 'https://www.youtube.com/@中村悠一のあそびば',
|
||||
'uploader_id': '@中村悠一のあそびば',
|
||||
'uploader': '中村悠一',
|
||||
},
|
||||
'playlist_mincount': 60,
|
||||
@@ -2010,7 +2013,7 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
'channel': '99% Invisible',
|
||||
'uploader_id': '@99percentinvisiblepodcast',
|
||||
},
|
||||
'playlist_count': 5,
|
||||
'playlist_mincount': 5,
|
||||
}, {
|
||||
# Releases tab, with rich entry playlistRenderers (same as Podcasts tab)
|
||||
# TODO: fix channel_is_verified extraction
|
||||
@@ -2034,6 +2037,7 @@ class YoutubeTabIE(YoutubeTabBaseInfoExtractor):
|
||||
# Playlist with only shorts, shown as reel renderers
|
||||
# FIXME: future: YouTube currently doesn't give continuation for this,
|
||||
# may do in future.
|
||||
# TODO: fix availability extraction
|
||||
'url': 'https://www.youtube.com/playlist?list=UUxqPAgubo4coVn9Lx1FuKcg',
|
||||
'info_dict': {
|
||||
'id': 'UUxqPAgubo4coVn9Lx1FuKcg',
|
||||
|
||||
@@ -4,7 +4,7 @@ from .common import PostProcessor
|
||||
from ..compat import shutil
|
||||
from ..utils import (
|
||||
PostProcessingError,
|
||||
make_dir,
|
||||
make_parent_dirs,
|
||||
)
|
||||
|
||||
|
||||
@@ -42,7 +42,10 @@ class MoveFilesAfterDownloadPP(PostProcessor):
|
||||
self.report_warning(
|
||||
f'Cannot move file "{oldfile}" out of temporary directory since "{newfile}" already exists. ')
|
||||
continue
|
||||
make_dir(newfile, PostProcessingError)
|
||||
try:
|
||||
make_parent_dirs(newfile)
|
||||
except OSError as e:
|
||||
raise PostProcessingError(f'Unable to create directory: {e}') from e
|
||||
self.to_screen(f'Moving file "{oldfile}" to "{newfile}"')
|
||||
shutil.move(oldfile, newfile) # os.rename cannot move between volumes
|
||||
|
||||
|
||||
@@ -46,4 +46,16 @@ def jwt_encode_hs256(payload_data, key, headers={}):
|
||||
return header_b64 + b'.' + payload_b64 + b'.' + signature_b64
|
||||
|
||||
|
||||
def make_dir(path, to_screen=None):
|
||||
from . import make_parent_dirs
|
||||
|
||||
try:
|
||||
make_parent_dirs(path)
|
||||
return True
|
||||
except OSError as e:
|
||||
if to_screen is not None:
|
||||
to_screen(f'Unable to create directory: {e}')
|
||||
return False
|
||||
|
||||
|
||||
compiled_regex_type = type(re.compile(''))
|
||||
|
||||
@@ -4713,16 +4713,9 @@ def random_uuidv4():
|
||||
return re.sub(r'[xy]', lambda x: _HEX_TABLE[random.randint(0, 15)], 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx')
|
||||
|
||||
|
||||
def make_dir(path, to_screen=None):
|
||||
try:
|
||||
dn = os.path.dirname(path)
|
||||
if dn:
|
||||
os.makedirs(dn, exist_ok=True)
|
||||
return True
|
||||
except OSError as err:
|
||||
if callable(to_screen) is not None:
|
||||
to_screen(f'unable to create directory {err}')
|
||||
return False
|
||||
def make_parent_dirs(path):
|
||||
if dir_name := os.path.dirname(path):
|
||||
os.makedirs(dir_name, exist_ok=True)
|
||||
|
||||
|
||||
def get_executable_path():
|
||||
@@ -5218,12 +5211,17 @@ class _UnsafeExtensionError(Exception):
|
||||
'sbv',
|
||||
])
|
||||
|
||||
_enabled = True
|
||||
|
||||
def __init__(self, extension, /):
|
||||
super().__init__(f'unsafe file extension: {extension!r}')
|
||||
self.extension = extension
|
||||
|
||||
@classmethod
|
||||
def sanitize_extension(cls, extension, /, *, prepend=False, _allowed_exts=()):
|
||||
if not cls._enabled:
|
||||
return extension
|
||||
|
||||
if extension is None:
|
||||
return None
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ class HTTPHeaderDict(dict):
|
||||
other = other.sensitive()
|
||||
if isinstance(other, dict):
|
||||
self.update(other)
|
||||
return
|
||||
return self
|
||||
return NotImplemented
|
||||
|
||||
def __or__(self, other, /) -> typing.Self:
|
||||
|
||||
Reference in New Issue
Block a user