Commit 330d8c21 authored by Eliot Berriot's avatar Eliot Berriot 💬

Merge branch 'develop' into 'develop'

Add support for Opus files

Closes #244

See merge request !390
parents 093deb1e 3ce3451d
......@@ -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
......@@ -9,6 +9,26 @@ from funkwhale_api.music import metadata
DATA_DIR = os.path.dirname(os.path.abspath(__file__))
@pytest.mark.parametrize(
"field,value",
[
("title", "Peer Gynt Suite no. 1, op. 46: I. Morning"),
("artist", "Edvard Grieg"),
("album", "Peer Gynt Suite no. 1, op. 46"),
("date", datetime.date(2012, 8, 15)),
("track_number", 1),
("musicbrainz_albumid", uuid.UUID("a766da8b-8336-47aa-a3ee-371cc41ccc75")),
("musicbrainz_recordingid", uuid.UUID("bd21ac48-46d8-4e78-925f-d9cc2a294656")),
("musicbrainz_artistid", uuid.UUID("013c8e5b-d72a-4cd3-8dee-6c64d6125823")),
],
)
def test_can_get_metadata_from_opus_file(field, value):
path = os.path.join(DATA_DIR, "test.opus")
data = metadata.Metadata(path)
assert data.get(field) == value
@pytest.mark.parametrize(
"field,value",
[
......
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