aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2012-11-27 12:46:09 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2012-11-27 12:46:09 +0100
commit56781d3d2e476e2e109d0907d89548fd4da05058 (patch)
tree577de167abd61a1a59e6160ed419247ecc018ddb /youtube_dl/utils.py
parented7516c69dbd676d0d98581756a483f19407fae4 (diff)
Switch back to underline for invalid characters, and make restricted ASCII-only
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py13
1 files changed, 9 insertions, 4 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 1f60d34ae..3339f56ec 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -207,15 +207,20 @@ def sanitize_filename(s, restricted=False):
elif char == ':':
return '_-' if restricted else ' -'
elif char in '\\/|*<>':
- return '-'
+ return '_'
if restricted and (char in '&\'' or char.isspace()):
return '_'
+ if restricted and ord(char) > 127:
+ return '_'
return char
result = u''.join(map(replace_insane, s))
- while '--' in result:
- result = result.replace('--', '-')
- return result.strip('-')
+ while '__' in result:
+ result = result.replace('__', '_')
+ result = result.strip('_')
+ if not result:
+ result = '_'
+ return result
def orderedSet(iterable):
""" Remove all duplicates from the input iterable """