Skip to content

Instantly share code, notes, and snippets.

@rinsuki
Created August 31, 2024 15:58
Show Gist options
  • Save rinsuki/d3526c637ee6a1ac0bc10b55a0ef426b to your computer and use it in GitHub Desktop.
Save rinsuki/d3526c637ee6a1ac0bc10b55a0ef426b to your computer and use it in GitHub Desktop.
Load wav file with Shift-JIS RIFF INFO chunks w/ MusicBrainz Picard
from picard import log
from picard.formats.wav import RiffListInfo
PLUGIN_API_VERSIONS = ["2.2"]
# trying to patch here https://github.com/metabrainz/picard/blob/4d49ac4bfb9bed3c87ddd843d81235561b3b32bd/picard/formats/wav.py#L143-L149
@staticmethod
def decode(value: bytes):
log.debug(f"patched decoder {value}")
try:
value = value.decode('utf-8')
except UnicodeDecodeError:
value = value.decode('shift-jis')
return value.rstrip('\0')
# https://docs.python.org/3/tutorial/classes.html#private-variables
RiffListInfo._RiffListInfo__decode_data = decode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment