PICARD-1589: Support language for ID3 comments.

Adds syntax "comment:{language}:{description}" in addition to existing "comment:{description}" for comment tag names.
This commit is contained in:
Philipp Wolfer
2019-09-04 18:51:03 +02:00
committed by Philipp Wolfer
parent f5aa26095e
commit 4d85c2e31f
5 changed files with 54 additions and 6 deletions

View File

@@ -87,6 +87,7 @@ TAGS = {
'catalognumber': 'Foo',
'comment:': 'Foo',
'comment:foo': 'Foo',
'comment:deu:foo': 'Foo',
'compilation': '1',
'composer': 'Foo',
'composersort': 'Foo',

View File

@@ -101,14 +101,18 @@ class CommonId3Tests:
def test_comment_delete(self):
metadata = Metadata(self.tags)
metadata['comment:bar'] = 'Foo'
metadata['comment:XXX:withlang'] = 'Foo'
original_metadata = save_and_load_metadata(self.filename, metadata)
del metadata['comment:bar']
del metadata['comment:XXX:withlang']
new_metadata = save_and_load_metadata(self.filename, metadata)
self.assertIn('comment:foo', original_metadata)
self.assertIn('comment:bar', original_metadata)
self.assertIn('comment:XXX:withlang', original_metadata)
self.assertIn('comment:foo', new_metadata)
self.assertNotIn('comment:bar', new_metadata)
self.assertNotIn('comment:XXX:withlang', new_metadata)
@skipUnlessTestfile
def test_id3v23_simple_tags(self):

18
test/test_util_tags.py Normal file
View File

@@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from test.picardtestcase import PicardTestCase
from picard.util.tags import (
display_tag_name,
parse_comment_tag,
)
class UtilTagsTest(PicardTestCase):
def test_display_tag_name(self):
self.assertEqual('Artist', display_tag_name('artist'))
self.assertEqual('Lyrics', display_tag_name('lyrics:'))
self.assertEqual('Comment [Foo]', display_tag_name('comment:Foo'))
def test_parse_comment_tag(self):
self.assertEqual(('XXX', 'foo'), parse_comment_tag('comment:XXX:foo'))
self.assertEqual(('eng', 'foo'), parse_comment_tag('comment:foo'))