1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-12-02 16:14:15 +01:00

output.sanitize: windows windows windows..

This commit is contained in:
Johan Andersson 2022-11-21 14:22:51 +01:00
parent 94eb8543f7
commit 6cf94c93eb

View File

@ -129,11 +129,14 @@ def filename(stream):
def sanitize(name): def sanitize(name):
dirname = name.parent
basename = str(name.name)
blocklist = [":", "*", "?", '"', "<", ">", "|", "\0"] blocklist = [":", "*", "?", '"', "<", ">", "|", "\0"]
for i in blocklist: for i in blocklist:
if i in name: if i in basename:
name = name.replace(i, "") basename = basename.replace(i, "")
return name
return dirname.joinpath(basename.replace("..", "."))
def formatname(output, config): def formatname(output, config):
@ -158,11 +161,11 @@ def formatname(output, config):
elif config.get("path") and pathlib.Path(config.get("path")).expanduser().is_dir(): elif config.get("path") and pathlib.Path(config.get("path")).expanduser().is_dir():
dirname = pathlib.Path(config.get("path")) dirname = pathlib.Path(config.get("path"))
elif config.get("output"): elif config.get("output"):
if output["ext"]: if "ext" in output and output["ext"]:
name = pathlib.Path(f"{config.get('output')}.{output['ext']}") name = pathlib.Path(f"{config.get('output')}.{output['ext']}")
else: else:
name = pathlib.Path(config.get("output")) name = pathlib.Path(config.get("output"))
name = pathlib.Path(sanitize(str(name.expanduser())).replace("..", ".")) name = pathlib.Path(sanitize(name.expanduser()))
if subfolder and dirname: if subfolder and dirname:
return dirname / subfolder / name.expanduser() return dirname / subfolder / name.expanduser()
elif subfolder: elif subfolder: