Fixed comment unit tests and fixed loading/saving comments in vorbis, apev2 and mp4.

This commit is contained in:
Philipp Wolfer
2010-04-12 18:59:05 +02:00
parent d7873c1f1b
commit 82d070ad9f
4 changed files with 23 additions and 23 deletions

View File

@@ -77,12 +77,13 @@ class APEv2File(File):
if len(disc) > 1:
metadata["totaldiscs"] = disc[1]
value = disc[0]
elif name == 'Performer' and value.endswith(')'):
name = name.lower()
start = value.rfind(' (')
if start > 0:
name += ':' + value[start + 2:-1]
value = value[:start]
elif name == 'Performer' or name == 'Comment':
name = name.lower() + ':'
if value.endswith(')'):
start = value.rfind(' (')
if start > 0:
name += value[start + 2:-1]
value = value[:start]
elif name in self.__translate:
name = self.__translate[name]
else:

View File

@@ -36,6 +36,7 @@ class MP4File(File):
"\xa9day": "date",
"\xa9gen": "genre",
"\xa9lyr": "lyrics",
"\xa9cmt": "comment:",
"\xa9too": "encodedby",
"cprt": "copyright",
"soal": "albumsort",

View File

@@ -43,7 +43,7 @@ class VCommentFile(File):
if name == "date" or name == "originaldate":
# YYYY-00-00 => YYYY
value = sanitize_date(value)
elif name == 'performer':
elif name == 'performer' or name == 'comment':
# transform "performer=Joe Barr (Piano)" to "performer:Piano=Joe Barr"
name += ':'
if value.endswith(')'):

View File

@@ -75,6 +75,8 @@ class FormatsTest(unittest.TestCase):
metadata[key] = value
loaded_metadata = save_and_load_metadata(self.filename, metadata)
for (key, value) in self.tags.iteritems():
#if key == 'comment:foo':
# print "%r" % loaded_metadata
self.assertEqual(loaded_metadata[key], value, '%s: %r != %r' % (key, loaded_metadata[key], value))
def test_ratings(self):
@@ -118,9 +120,8 @@ class FLACTest(FormatsTest):
'discnumber' : '1',
'totaldiscs' : '2',
'compilation' : '1',
# FIXME: comment is not tested properly
#'comment' : 'Foo',
#'comment:foo' : 'Foo',
'comment:' : 'Foo',
'comment:foo' : 'Foo',
'genre' : 'Foo',
'bpm' : '80',
'mood' : 'Foo',
@@ -186,8 +187,8 @@ class WMATest(FormatsTest):
'discnumber' : '1',
#'totaldiscs' : '2',
#'compilation' : '1',
# FIXME: comment is not tested properly
#'comment' : 'Foo',
'comment:' : 'Foo',
# FIXME: comment:foo is unsupported in our WMA implementation
#'comment:foo' : 'Foo',
'genre' : 'Foo',
'bpm' : '80',
@@ -254,9 +255,8 @@ class MP3Test(FormatsTest):
'discnumber' : '1',
'totaldiscs' : '2',
'compilation' : '1',
# FIXME: comment is not tested properly
#'comment' : 'Foo',
#'comment:foo' : 'Foo',
'comment:' : 'Foo',
'comment:foo' : 'Foo',
'genre' : 'Foo',
'bpm' : '80',
'mood' : 'Foo',
@@ -322,9 +322,8 @@ class OggVorbisTest(FormatsTest):
'discnumber' : '1',
'totaldiscs' : '2',
'compilation' : '1',
# FIXME: comment is not tested properly
#'comment' : 'Foo',
#'comment:foo' : 'Foo',
'comment:' : 'Foo',
'comment:foo' : 'Foo',
'genre' : 'Foo',
'bpm' : '80',
'mood' : 'Foo',
@@ -390,8 +389,8 @@ class MP4Test(FormatsTest):
'discnumber' : '1',
'totaldiscs' : '2',
'compilation' : '1',
# FIXME: comment is not tested properly
#'comment' : 'Foo',
'comment:' : 'Foo',
# FIXME: comment:foo is unsupported in our MP4 implementation
#'comment:foo' : 'Foo',
'genre' : 'Foo',
'bpm' : '80',
@@ -458,9 +457,8 @@ class WavPackTest(FormatsTest):
'discnumber' : '1',
'totaldiscs' : '2',
'compilation' : '1',
# FIXME: comment is not tested properly
#'comment' : 'Foo',
#'comment:foo' : 'Foo',
'comment:' : 'Foo',
'comment:foo' : 'Foo',
'genre' : 'Foo',
'bpm' : '80',
'mood' : 'Foo',