[WS] iTunes

This is a web sources script for the music catalog of Apple's iTunes.

It writes the following tag fields:

script installation & usage:

  1. download the .src file

  2. move the file into this folder: %appdata%\Mp3tag\data\sources

    (just copy&paste this into the Windows Explorer address bar)

  3. run the script from Mp3Tag with this button:

newest version: 1.1 (uploaded 04.06.2012):
iTunes.src (3.2 KB)

iTunes.src (3.2 KB)


Some comments to the way the script works:

The script uses iTunes API:
This should make the script very stable, but it has also some limitations:

The COVER picture is always only 100x100 pixels. Sorry, no larger picture available at iTunes API

The PUBLISHER tag field is not always written as one company. Ofter there is additional information.

For the TITLE tag field I have picked "trackCensoredName" instead of "trackName". According to itunes' description, the the diference should be that rude words are replaced by * (like "S**t Happens"). But I have detected some examples, where the "trackCensoredName" has the version name of the title (like "Title (Club Mix)" or "Title (Trentemøller Remix)") and "trackName" has not.

The GENRE tag field displays only one main genre (like "Electronic"). The HTML pages have the more than one genre and more defined genre names (like "Electronic, Music, Dance, Techno, Ambient, House") The API has not (at least I don't know how to display it).
See the example above.

For the YEAR tag field, I was not able to get the original year when there are remastered versions on iTunes. The HTML pages have the original year. The API has not (at least I don't know how to display it).

Maybe I will make another version of the script which will parse the HTML site to avoid some of the limitations.

Let me know what you think about it and give me feeback if you spot some problems.
Everybody is invited to develop and modify this script.

The _length field should support milliseconds out of the box.
So you probably can save your (very good) ms conversion code.

Oh! So simple! I didn't even try this. How should I have known this? A good example of the poor documentation of the web sources functionality. The rules for the _LENGTH output aren't explained anywhere, are they? That would have saved me some work.

Wow this script is amazing!
Thank you :slight_smile:

Love the script but I'm finding some stuff it doesn't pick up that is on itunes

Can you give examples? Maybe I can fix that.

I tried to pull the details for Lawson - When she was Mine and kept getting stuff similar, other people's versions but not that one.

However I noticed something similar a week or so ago - I found something on the Discogs site - but when I tried to find it via the Source part of Discogs on Mp3tag it couldn't find it

Ok, I found the problem. iTunes has different catalogs for each country. The script searches the US catalog. When you use the iTunes software, you will always see the catalog of your own country.
The single you are mentioning is not in the US catalog, but it is in the Great Britain catalog.


I guess we would need different country versions of the script to cover that, similar to the Amazon scripts for Mp3tag.

As for the Discogs script, please report that in the respective forum thread. But I never had problems to find things there. I use that scripts very often. However, it is very sensitive for little spelling mistakes.

Hello and well done Pone!

Your script is most impressive; I have been able to improve metadata in my classical collection.
When tagging those huge boxset with a lot of tracks; it seems there is a limitation.
The script will only list the 50 first items and therefore write tags to only 50 files.

Maybe it is a limitation of the API?

Anyway thanks already!!!

I don't know. Can you give me an example link?
Maybe I've built that limitation into the script. Check what happens if you delete the "99" in the last line of the script!

I fixed that. The limitation was in iTunes' API. See update report below

Update 1.1:

FIXED: There was a maximum of 50 songs for an album before. Now it's 200 songs. That's the maximum for iTunes' API. Thank VincentVega for reporting this bug.

CHANGED: The automatic searchbox input is now %artist% %album%, before it was only %artist%. That will help to put your desired album on top of the results list.

CHANGED: The internal script code for changing milliseconds to minutes and seconds. Thanks dano for mentioning that this was not necessary.

  • download in the starting post -

It works; thanks for the quick fix:)
200 entries is more than enough.
All the best.

fantastic script, really very handy!

i have a question and not sure if you would mind helping. I'm modding this script slightly to be able to tag tv shows and movies as well. tv shows appear to be ok but i'm having a strange issue with movies.

it's mainly around writing the longDescription to the PODCASTDESC field. i know this isn't an original field in your script hence why not sure if you're able to help.

the lines looks like this -

outputto "PODCASTDESC"
sayregexp "(?<="longDescription":").+?(?=")" ", " "}"

but whenever it reaches the following characters " it stops writing. it appears anything in the description in quotes also has a \ with it as well. for example -

legendary Marvel Super Hero \“Iron Man,\”

i thought the following line (also found in your script)

replace "\"" """

might have taken care of it but it appears not. it just doesn't seem to like writing anything in quotes.

i'm a complete amateur at this so any chance you would mind assisting?

many thanks

Can you post your script version or send it to me? It's much easier to find the problem when i can use it and read the debug file.

thanks i have uploaded what i have so far. it really is just a case of using this great script and changing a few fields round to maybe try and apply it to a different media type.

as i say i'm a complete amateur so maybe going about this the wrong way.

iTunes42.src (2.28 KB)

Good work on the script!

replace "\"" """
replace "\"" "\\u0022"
That works perfectly.

I must confess that i don't know why I have included the replace "\"" """ line in the index part of my script. It doesn't seem to help anything. I did a few tests about quotationmarks but had the impression that itunes doesn't have this character in ther music database. They use only single quotes there, which avoids the problem.

I don't want to bother you, pone, but there has been coming up a question to me about apple search entities ... in their API manual I do not find an entitiy called "album", so how can you use "album" successfully in your script?


It is there. Just look again:
In the table there at entity, the following values are listed under music:
musicArtist, musicTrack, album, musicVideo, mix, song

'pone' I beg your pardon ... now I see it too! Thank you.