Skip to content

Commit

Permalink
Add support for splitting of ID3v2.3 multi-value tags for MP3ListDesc…
Browse files Browse the repository at this point in the history
…StorageStyle

fixes rest of problems in beetbox#43

Shouldn't be enabled on tags like `artists` or other without confidence that values will not contain separator (eg. `artists: ['AC/DC']`).
Format of mbid is known and I'm sure we can enable it here.

When solving beetbox#21 this separator value in `el.split('/')` also should be taken into account.
  • Loading branch information
JuniorJPDJ committed May 16, 2021
1 parent 42300c7 commit 341db18
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions mediafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,14 +897,19 @@ def delete(self, mutagen_file):


class MP3ListDescStorageStyle(MP3DescStorageStyle, ListStorageStyle):
def __init__(self, desc=u'', key='TXXX', **kwargs):
super(MP3ListDescStorageStyle, self).__init__(desc=desc, key=key,
**kwargs)
def __init__(self, desc=u'', key='TXXX', split_v23=False, **kwargs):
self.split_v23 = split_v23
super(MP3ListDescStorageStyle, self).__init__(
desc=desc, key=key, **kwargs
)

def fetch(self, mutagen_file):
for frame in mutagen_file.tags.getall(self.key):
if frame.desc.lower() == self.description.lower():
return frame.text
if mutagen_file.tags.version == (2, 3, 0) and self.split_v23:
return sum([el.split('/') for el in frame.text], start=[])
else:
return frame.text
return []

def store(self, mutagen_file, values):
Expand Down

0 comments on commit 341db18

Please sign in to comment.