Skip to content

Commit

Permalink
[CI] auto update yt_dlp to upstream commit 6fc85f617a5850307fd5b25847…
Browse files Browse the repository at this point in the history
…7070e6ee177796
  • Loading branch information
github-actions[bot] committed Dec 23, 2024
1 parent 3549d83 commit f7be7ca
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
26 changes: 18 additions & 8 deletions lib/yt_dlp/YoutubeDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ class YoutubeDL:
outtmpl_na_placeholder: Placeholder for unavailable meta fields.
restrictfilenames: Do not allow "&" and spaces in file names
trim_file_name: Limit length of filename (extension excluded)
windowsfilenames: Force the filenames to be windows compatible
windowsfilenames: True: Force filenames to be Windows compatible
False: Sanitize filenames only minimally
This option has no effect when running on Windows
ignoreerrors: Do not stop on download/postprocessing errors.
Can be 'only_download' to ignore only download errors.
Default is 'only_download' for CLI, but False for API
Expand Down Expand Up @@ -1192,8 +1194,7 @@ def _copy_infodict(info_dict):

def prepare_outtmpl(self, outtmpl, info_dict, sanitize=False):
""" Make the outtmpl and info_dict suitable for substitution: ydl.escape_outtmpl(outtmpl) % info_dict
@param sanitize Whether to sanitize the output as a filename.
For backward compatibility, a function can also be passed
@param sanitize Whether to sanitize the output as a filename
"""

info_dict.setdefault('epoch', int(time.time())) # keep epoch consistent once set
Expand Down Expand Up @@ -1309,14 +1310,23 @@ def get_value(mdict):

na = self.params.get('outtmpl_na_placeholder', 'NA')

def filename_sanitizer(key, value, restricted=self.params.get('restrictfilenames')):
def filename_sanitizer(key, value, restricted):
return sanitize_filename(str(value), restricted=restricted, is_id=(
bool(re.search(r'(^|[_.])id(\.|$)', key))
if 'filename-sanitization' in self.params['compat_opts']
else NO_DEFAULT))

sanitizer = sanitize if callable(sanitize) else filename_sanitizer
sanitize = bool(sanitize)
if callable(sanitize):
self.deprecation_warning('Passing a callable "sanitize" to YoutubeDL.prepare_outtmpl is deprecated')
elif not sanitize:
pass
elif (sys.platform != 'win32' and not self.params.get('restrictfilenames')
and self.params.get('windowsfilenames') is False):
def sanitize(key, value):
return value.replace('/', '\u29F8').replace('\0', '')
else:
def sanitize(key, value):
return filename_sanitizer(key, value, restricted=self.params.get('restrictfilenames'))

def _dumpjson_default(obj):
if isinstance(obj, (set, LazyList)):
Expand Down Expand Up @@ -1399,13 +1409,13 @@ def create_key(outer_mobj):

if sanitize:
# If value is an object, sanitize might convert it to a string
# So we convert it to repr first
# So we manually convert it before sanitizing
if fmt[-1] == 'r':
value, fmt = repr(value), str_fmt
elif fmt[-1] == 'a':
value, fmt = ascii(value), str_fmt
if fmt[-1] in 'csra':
value = sanitizer(last_field, value)
value = sanitize(last_field, value)

key = '{}\0{}'.format(key.replace('%', '%\0'), outer_mobj.group('format'))
TMPL_DICT[key] = value
Expand Down
4 changes: 2 additions & 2 deletions lib/yt_dlp/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -1370,12 +1370,12 @@ def _alias_callback(option, opt_str, value, parser, opts, nargs):
help='Allow Unicode characters, "&" and spaces in filenames (default)')
filesystem.add_option(
'--windows-filenames',
action='store_true', dest='windowsfilenames', default=False,
action='store_true', dest='windowsfilenames', default=None,
help='Force filenames to be Windows-compatible')
filesystem.add_option(
'--no-windows-filenames',
action='store_false', dest='windowsfilenames',
help='Make filenames Windows-compatible only if using Windows (default)')
help='Sanitize filenames only minimally')
filesystem.add_option(
'--trim-filenames', '--trim-file-names', metavar='LENGTH',
dest='trim_file_name', default=0, type=int,
Expand Down
2 changes: 1 addition & 1 deletion lib/yt_dlp_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d298693b1b266d198e8eeecb90ea17c4a031268f
6fc85f617a5850307fd5b258477070e6ee177796

0 comments on commit f7be7ca

Please sign in to comment.