Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to reclaim play count and rating (iTunes)? (Read 20615 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to reclaim play count and rating (iTunes)?

I apologize if this question's been posted ad nauseum, but after being overwhelmed by the non-specific search results I figured I'd lob this request over the wall...

Is there any way to reclaim or maintain My Rating and play count totals from iTunes after using MP3gain? I've built playlists based on rating and play count and I'd like to keep them carefully maintained. My process for using this software and the iPod is:

Clear "to be MP3gain'd" files from iTunes library
Use MP3gain to desired db level
Add folder containing "new" files to iTunes library
Re-sync iPod

Help me get those stars back when I import the files again!

Thanks to all and any who reply...

INFO
iTunes 4.8
MP3gain
Windows XP SP2
4G 20GB iPod

How to reclaim play count and rating (iTunes)?

Reply #1
This is not a perfect solution, but it works for most cases.

Download this script I wrote: http://otto.homedns.org:8888/iTunes/SaveRatings.zip

It's an HTA file, which is an HTML Application. If your virus scanner complains about it (many will gripe about HTA's using Javascript on general principle), I suggest disabling the virus scanner temporarily. It's perfectly safe, I wrote it myself.

Start iTunes. Then double click the HTA to run it. Click "Save Ratings" to save the ratings (and play count and last played time) to a file which will be called "ratings.xml". It does take a while to run, and has no obvious feedback actually showing it running, so go make a sandwich while it processes. Once it's done, close it.

Do whatever you need to do, then when you have all your stuff back in iTunes, run the program again and select "Restore Ratings" to restore all the data back to iTunes.

This script keys off of the song name, artist name, and album name. So anything with identical info like that will get the ratings restored to it. That's how it works, basically.

It runs some fairly simple Javascript if you want to edit it to be more suited to your particular needs. It's just a text file, really, very easy to modify.

Anyway, enjoy.

How to reclaim play count and rating (iTunes)?

Reply #2
you don't need to necessarily remove your mp3's from iTunes and add them later again. Usually iTunes notices it when a file has been changed and therefore will update it automatically next time you sync your iPod. It works great if you replace the file or if you alter the tag information - even if you keep the timestamp. You just have to play the file or take a look at the specs...

This might not work when you just change the volume of the mp3 since iTunes won't read APEv2 Tags anyway, but you could just uncheck the songs you've updated and sync your iPod. That way the files are removed from your iPod. After that, you tick the checkboxes again and sync your iPod a second time. The files are copied to your iPod and you have the updated files on your iPod without loosing any meta info...

Easy as pie
--alt-presets are there for a reason! These other switches DO NOT work better than it, trust me on this.
LAME + Joint Stereo doesn't destroy 'Stereo'

How to reclaim play count and rating (iTunes)?

Reply #3
Jojo: True, except iTunes won't redo it's volume scan for the SoundCheck information without removing and readding the files. Which is fine as long as you never turn on SoundCheck.

 

How to reclaim play count and rating (iTunes)?

Reply #4
Quote
Jojo: True, except iTunes won't redo it's volume scan for the SoundCheck information without removing and readding the files. Which is fine as long as you never turn on SoundCheck.
[a href="index.php?act=findpost&pid=304719"][{POST_SNAPBACK}][/a]

seems logical, but you wouldn't want to use mp3Gain anymore if you already use SoundCheck - and the other way around.
--alt-presets are there for a reason! These other switches DO NOT work better than it, trust me on this.
LAME + Joint Stereo doesn't destroy 'Stereo'

How to reclaim play count and rating (iTunes)?

Reply #5
@ Otto42

do you think you could add a feature that saves all playlists? It's especially the Smart Playlists and it's rules I'm looking for

thanks
--alt-presets are there for a reason! These other switches DO NOT work better than it, trust me on this.
LAME + Joint Stereo doesn't destroy 'Stereo'

How to reclaim play count and rating (iTunes)?

Reply #6
There's no need. You can save the playlists yourself in iTunes. Just export the playlists to an XML file and reimport them later. It'll keep the smart playlist rules too.

Okay, so it's a one-by-one solution, but it's there now in any case.

How to reclaim play count and rating (iTunes)?

Reply #7
I just used your little script again. It still works great
Anyway, would it be possible to preserve the "song added" information as well? I have a bunch of smart playlists that depend upon that information.

thanks
--alt-presets are there for a reason! These other switches DO NOT work better than it, trust me on this.
LAME + Joint Stereo doesn't destroy 'Stereo'

How to reclaim play count and rating (iTunes)?

Reply #8
If your files were soundchecked before mp3gaining them, you will not only have to remove them from the library and re-import them afterwards, but you will also have to remove the itunesnorm tag. Otherwise, itunes will re-import the old soundcheck values.
It also still makes sense to soundcheck the mp3gained files imo: if you mp3gain them it would be best to use album gain. By turning on soundcheck you can still use track gain for playback. (track gain: with soundcheck, album gain: without soundcheck)

How to reclaim play count and rating (iTunes)?

Reply #9
I just used your little script again. It still works great
Anyway, would it be possible to preserve the "song added" information as well? I have a bunch of smart playlists that depend upon that information.

thanks
ok, I've tried to modify Otto's script. I simply want to preserve the 'date added' property. I also removed the album criteria for a successful restore of a song.

The data gets exported and all the data is there, but I'm getting an error on line 175, char 7, saying: "Wrong number of arguments or invalid property assignment". The line the code refers to is:

Quote
foundTrack.DateAdded = dateadded.getVarDate();

Here is the entire script:
Code: [Select]
<html>
<head>
<title>Save and Restore Ratings/Playcounts/Last Played</title>

<?XML:NAMESPACE PREFIX = HTA />
<HTA:APPLICATION />

<script LANGUAGE="VBScript">
Function GetNothing()
Set GetNothing = Nothing
End Function
</SCRIPT>

<script type="text/JScript">

var jsNothing = GetNothing();

function saveXMLRatings(everything)
{
var iTunesApp = new ActiveXObject("iTunes.Application");
var mainLibrary = iTunesApp.LibraryPlaylist;
var mainLibrarySource = iTunesApp.LibrarySource;
var tracks = mainLibrary.Tracks;
var numTracks = tracks.Count;
var i;

var dom = new ActiveXObject("Microsoft.XMLDOM");

// create the root element
var  root = dom.createElement("songs");
dom.appendChild(root);

// Insert a newline + tab for readability
root.appendChild(dom.createTextNode("\n\t"));

// run through all the tracks
for (i = 1; i <= numTracks; i++)
{
var currTrack = tracks.Item(i);
var rating = currTrack.Rating;
var playcount = currTrack.PlayedCount;
var lastplayed = currTrack.PlayedDate;
var dateadded = currTrack.DateAdded;
var name = currTrack.Name;
var artist = currTrack.Artist;
//var album = currTrack.Album;

// dont bother to save if the rating and playcount are both zero
if (rating != 0 || playcount != 0 || everything == 1)
{
// create a new song element
var songnode = dom.createElement("song");
root.appendChild(songnode);
songnode.appendChild(dom.createTextNode("\n\t\t"));

var artistnode = dom.createElement("artist");
artistnode.text = artist;
songnode.appendChild(artistnode);
songnode.appendChild(dom.createTextNode("\n\t\t"));

// var albumnode = dom.createElement("album");
// albumnode.text = album;
// songnode.appendChild(albumnode);
// songnode.appendChild(dom.createTextNode("\n\t\t"));

var namenode = dom.createElement("name");
namenode.text = name;
songnode.appendChild(namenode);
songnode.appendChild(dom.createTextNode("\n\t\t"));

var ratingnode = dom.createElement("rating");
ratingnode.text = rating;
songnode.appendChild(ratingnode);
songnode.appendChild(dom.createTextNode("\n\t\t"));

var datenode = dom.createElement("lastplayed");
datenode.text = lastplayed;
songnode.appendChild(datenode);
songnode.appendChild(dom.createTextNode("\n\t\t"));

var addednode = dom.createElement("dateadded");
addednode.text = dateadded;
songnode.appendChild(addednode);
songnode.appendChild(dom.createTextNode("\n\t\t"));

var countnode = dom.createElement("playcount");
countnode.text = playcount;
songnode.appendChild(countnode);
songnode.appendChild(dom.createTextNode("\n\t"));
root.appendChild(dom.createTextNode("\n\t"));

// var addednode = dom.createElement("dateadded");
// addednode.text = dateadded;
// songnode.appendChild(addednode);
// songnode.appendChild(dom.createTextNode("\n\t"));
// root.appendChild(dom.createTextNode("\n\t"));
}
}

document.write("Ratings/Playcount data saved.<br>");
// Add a newline.
root.appendChild(dom.createTextNode("\n"));

// Save the XML document to a file.
dom.save("ratings2.xml");

root = null;
dom = null;
iTunesApp = jsNothing;
}


function restoreXMLRatings(everything)
{
var iTunesApp = new ActiveXObject("iTunes.Application");
var mainLibrary = iTunesApp.LibraryPlaylist;
//var mainLibrarySource = iTunesApp.LibrarySource;
var tracks = mainLibrary.Tracks;

var ITPlaylistSearchFieldSongNames = 5;

var dom = new ActiveXObject("Microsoft.XMLDOM")
dom.async="false"
dom.load("ratings2.xml")

// go through the songs one by one

var i, n_elems, j;
var elems = dom.getElementsByTagName("song");
n_elems = elems.length;
for (i = 0; i < n_elems; i++)
{
// elems.item(i) or elems[i] is the song node we want to look at

var rating = elems.item(i).selectSingleNode("rating").text;
var playcount = elems.item(i).selectSingleNode("playcount").text;
var lastplayed = new Date(elems.item(i).selectSingleNode("lastplayed").text);
var dateadded = new Date(elems.item(i).selectSingleNode("dateadded").text);
var name = elems.item(i).selectSingleNode("name").text;
var artist = elems.item(i).selectSingleNode("artist").text;
//var album = elems.item(i).selectSingleNode("album").text;

// search for the name of the song
var foundTracks = mainLibrary.Search(name,ITPlaylistSearchFieldSongNames);

var worked = 0;
if (foundTracks)
{
for (j=1; j<=foundTracks.Count;j++)
{
// check the artist, album, name, and kind
if (name == foundTracks.Item(j).Name &&
artist == foundTracks.Item(j).Artist
//&&
//album == foundTracks.Item(j).Album
)
{
var foundTrack = foundTracks.Item(j);

//document.write("Found an exact match for " +name+ "<br>");
if (rating !=0 || everything == 1)
{
//document.write("Setting rating to "+rating +"<br>");
foundTrack.Rating = parseInt(rating);
}
if (playcount !=0 || everything == 1)
{
//document.write("Setting playcount to "+playcount +"<br>");
foundTrack.PlayedCount = parseInt(playcount);

// also restore last played date in this case
//document.write("Setting lastplayed<br>");
foundTrack.PlayedDate = lastplayed.getVarDate();

foundTrack.DateAdded = dateadded.getVarDate();
}
worked=1;
}
} // end for
}
//if (worked==0) document.write("Could not find any match for "+name+", "+album+", "+artist+"<br>");
if (worked==0) document.write("Could not find any match for "+name+", "+artist+"<br>");
foundTracks=null;
}

dom = null;
iTunesApp = jsNothing;
}

</script>

</head>
<body>

<h4>Saving Ratings</h4>
<p>Click the "Save Ratings" button below to save the Ratings/Playcount/LastPlayedDate data from iTunes into
a file. This file will be called "ratings2.xml" and it will be saved in the same directory
as you ran the HTA file from. This process may take a while.</p>

<h4>Restoring Ratings</h4>
<p>Click the "Restore Ratings" button to restore the Ratings/Playcount/LastPlayedDate from the "ratings2.xml" file
to the iTunes library. This is not undo-able, so you may want to backup your iTunes library
files first.</p>

<h4>Saving/Restoring Everything</h4>
<p>Does the same thing, except it saves and restores all song data, including zero ratings and such.
Normally, zero ratings get ignored, so as not to overwrite good ratings with zero ratings. This
has no such protection. It's also much, much slower. Be patient.</p>

<h4>Note</h4>
<ul>
<li>It's recommended that you have iTunes running when you use this program. It's not
required, as iTunes will start regardless, but it's a bit faster if it's already running.</li>
</ul>

<center>
<table border=0>
<!--
<tr>
<td align=center><button onclick="saveXMLRatings(0)">Save Ratings</button></td>
<td align=center><button onclick="restoreXMLRatings(0)">Restore Ratings</button></td>
</tr>
-->
<tr>
<td align=center><button onclick="saveXMLRatings(1)">Save Everything</button></td>
<td align=center><button onclick="restoreXMLRatings(1)">Restore Everything</button></td>
</tr>
</table>
</center>

</body>
</html>
any help would be appreciated.

thanks
--alt-presets are there for a reason! These other switches DO NOT work better than it, trust me on this.
LAME + Joint Stereo doesn't destroy 'Stereo'


How to reclaim play count and rating (iTunes)?

Reply #11
Just added this feature to iTSfv, kudos to Otto42's design idea.

maybe you could check my previous post in this thread and see if it is possible to backup the 'date added' property as well
--alt-presets are there for a reason! These other switches DO NOT work better than it, trust me on this.
LAME + Joint Stereo doesn't destroy 'Stereo'

How to reclaim play count and rating (iTunes)?

Reply #12
maybe you could check my previous post in this thread and see if it is possible to backup the 'date added' property as well


It's possible to backup; the problem is restoring it. Like you said maybe hacking the XML file could be a workaround. IIRC the change has to be done to the .itl file as well as the .xml file. Otherwise iTunes reverts back to the old value by reading the .itl file. However, indeed an interesting challenge.


How to reclaim play count and rating (iTunes)?

Reply #14
Is there any way to reclaim or maintain My Rating and play count totals from iTunes after using MP3gain? I've built playlists based on rating and play count and I'd like to keep them carefully maintained. My process for using this software and the iPod is:


I found a way to get the ratings back . . . it's kind of a hack, but it works with little fuss --

1.  Sort your entire iTunes music library by rating, and then create a playlist for each number of stars you've given the song ("star 1," "star2," etc.).

2.  Download a program that converts iTunes playlists to m3u files, like this one:
http://www.ericdaugherty.com/dev/itunesexport

3.  Export the star 1-5 playlists to m3u format.

4.  Load the star 1-5 playlists into foobar and rate the songs according to what their playlist name is.

iRating will take care of the other stuff you want too, but it only works on a limited number of files 100-200 before closing down.

How to reclaim play count and rating (iTunes)?

Reply #15
Or you can try iRating. This guy seems to get the thing complete  .
Axel


Later versions of iTSfv will store all the "not-stored-in-tracks" tags to an XML file to backup/restore.



[a href="http://wmwiki.com/downloads/itsfv/beta/?M=D" target="_blank"]http://wmwiki.com/downloads/itsfv/beta/?M=D


I have tested this myself however if you are trying it please try it first in another XP user account to get confidence that it is working.

Backing up should be must faster because it is not storing the data in the track thus not modifying the track everytime.