Implements https://github.com/ytdl-org/youtube-dl/issues/31216#issuecomment-
1236102822, which has a test.
import tempfile
import time
import traceback
+import unicodedata
import xml.etree.ElementTree
import zlib
return '_'
return char
+ # Replace look-alike Unicode glyphs
+ if restricted and not is_id:
+ s = unicodedata.normalize('NFKC', s)
# Handle timestamps
s = re.sub(r'[0-9]+(?::[0-9]+)+', lambda m: m.group(0).replace(':', '_'), s)
result = ''.join(map(replace_insane, s))