mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-06-22 02:34:39 +00:00
Compare commits
2 Commits
a2483524fb
...
9055188250
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9055188250 | ||
|
|
b05b408d10 |
@ -395,6 +395,7 @@ 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"
|
||||||
|
|||||||
@ -139,7 +139,7 @@ from .utils import (
|
|||||||
join_nonempty,
|
join_nonempty,
|
||||||
locked_file,
|
locked_file,
|
||||||
make_archive_id,
|
make_archive_id,
|
||||||
make_dir,
|
make_parent_dirs,
|
||||||
number_of_digits,
|
number_of_digits,
|
||||||
orderedSet,
|
orderedSet,
|
||||||
orderedSet_from_options,
|
orderedSet_from_options,
|
||||||
@ -2036,7 +2036,12 @@ 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):
|
||||||
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
|
@staticmethod
|
||||||
def _playlist_infodict(ie_result, strict=False, **kwargs):
|
def _playlist_infodict(ie_result, strict=False, **kwargs):
|
||||||
|
|||||||
@ -420,10 +420,11 @@ class BandcampWeeklyIE(BandcampIE): # XXX: Do not subclass from concrete IE
|
|||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '224',
|
'id': '224',
|
||||||
'ext': 'mp3',
|
'ext': 'mp3',
|
||||||
'title': 'Magic Moments, 2017-04-04',
|
'title': 'Bandcamp Weekly, 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': 'Magic Moments',
|
'series': 'Bandcamp Weekly',
|
||||||
'episode_id': '224',
|
'episode_id': '224',
|
||||||
'release_timestamp': 1491264000,
|
'release_timestamp': 1491264000,
|
||||||
'release_date': '20170404',
|
'release_date': '20170404',
|
||||||
@ -450,12 +451,13 @@ 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('title')
|
series_title = show_data.get('subtitle')
|
||||||
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),
|
||||||
|
|||||||
@ -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_dir,
|
make_parent_dirs,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +42,10 @@ 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
|
||||||
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}"')
|
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
|
||||||
|
|
||||||
|
|||||||
@ -46,4 +46,16 @@ 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(''))
|
||||||
|
|||||||
@ -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')
|
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):
|
def make_parent_dirs(path):
|
||||||
try:
|
if dir_name := os.path.dirname(path):
|
||||||
dn = os.path.dirname(path)
|
os.makedirs(dir_name, exist_ok=True)
|
||||||
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():
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user