mirror of
https://github.com/fergalmoran/picard.git
synced 2026-01-04 07:33:59 +00:00
Three parts: (1) The monkey patching of EncodedTextSpec to ignore encoding errors when using latin1 as encoding. This gets replaced with a new id3text function which makes sure that any value passed to mutagen can be encoded with the selected encoding (2) MultiSpec monkey patch to not null terminate a list of strings. While this is valid according to the spec mutagen decided to terminate all strings (not only the text lists handled here). If this is a problem it should be discussed upstream (mutagen). (3) compatid3 which implemented id3v2.3 support and added some additional frames. This gets replaced with the id3v2.3 support implemented upstream. The additional frames still get passed to mutagen and, to match the previous implementation, update_to_v23() gets wrapped to allow some v2.4 only frames. The newly added id3v2.3 code depends on mutagen 1.22+
64 lines
2.3 KiB
Python
64 lines
2.3 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
import unittest
|
|
from mutagen import id3
|
|
from picard.formats.mutagenext import compatid3
|
|
from picard.formats.id3 import id3text
|
|
|
|
|
|
class UpdateToV23Test(unittest.TestCase):
|
|
|
|
def test_id3text(self):
|
|
self.assertEqual(id3text(u"\u1234", 0), u"?")
|
|
self.assertEqual(id3text(u"\u1234", 1), u"\u1234")
|
|
self.assertEqual(id3text(u"\u1234", 2), u"\u1234")
|
|
self.assertEqual(id3text(u"\u1234", 3), u"\u1234")
|
|
|
|
def test_keep_some_v24_tag(self):
|
|
tags = compatid3.CompatID3()
|
|
tags.add(id3.TSOP(encoding=0, text=["foo"]))
|
|
tags.add(id3.TSOA(encoding=0, text=["foo"]))
|
|
tags.add(id3.TSOT(encoding=0, text=["foo"]))
|
|
tags.update_to_v23()
|
|
self.assertEqual(tags["TSOP"].text, ["foo"])
|
|
self.assertEqual(tags["TSOA"].text, ["foo"])
|
|
self.assertEqual(tags["TSOT"].text, ["foo"])
|
|
|
|
def test_tdrc(self):
|
|
tags = compatid3.CompatID3()
|
|
tags.add(id3.TDRC(encoding=1, text="2003-04-05 12:03"))
|
|
tags.update_to_v23()
|
|
self.assertEqual(tags["TYER"].text, ["2003"])
|
|
self.assertEqual(tags["TDAT"].text, ["0504"])
|
|
self.assertEqual(tags["TIME"].text, ["1203"])
|
|
|
|
def test_tdor(self):
|
|
tags = compatid3.CompatID3()
|
|
tags.add(id3.TDOR(encoding=1, text="2003-04-05 12:03"))
|
|
tags.update_to_v23()
|
|
self.assertEqual(tags["TORY"].text, ["2003"])
|
|
|
|
def test_genre_from_v24_1(self):
|
|
tags = compatid3.CompatID3()
|
|
tags.add(id3.TCON(encoding=1, text=["4", "Rock"]))
|
|
tags.update_to_v23()
|
|
self.assertEqual(tags["TCON"].text, ["Disco", "Rock"])
|
|
|
|
def test_genre_from_v24_2(self):
|
|
tags = compatid3.CompatID3()
|
|
tags.add(id3.TCON(encoding=1, text=["RX", "3", "CR"]))
|
|
tags.update_to_v23()
|
|
self.assertEqual(tags["TCON"].text, ["Remix", "Dance", "Cover"])
|
|
|
|
def test_genre_from_v23_1(self):
|
|
tags = compatid3.CompatID3()
|
|
tags.add(id3.TCON(encoding=1, text=["(4)Rock"]))
|
|
tags.update_to_v23()
|
|
self.assertEqual(tags["TCON"].text, ["Disco", "Rock"])
|
|
|
|
def test_genre_from_v23_2(self):
|
|
tags = compatid3.CompatID3()
|
|
tags.add(id3.TCON(encoding=1, text=["(RX)(3)(CR)"]))
|
|
tags.update_to_v23()
|
|
self.assertEqual(tags["TCON"].text, ["Remix", "Dance", "Cover"])
|