|
@@ -34,7 +34,7 @@ class ID3(_mutagen):
|
|
|
def get_free_int(self, tag_label):
|
|
|
tags = [t for t in self.get_free_ints(tag_label)]
|
|
|
if len(tags) == 0:
|
|
|
- raise KeyError(tag_label)
|
|
|
+ return None
|
|
|
else:
|
|
|
assert len(tags) == 1, tags
|
|
|
assert tags[0][0] == tag_label, tag
|
|
@@ -94,16 +94,22 @@ class MP4(_mutagen):
|
|
|
def _get_free(self, tag_label):
|
|
|
# freeform keys start with '----'
|
|
|
# http://mutagen.readthedocs.io/en/latest/api/mp4.html
|
|
|
- tags = self._mutagen_file.tags['----:' + tag_label]
|
|
|
- assert len(tags) == 1, tags
|
|
|
- return tags[0]
|
|
|
+ try:
|
|
|
+ tags = self._mutagen_file.tags['----:' + tag_label]
|
|
|
+ except KeyError:
|
|
|
+ return None
|
|
|
+ if len(tags) == 1:
|
|
|
+ return tags[0]
|
|
|
+ else:
|
|
|
+ raise ValueError(tags)
|
|
|
|
|
|
def get_free_int(self, tag_label):
|
|
|
- return MP4._freeform_to_int(self._get_free(tag_label))
|
|
|
+ t = self._get_free(tag_label)
|
|
|
+ return None if t is None else MP4._freeform_to_int(t)
|
|
|
|
|
|
def _get_free_uuid(self, tag_label):
|
|
|
tag = self._get_free(tag_label)
|
|
|
- assert tag.dataformat == mutagen.mp4.AtomDataType.UUID, tag.dataformat
|
|
|
+ assert tag is None or tag.dataformat == mutagen.mp4.AtomDataType.UUID, tag.dataformat
|
|
|
return tag
|
|
|
|
|
|
def set_free_int(self, tag_label, data):
|
|
@@ -128,10 +134,7 @@ class MP4(_mutagen):
|
|
|
return tag
|
|
|
|
|
|
def get_track_uuid(self):
|
|
|
- try:
|
|
|
- return self._get_free_uuid(self._UUID_TAG_KEY)
|
|
|
- except KeyError:
|
|
|
- return None
|
|
|
+ return self._get_free_uuid(self._UUID_TAG_KEY)
|
|
|
|
|
|
def set_track_uuid(self, uuid):
|
|
|
return self._set_free_uuid(self._UUID_TAG_KEY, uuid)
|