From 318a0002511140e6e0f4388c10f78f637dcc2552 Mon Sep 17 00:00:00 2001 From: Jordan Atwood Date: Mon, 15 Jan 2024 19:40:00 -0800 Subject: [PATCH] Munge unicode characters in music filenames This is primarily to ensure emojis are replaced as file names can't contain those when transferred via go-mtpfs. This has the side effect of encoding _all_ unicode characters, such as japanese characters, and other emoticons, but that's a small price to pay for such an easy fix. --- src/.bin/music-transfer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/.bin/music-transfer.py b/src/.bin/music-transfer.py index a281f27..99150c3 100755 --- a/src/.bin/music-transfer.py +++ b/src/.bin/music-transfer.py @@ -30,7 +30,7 @@ KNOWN_EXTENSIONS: Set[str] = set([ # see: https://stackoverflow.com/a/35352640/540162 # getting filesystem type can be done like so: https://stackoverflow.com/a/25286268/540162 def munge_path(path: str) -> str: - return re.sub(r'[\:*?"|<>]+', '-', path) + return re.sub(r'[\:*?"|<>]+', '-', path.encode('unicode_escape').decode('utf-8')) def main(): if len(sys.argv) != 3: