0

I tried mutagen EasyID3 class to retrieve this tag (on mp3s I am sure this tag exist) and it doesnt show up in the list of tags returned.

It is the Itunes rating tag I am talking about.

It seems I lack an important information about this particular tag (different standards? not an ID3?) but I couldn't find any help in the mutagen documentation.

Yannick
  • 1,550
  • 4
  • 18
  • 27

2 Answers2

1

Like previously stated, iTunes doesn't store ratings in mp3 tags. The ratings are stored in the file 'iTunes Music Library.xml', which is usually found in the folder '\Music\iTunes'.

You can access the star ratings with help from the win32com library. Use pip to install the module. Go here to see the latest version:

https://pypi.org/project/pywin32/

I typically use this module by selecting a group of tracks in iTunes and looping through them. That means you need to open iTunes and go to a group of songs, let's say from an album. Select all those tracks, ctrl+a. Then go over to your python IDE, write your code, and run it. Use this as a template:

# import mutagen, however you need to
import win32com.client

itunes = win32com.client.Dispatch('iTunes.Application')
tracks = itunes.SelectedTracks
track_count = tracks.Count

while track_count:
    current_track = tracks.Item(track_count)
    rating = current_track.Rating
    location = current_track.Location
    # Do things in mutagen here
    track_count -= 1

So, within that loop, pass the location variable to whichever mutagen method/function you need to open the file. Then pass rating or str(rating) to the appropriate id3 field, which looks like the POPM field (which allows for a value of 1-255).

You do have a few other considerations to make here. Is the POPM rating field sufficient? Should you make your own id3 field for a 1-5, 0-100 rating?

Getting the Rating from iTunes is the easy part. Figuring out how you want to write that to an ID3 tag is the hard part.

avs
  • 19
  • 1
0

Looks like the Ratings in iTunes are not stored in the ID3 tags of the MP3s. Look at the discussion here https://discussions.apple.com/thread/256205?start=0&tstart=0

So there is no way Mutagen would be able to retrieve it.

Arunmozhi
  • 1,034
  • 8
  • 17
  • ok but where is it stored then? I use another software that can retrieve and edit this tag so I wonder how to get it in a python script – Yannick Nov 02 '17 at 02:54