Commit 83bb68c1 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Merge branch '267-split-slash' into 'develop'

Resolve "Split on / when tag fields contains multiple uuids"

Closes #267

See merge request funkwhale/funkwhale!230
parents bbfc48e6 7c473488
......@@ -91,10 +91,23 @@ def convert_track_number(v):
class FirstUUIDField(forms.UUIDField):
def to_python(self, value):
# sometimes, Picard leaves to uuids in the field, separated
# by a slash
value = value.split('/')[0]
except (AttributeError, IndexError, TypeError):
return super().to_python(value)
'musicbrainz_artistid': forms.UUIDField(),
'musicbrainz_albumid': forms.UUIDField(),
'musicbrainz_recordingid': forms.UUIDField(),
'musicbrainz_artistid': FirstUUIDField(),
'musicbrainz_albumid': FirstUUIDField(),
'musicbrainz_recordingid': FirstUUIDField(),
CONF = {
......@@ -95,3 +95,17 @@ def test_can_get_metadata_from_flac_file_not_crash_if_empty():
with pytest.raises(metadata.TagNotFound):
@pytest.mark.parametrize('field_name', [
def test_mbid_clean_keeps_only_first(field_name):
u1 = str(uuid.uuid4())
u2 = str(uuid.uuid4())
field = metadata.VALIDATION[field_name]
result = field.to_python('/'.join([u1, u2]))
assert str(result) == u1
Do not crash when tag contains multiple uuids with a / separator (#267)
Supports Markdown
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