views:

322

answers:

1

I am writing a JScript script with iTunes COM api for updating ratings and played count from the iPod database back into iTunes Library. In order to do so, the script should be able to recognize the songs that were transferred from this iTunes Library, so that it can read the ratings data for the track on iPod and update the corresponding track in the iTunes Library

Here's the code I've written:

var iTunesApp = WScript.createObject("iTunes.Application");
var mainLibrary = iTunesApp.LibraryPlaylist;
var iPodLibraryPlaylist = playlists.Item(1);    // get the main iPod Library playlist(leaving the unimportant portion)

for(j=0; j <= iPodLibraryPlaylist.Tracks.Count - 1; j++) {
        foo = iPodLibraryPlaylist.Tracks.Item(j+1);    // j+1, coz this index is 1-based (why apple...why?)
        bar = mainLibrary.Tracks.ItemByPersistentID(iTunesApp.ITObjectPersistentIDHigh(foo), iTunesApp.ITObjectPersistentIDLow(foo));
        WScript.StdOut.WriteLine(bar.Name);    // should print the name of the track, but throws runtime error: Object required
}

According to the iTunes COM API

You can retrieve a source, playlist, or track with a specified persistent ID using the ItemByPersistentID property of the appropriate collection interface

ItemByPersistentID returns an IITTrack object with the specified persistent ID

Now the questions are:

  1. Am I right in saying that the 64-bit Persistent ID for a track in iTunes Library remains the same when the track is transferred to an iPod.
  2. Is there anything wrong in the way i'm using the ITObjectPersistentIDHigh() and ITObjectPersistentIDLow()
  3. Is there any totally other way to do this?

PS: There are 662 songs on the test iPod, so there's no problem there

Any help is much appreciated! thnx!

A: 

If you have the latest nano, and turn on the voiceover function, then the ID changes, otherwise it doesn't. I'm trying to figure out how the SW knows to update the play count and time when you sync, since the ID isn't the same.

Doug