Compare commits

..

No commits in common. "9055188250348c3e6e29eee53e5fb3dc2c951977" and "a2483524fbf9c1f5406774622d8d048430b320e9" have entirely different histories.

6 changed files with 17 additions and 33 deletions

View File

@ -395,7 +395,6 @@ banned-from = [
"yt_dlp.utils.bytes_to_intlist".msg = "Use `list` instead." "yt_dlp.utils.bytes_to_intlist".msg = "Use `list` instead."
"yt_dlp.utils.intlist_to_bytes".msg = "Use `bytes` 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.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.decodeArgument".msg = "Do not use"
"yt_dlp.utils.decodeFilename".msg = "Do not use" "yt_dlp.utils.decodeFilename".msg = "Do not use"
"yt_dlp.utils.encodeFilename".msg = "Do not use" "yt_dlp.utils.encodeFilename".msg = "Do not use"

View File

@ -139,7 +139,7 @@ from .utils import (
join_nonempty, join_nonempty,
locked_file, locked_file,
make_archive_id, make_archive_id,
make_parent_dirs, make_dir,
number_of_digits, number_of_digits,
orderedSet, orderedSet,
orderedSet_from_options, orderedSet_from_options,
@ -2036,12 +2036,7 @@ class YoutubeDL:
raise Exception(f'Invalid result type: {result_type}') raise Exception(f'Invalid result type: {result_type}')
def _ensure_dir_exists(self, path): def _ensure_dir_exists(self, path):
try: return make_dir(path, self.report_error)
make_parent_dirs(path)
return True
except OSError as e:
self.report_error(f'Unable to create directory: {e}')
return False
@staticmethod @staticmethod
def _playlist_infodict(ie_result, strict=False, **kwargs): def _playlist_infodict(ie_result, strict=False, **kwargs):

View File

@ -420,11 +420,10 @@ class BandcampWeeklyIE(BandcampIE): # XXX: Do not subclass from concrete IE
'info_dict': { 'info_dict': {
'id': '224', 'id': '224',
'ext': 'mp3', 'ext': 'mp3',
'title': 'Bandcamp Weekly, 2017-04-04', 'title': 'Magic Moments, 2017-04-04',
'episode': 'Magic Moments',
'description': 'md5:5d48150916e8e02d030623a48512c874', 'description': 'md5:5d48150916e8e02d030623a48512c874',
'thumbnail': 'https://f4.bcbits.com/img/9982549_0.jpg', 'thumbnail': 'https://f4.bcbits.com/img/9982549_0.jpg',
'series': 'Bandcamp Weekly', 'series': 'Magic Moments',
'episode_id': '224', 'episode_id': '224',
'release_timestamp': 1491264000, 'release_timestamp': 1491264000,
'release_date': '20170404', 'release_date': '20170404',
@ -451,13 +450,12 @@ class BandcampWeeklyIE(BandcampIE): # XXX: Do not subclass from concrete IE
format_id = traverse_obj(stream_url, ({parse_qs}, 'enc', -1)) format_id = traverse_obj(stream_url, ({parse_qs}, 'enc', -1))
encoding, _, bitrate_str = (format_id or '').partition('-') encoding, _, bitrate_str = (format_id or '').partition('-')
series_title = show_data.get('subtitle') series_title = show_data.get('title')
release_timestamp = unified_timestamp(show_data.get('date')) release_timestamp = unified_timestamp(show_data.get('date'))
return { return {
'id': show_id, 'id': show_id,
'episode_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=', '), 'title': join_nonempty(series_title, strftime_or_none(release_timestamp, '%Y-%m-%d'), delim=', '),
'series': series_title, 'series': series_title,
'thumbnail': format_field(show_data, 'imageId', 'https://f4.bcbits.com/img/%s_0.jpg', default=None), 'thumbnail': format_field(show_data, 'imageId', 'https://f4.bcbits.com/img/%s_0.jpg', default=None),

View File

@ -4,7 +4,7 @@ from .common import PostProcessor
from ..compat import shutil from ..compat import shutil
from ..utils import ( from ..utils import (
PostProcessingError, PostProcessingError,
make_parent_dirs, make_dir,
) )
@ -42,10 +42,7 @@ class MoveFilesAfterDownloadPP(PostProcessor):
self.report_warning( self.report_warning(
f'Cannot move file "{oldfile}" out of temporary directory since "{newfile}" already exists. ') f'Cannot move file "{oldfile}" out of temporary directory since "{newfile}" already exists. ')
continue continue
try: make_dir(newfile, PostProcessingError)
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}"') self.to_screen(f'Moving file "{oldfile}" to "{newfile}"')
shutil.move(oldfile, newfile) # os.rename cannot move between volumes shutil.move(oldfile, newfile) # os.rename cannot move between volumes

View File

@ -46,16 +46,4 @@ def jwt_encode_hs256(payload_data, key, headers={}):
return header_b64 + b'.' + payload_b64 + b'.' + signature_b64 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('')) compiled_regex_type = type(re.compile(''))

View File

@ -4713,9 +4713,16 @@ def random_uuidv4():
return re.sub(r'[xy]', lambda x: _HEX_TABLE[random.randint(0, 15)], 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx') return re.sub(r'[xy]', lambda x: _HEX_TABLE[random.randint(0, 15)], 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx')
def make_parent_dirs(path): def make_dir(path, to_screen=None):
if dir_name := os.path.dirname(path): try:
os.makedirs(dir_name, exist_ok=True) 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 get_executable_path(): def get_executable_path():