mirror of
https://github.com/fergalmoran/picard.git
synced 2026-03-06 21:35:09 +00:00
Save TSOP/TSOT/TSOA/TSO2 frames even to ID3v2.3
http://tickets.musicbrainz.org/browse/PICARD-122
This commit is contained in:
@@ -57,6 +57,10 @@ id3.MultiSpec._write_orig = id3.MultiSpec.write
|
||||
id3.MultiSpec.write = patched_MultiSpec_write
|
||||
|
||||
|
||||
id3.TCMP = compatid3.TCMP
|
||||
id3.TSO2 = compatid3.TSO2
|
||||
|
||||
|
||||
class ID3File(File):
|
||||
"""Generic ID3-based file."""
|
||||
_File = None
|
||||
@@ -64,7 +68,7 @@ class ID3File(File):
|
||||
|
||||
__upgrade = {
|
||||
'XSOP': 'TSOP',
|
||||
'XDOR': 'TDRC',
|
||||
'TXXX:ALBUMARTISTSORT': 'TSO2',
|
||||
}
|
||||
|
||||
__translate = {
|
||||
@@ -92,6 +96,7 @@ class ID3File(File):
|
||||
'TENC': 'encodedby',
|
||||
'TCOP': 'copyright',
|
||||
'TSOA': 'albumsort',
|
||||
'TSO2': 'albumartistsort',
|
||||
'TSOP': 'artistsort',
|
||||
'TSOT': 'titlesort',
|
||||
'TPUB': 'label',
|
||||
@@ -114,7 +119,6 @@ class ID3File(File):
|
||||
'Acoustid Fingerprint': 'acoustid_fingerprint',
|
||||
'Acoustid Id': 'acoustid_id',
|
||||
'SCRIPT': 'script',
|
||||
'ALBUMARTISTSORT': 'albumartistsort',
|
||||
'CATALOGNUMBER': 'catalognumber',
|
||||
'BARCODE': 'barcode',
|
||||
'ASIN': 'asin',
|
||||
@@ -243,7 +247,6 @@ class ID3File(File):
|
||||
tmcl = mutagen.id3.TMCL(encoding=encoding, people=[])
|
||||
tipl = mutagen.id3.TIPL(encoding=encoding, people=[])
|
||||
|
||||
id3.TCMP = compatid3.TCMP
|
||||
tags.delall('TCMP')
|
||||
for name, values in metadata.rawitems():
|
||||
if name.startswith('performer:'):
|
||||
@@ -287,6 +290,12 @@ class ID3File(File):
|
||||
tags.add(getattr(id3, frameid)(url=values[0]))
|
||||
elif frameid.startswith('T'):
|
||||
tags.add(getattr(id3, frameid)(encoding=encoding, text=values))
|
||||
if frameid == 'TSOA':
|
||||
tags.delall('XSOA')
|
||||
elif frameid == 'TSOP':
|
||||
tags.delall('XSOP')
|
||||
elif frameid == 'TSO2':
|
||||
tags.delall('TXXX:ALBUMARTISTSORT')
|
||||
elif name in self.__rtranslate_freetext:
|
||||
tags.add(id3.TXXX(encoding=encoding, desc=self.__rtranslate_freetext[name], text=values))
|
||||
elif name.startswith('~id3:'):
|
||||
@@ -307,9 +316,6 @@ class ID3File(File):
|
||||
tags.update_to_v23()
|
||||
tags.save(encode_filename(filename), v2=3, v1=v1)
|
||||
else:
|
||||
# remove all custom 2.3 frames
|
||||
for old in self.__upgrade.keys():
|
||||
tags.delall(old)
|
||||
tags.update_to_v24()
|
||||
tags.save(encode_filename(filename), v2=4, v1=v1)
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ from mutagen.id3 import ID3, Frame, Frames, Frames_2_2, TextFrame, TORY, \
|
||||
class TCMP(TextFrame):
|
||||
pass
|
||||
|
||||
class TSO2(TextFrame):
|
||||
pass
|
||||
|
||||
class XDOR(TextFrame):
|
||||
pass
|
||||
|
||||
@@ -49,6 +52,7 @@ class CompatID3(ID3):
|
||||
known_frames = dict(Frames)
|
||||
known_frames.update(dict(Frames_2_2))
|
||||
known_frames["TCMP"] = TCMP
|
||||
known_frames["TSO2"] = TSO2
|
||||
known_frames["XDOR"] = XDOR
|
||||
known_frames["XSOP"] = XSOP
|
||||
kwargs["known_frames"] = known_frames
|
||||
@@ -212,13 +216,12 @@ class CompatID3(ID3):
|
||||
# ID3v2.2 LNK frames are just way too different to upgrade.
|
||||
self.delall("LINK")
|
||||
|
||||
if "TSOP" in self:
|
||||
f = self.pop("TSOP")
|
||||
self.add(XSOP(encoding=f.encoding, text=f.text))
|
||||
# leave TSOP, TSOA and TSOT even though they are officially defined
|
||||
# only in ID3v2.4, because most applications use them also in ID3v2.3
|
||||
|
||||
# New frames added in v2.4.
|
||||
for key in ["ASPI", "EQU2", "RVA2", "SEEK", "SIGN", "TDRL", "TDTG",
|
||||
"TMOO", "TPRO", "TSOA", "TSOT", "TSST"]:
|
||||
"TMOO", "TPRO", "TSST"]:
|
||||
if key in self: del(self[key])
|
||||
|
||||
for frame in self.values():
|
||||
|
||||
Reference in New Issue
Block a user