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.
This commit is contained in:
André Koch-Kramer 2019-05-06 17:42:59 +02:00
parent 0c9a667da7
commit 4f9d64a284

View File

@ -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.