mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-27 21:59:17 +01:00
improve windows lookalike characters
This commit is contained in:
parent
fca3eb5f8b
commit
3724350fb0
1 changed files with 12 additions and 2 deletions
|
@ -637,8 +637,18 @@ def sanitize_filename(s, restricted=False, is_id=NO_DEFAULT):
|
||||||
elif not restricted and char == '\n':
|
elif not restricted and char == '\n':
|
||||||
return '\0 '
|
return '\0 '
|
||||||
elif is_id is NO_DEFAULT and not restricted and char in '"*:<>?|/\\':
|
elif is_id is NO_DEFAULT and not restricted and char in '"*:<>?|/\\':
|
||||||
# Replace with their full-width unicode counterparts
|
# Replace with lookalike characters
|
||||||
return {'/': '\u29F8', '\\': '\u29f9'}.get(char, chr(ord(char) + 0xfee0))
|
return {
|
||||||
|
'"': '\u2033',
|
||||||
|
'*': '\uA60E',
|
||||||
|
':': '\u0589',
|
||||||
|
'<': '\u227A',
|
||||||
|
'>': '\u227B',
|
||||||
|
'?': '\uFF1F',
|
||||||
|
'|': '\u01C0',
|
||||||
|
'/': '\u29F8',
|
||||||
|
'\\': '\u29f9',
|
||||||
|
}[char]
|
||||||
elif char == '?' or ord(char) < 32 or ord(char) == 127:
|
elif char == '?' or ord(char) < 32 or ord(char) == 127:
|
||||||
return ''
|
return ''
|
||||||
elif char == '"':
|
elif char == '"':
|
||||||
|
|
Loading…
Reference in a new issue