mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-11-14 21:45:15 +00:00
Option --windows-filenames to force use of windows compatible filenames
* Also changed `--trim-file-name` to `--trim-filenames` to be similar to related options Related: https://web.archive.org/web/20210217190806/https://old.reddit.com/r/youtubedl/comments/llc4o5/do_you_guys_also_have_this_error :ci skip dl
This commit is contained in:
@@ -2125,13 +2125,17 @@ def sanitize_filename(s, restricted=False, is_id=False):
|
||||
return result
|
||||
|
||||
|
||||
def sanitize_path(s):
|
||||
def sanitize_path(s, force=False):
|
||||
"""Sanitizes and normalizes path on Windows"""
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform == 'win32':
|
||||
drive_or_unc, _ = os.path.splitdrive(s)
|
||||
if sys.version_info < (2, 7) and not drive_or_unc:
|
||||
drive_or_unc, _ = os.path.splitunc(s)
|
||||
elif force:
|
||||
drive_or_unc = ''
|
||||
else:
|
||||
return s
|
||||
drive_or_unc, _ = os.path.splitdrive(s)
|
||||
if sys.version_info < (2, 7) and not drive_or_unc:
|
||||
drive_or_unc, _ = os.path.splitunc(s)
|
||||
|
||||
norm_path = os.path.normpath(remove_start(s, drive_or_unc)).split(os.path.sep)
|
||||
if drive_or_unc:
|
||||
norm_path.pop(0)
|
||||
|
||||
Reference in New Issue
Block a user