Add support for Opus files

This adds support for reading metadata from Opus files. The metadata config
is copied from OggVorbis with just the 'track' field name changed.

Also make sure get_audio_file_data() in music/utils.py doesn't crash if no
bitrate information is set, since mutagen doesn't add a bitrate to Opus
info objects.

Fixes #244.
Signed-off-by: Toke Høiland-Jørgensen's avatarToke Høiland-Jørgensen <toke@toke.dk>
parent 6940d411
......@@ -114,6 +114,22 @@ VALIDATION = {
}
CONF = {
"OggOpus": {
"getter": lambda f, k: f[k][0],
"fields": {
"track_number": {
"field": "TRACKNUMBER",
"to_application": convert_track_number,
},
"title": {},
"artist": {},
"album": {},
"date": {"field": "date", "to_application": get_date},
"musicbrainz_albumid": {},
"musicbrainz_artistid": {},
"musicbrainz_recordingid": {"field": "musicbrainz_trackid"},
},
},
"OggVorbis": {
"getter": lambda f, k: f[k][0],
"fields": {
......
......@@ -54,7 +54,7 @@ def get_audio_file_data(f):
if not data:
return
d = {}
d["bitrate"] = data.info.bitrate
d["bitrate"] = getattr(data.info, "bitrate", 0)
d["length"] = data.info.length
return d
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment