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.
master
Jordan Atwood 9 months ago
parent 8c2f67f31f
commit 318a000251
Signed by: nightfirecat
GPG Key ID: 615A619C2D73A6DF
  1. 2
      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:

Loading…
Cancel
Save