Skip to content

Commit

Permalink
Update 'extra' fields with data from other tags (#188)
Browse files Browse the repository at this point in the history
Fixes #187
  • Loading branch information
mathiascode committed Oct 23, 2023
1 parent 21e65cd commit 1276c4c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Binary file added tinytag/tests/samples/aiff_extra_tags.aiff
Binary file not shown.
8 changes: 7 additions & 1 deletion tinytag/tests/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@
{'extra': {}, 'filesize': 4692, 'bitrate': 10.186943678613627, 'channels': 2,
'duration': 3.68, 'samplerate': 44100, 'bitdepth': 16}),
('samples/with_id3_header.flac',
{'extra': {}, 'filesize': 64837, 'album': ' ', 'artist': '群星', 'disc': '0',
{'extra': {'text': 'ID\x00\ufeff8591671910'}, 'filesize': 64837, 'album': ' ',
'artist': '群星', 'disc': '0',
'title': 'A 梦 哆啦 机器猫 短信铃声', 'track': '0', 'bitrate': 1143.72468, 'channels': 1,
'duration': 0.45351473922902497, 'genre': 'genre', 'samplerate': 44100, 'bitdepth': 16,
'year': '2018'}),
Expand Down Expand Up @@ -390,6 +391,7 @@
'comment': 'test comment',
'duration': 727.1066666666667,
'extra': {'description': 'test description'}}),

# AIFF
('samples/test-tagged.aiff',
{'extra': {}, 'channels': 2, 'duration': 1.0, 'filesize': 177620, 'artist': 'theartist',
Expand All @@ -413,6 +415,10 @@
'AFspdate: 2003-01-30 03:28:34 UTC\x00user: kabal@CAPELLA\x00program: CopyAudio'}),
('samples/invalid_sample_rate.aiff',
{'extra': {}, 'channels': 1, 'filesize': 4096, 'bitdepth': 16}),
('samples/aiff_extra_tags.aiff',
{'extra': {'isrc': 'CC-XXX-YY-NNNNN'}, 'channels': 1, 'duration': 2.176,
'filesize': 18532, 'bitrate': 64.0, 'samplerate': 8000, 'bitdepth': 8,
'title': 'song title', 'artist': 'artist 1;artist 2', 'audio_offset': 46}),

])

Expand Down
2 changes: 2 additions & 0 deletions tinytag/tinytag.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,8 @@ def update(self, other, all_fields=False):
'_image_data']:
if not getattr(self, key) and getattr(other, key):
setattr(self, key, getattr(other, key))
if other.extra:
self.extra.update(other.extra)

@staticmethod
def _unpad(s):
Expand Down

0 comments on commit 1276c4c

Please sign in to comment.