Merge branch '214-flac-no-mbid' into 'develop'

Resolve "Flac import fails if no MusicBrainz-ID present"

Closes #214

See merge request funkwhale/funkwhale!208
merge-requests/237/head
Eliot Berriot 2018-05-22 21:57:44 +00:00
commit b36ed8a699
3 zmienionych plików z 13 dodań i 1 usunięć

Wyświetl plik

@ -30,7 +30,7 @@ def get_id3_tag(f, k):
def get_flac_tag(f, k):
try:
return f.get(k)[0]
return f.get(k, [])[0]
except (KeyError, IndexError):
raise TagNotFound(k)
@ -158,6 +158,9 @@ CONF = {
'musicbrainz_recordingid': {
'field': 'musicbrainz_trackid'
},
'test': {
'field': 'test'
},
}
},
}

Wyświetl plik

@ -57,3 +57,11 @@ def test_can_get_metadata_from_flac_file(field, value):
data = metadata.Metadata(path)
assert data.get(field) == value
def test_can_get_metadata_from_flac_file_not_crash_if_empty():
path = os.path.join(DATA_DIR, 'sample.flac')
data = metadata.Metadata(path)
with pytest.raises(metadata.TagNotFound):
data.get('test')

Wyświetl plik

@ -0,0 +1 @@
Do not crash on flac import if musicbrainz tags are missing (#214)