1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 04:05:39 +01:00

output: sanitize the filename a little

This commit is contained in:
Johan Andersson 2022-11-21 14:05:36 +01:00
parent 8950be8eec
commit 2c16302f25

View File

@ -128,6 +128,14 @@ def filename(stream):
return True return True
def sanitize(name):
blocklist = [":", "*", "?", '"', "<", ">", "|", "\0"]
for i in blocklist:
if i in name:
name = name.replace(i, "")
return name
def formatname(output, config): def formatname(output, config):
name = pathlib.Path(_formatname(output, config)) name = pathlib.Path(_formatname(output, config))
subfolder = None subfolder = None
@ -154,6 +162,7 @@ def formatname(output, config):
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("..", "."))
if subfolder and dirname: if subfolder and dirname:
return dirname / subfolder / name.expanduser() return dirname / subfolder / name.expanduser()
elif subfolder: elif subfolder: