mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-01-07 17:16:08 +00:00
improved performance by extracting accented chars to top level
This commit is contained in:
parent
31c4448f6e
commit
c587cbb793
|
@ -89,6 +89,11 @@ KNOWN_EXTENSIONS = (
|
||||||
'wav',
|
'wav',
|
||||||
'f4f', 'f4m', 'm3u8', 'smil')
|
'f4f', 'f4m', 'm3u8', 'smil')
|
||||||
|
|
||||||
|
# needed for sanitizing filenames in restricted mode
|
||||||
|
ACCENT_CHARS = dict(zip('ÂÃÄÀÁÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ',
|
||||||
|
itertools.chain('AAAAAA', ['AE'], 'CEEEEIIIIDNOOOOOOUUUUYP', ['ss'],
|
||||||
|
'aaaaaa', ['ae'], 'ceeeeiiiionoooooouuuuypy')))
|
||||||
|
|
||||||
|
|
||||||
def preferredencoding():
|
def preferredencoding():
|
||||||
"""Get preferred encoding.
|
"""Get preferred encoding.
|
||||||
|
@ -365,11 +370,8 @@ def sanitize_filename(s, restricted=False, is_id=False):
|
||||||
Set is_id if this is not an arbitrary string, but an ID that should be kept if possible
|
Set is_id if this is not an arbitrary string, but an ID that should be kept if possible
|
||||||
"""
|
"""
|
||||||
def replace_insane(char):
|
def replace_insane(char):
|
||||||
accents = dict(zip('ÂÃÄÀÁÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ',
|
if restricted and char in ACCENT_CHARS:
|
||||||
itertools.chain('AAAAAA', ['AE'], 'CEEEEIIIIDNOOOOOOUUUUYP', ['ss'],
|
return ACCENT_CHARS[char]
|
||||||
'aaaaaa', ['ae'], 'ceeeeiiiionoooooouuuuypy')))
|
|
||||||
if restricted and char in accents:
|
|
||||||
return accents[char]
|
|
||||||
if char == '?' or ord(char) < 32 or ord(char) == 127:
|
if char == '?' or ord(char) < 32 or ord(char) == 127:
|
||||||
return ''
|
return ''
|
||||||
elif char == '"':
|
elif char == '"':
|
||||||
|
|
Loading…
Reference in a new issue