Open
Description
I need to read/write the ID3 Popularimeter tag within my app, specifically in the way that Native Instruments Traktor writes them.
This is a sample file containing the tag as written by Traktor:
https://github.com/ifischer/django-tracks-api/raw/master/tracks_api/tests/fixtures/popm.mp3
This is how mutagen-inspect shows it on command line:
$ mutagen-inspect tracks_api/tests/fixtures/popm.mp3
-- tracks_api/tests/fixtures/popm.mp3
- MPEG 1 layer 3, 32678 bps (VBR), 44100 Hz, 1 chn, 5.04 seconds (audio/mp3)
[email protected]=0 102/255
TSSE=Lavf57.83.100
So far I'm using pure mutagen in my app to do it:
from mutagen.id3 import ID3
from mutagen.id3 import POPM
ID3_POPM = 'POPM'
class SimpleID3(ID3):
def __init__(self, filename):
super().__init__(filename)
@property
def rating(self):
rating = self.getall(ID3_POPM)
if rating:
rating = rating[0].rating
return int(rating / 51)
return None
@rating.setter
def rating(self, rating: int):
popm = POPM(email='[email protected]', rating=rating * 51, count=0)
self[ID3_POPM] = popm
How can I achieve something similar with mediafile, adding the popularimeter tag as a custom field?
Metadata
Assignees
Labels
No labels