Minor filename encoding improvement in a common case

This commit is contained in:
Philipp Hagemeister 2012-11-27 15:07:10 +01:00
parent fa59f4b6a9
commit 46cbda0be4
2 changed files with 10 additions and 0 deletions

View file

@ -218,6 +218,9 @@ def sanitize_filename(s, restricted=False):
while '__' in result:
result = result.replace('__', '_')
result = result.strip('_')
# Common case of "Foreign band name - English song title"
if restricted and result.startswith('-_'):
result = result[2:]
if not result:
result = '_'
return result