Strip surrounding whitespace in filenames
Such spaces are annoying enough to deal with, and break external downloaders trying to be smart (such as aria2c). Fixes #20312.
This commit is contained in:
parent
118f7add3b
commit
422a413bd5
@ -509,7 +509,7 @@ def sanitize_filename(s, restricted=False, is_id=False):
|
|||||||
if not is_id:
|
if not is_id:
|
||||||
while '__' in result:
|
while '__' in result:
|
||||||
result = result.replace('__', '_')
|
result = result.replace('__', '_')
|
||||||
result = result.strip('_')
|
result = result.strip(' _')
|
||||||
# Common case of "Foreign band name - English song title"
|
# Common case of "Foreign band name - English song title"
|
||||||
if restricted and result.startswith('-_'):
|
if restricted and result.startswith('-_'):
|
||||||
result = result[2:]
|
result = result[2:]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user