Skip to content

Commit

Permalink
id3: v2_version shouldn't affect the result if no translation happens…
Browse files Browse the repository at this point in the history
…. See #357

In case of no translation use the version of the tag we are loading.
  • Loading branch information
lazka committed Oct 30, 2018
1 parent 6507b1d commit 7f3ee50
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mutagen/id3/_file.py
Expand Up @@ -180,7 +180,11 @@ class XMYF(Frame): ...
self.update_to_v24()

if self._header and load_v1:
frames, offset = find_id3v1(fileobj, v2_version, known_frames)
if translate:
v1v2_ver = v2_version
else:
v1v2_ver = 4 if self.version[1] == 4 else 3
frames, offset = find_id3v1(fileobj, v1v2_ver, known_frames)
if frames:
for v in frames.values():
if len(self.getall(v.HashKey)) == 0:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_id3.py
Expand Up @@ -133,6 +133,14 @@ def test_load_v1_v2(self):
with self.assertRaises(KeyError):
tags["TALB"]

def test_load_v1_v2_no_translate(self):
tags = ID3(self.v1v2_combined, v2_version=4, translate=False)
assert tags.version == (2, 4, 0)
assert str(tags["TDRC"].text[0]) == "1337"
tags = ID3(self.v1v2_combined, v2_version=3, translate=False)
assert tags.version == (2, 4, 0)
assert str(tags["TDRC"].text[0]) == "1337"

def test_load_v1_v2_precedence(self):
tags = ID3(self.v1v2_combined)
self.assertEquals(tags["TRCK"].text, ["3/11"]) # i.e. not 123
Expand Down

0 comments on commit 7f3ee50

Please sign in to comment.