From 4f9d64a28414f029f3714614ee5c710962f9bab4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Koch-Kramer?= <koch-kramer@web.de> Date: Mon, 6 May 2019 17:42:59 +0200 Subject: [PATCH] Replace non filename compatible chars in fields Values that got inserted in dirname and filename pattern get cleared from characters that will not work in filenames. This is also helpful for #262. --- instaloader/instaloader.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/instaloader/instaloader.py b/instaloader/instaloader.py index 6182bb6..f52081e 100644 --- a/instaloader/instaloader.py +++ b/instaloader/instaloader.py @@ -111,6 +111,16 @@ class _PostPathFormatter(_ArbitraryItemFormatter): ret = ret.replace('\\', '\ufe68').replace('|', '\uff5c').replace('?', '\ufe16').replace('*', '\uff0a') return ret + def get_value(self, key, args, kwargs): + """Replaces '/' with similar looking Division Slash and on windows newline with space""" + ret = super().get_value(key, args, kwargs) + if not isinstance(ret, str): + return ret + ret = ret.replace('/', '\u2215') + if platform.system() == 'Windows': + ret = ret.replace('\n', ' ') + return ret + class Instaloader: """Instaloader Class.