我正在用 iTunes COM api 编写一个 JScript 脚本,用于将 iPod 数据库中的 ratings
和 played count
更新回 iTunes Library。为此,脚本应该能够识别从该 iTunes 库传输的歌曲,以便它可以读取 iPod 上轨道的评级数据并更新 iTunes 库中的相应轨道
这是我写的代码:
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
}
根据 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
现在的问题是:
- 当轨道传输到 iPod 时,iTunes 库中轨道的 64 位持久 ID 保持不变,我说得对吗?
- 我使用
ITObjectPersistentIDHigh()
和ITObjectPersistentIDLow()
的方式有什么问题吗?
- 有没有完全不同的方法来做到这一点?
PS:测试iPod上有662首歌曲,所以没有问题
非常感谢任何帮助!谢谢!
最佳答案
如果你有最新的nano,并且开启了画外音功能,那么ID会变,否则不会。我试图弄清楚 SW 如何知道在您同步时更新播放次数和时间,因为 ID 不相同。
关于com - 需要有关 iTunes COM 持久 ID 的解释。将轨道传输到 iPod 时,轨道 ID 是否相同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1633215/