Skip to content
Snippets Groups Projects
Verified Commit e29cfb73 authored by Eliot Berriot's avatar Eliot Berriot
Browse files

Smarted UUID validation on metadata

parent 74e7aed2
Branches
Tags
No related merge requests found
import mutagen from django import forms
import arrow import arrow
import mutagen
NODEFAULT = object() NODEFAULT = object()
...@@ -50,6 +51,13 @@ def convert_track_number(v): ...@@ -50,6 +51,13 @@ def convert_track_number(v):
except (ValueError, AttributeError, IndexError): except (ValueError, AttributeError, IndexError):
pass pass
VALIDATION = {
'musicbrainz_artistid': forms.UUIDField(),
'musicbrainz_albumid': forms.UUIDField(),
'musicbrainz_recordingid': forms.UUIDField(),
}
CONF = { CONF = {
'OggVorbis': { 'OggVorbis': {
'getter': lambda f, k: f[k][0], 'getter': lambda f, k: f[k][0],
...@@ -146,4 +154,7 @@ class Metadata(object): ...@@ -146,4 +154,7 @@ class Metadata(object):
converter = field_conf.get('to_application') converter = field_conf.get('to_application')
if converter: if converter:
v = converter(v) v = converter(v)
field = VALIDATION.get(key)
if field:
v = field.to_python(v)
return v return v
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment