需要有关 iTunes COM 持久 ID 的解释。曲目传输到 iPod 时的 ID 是否相同?
我正在使用 iTunes COM api 编写一个 JScript 脚本,用于将 iPod 数据库中的评级和播放次数更新回 iTunes 库。为此,脚本应该能够识别从此 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
您可以检索源、播放列表、 或跟踪指定的持久性 使用 ItemByPersistentID 的 ID 适当收藏的财产 界面
ItemByPersistentID 返回 IITTrack 具有指定持久化的对象 身份证号
现在的问题是:
- 当 iTunes 库中的曲目传输到 iPod 时,其 64 位持久 ID 保持不变,我这样说对吗?
- 我使用
ITObjectPersistentIDHigh()
和ITObjectPersistentIDLow()
的方式有什么问题吗 - ?还有其他方法可以做到这一点吗?
PS:测试 iPod 上有 662 首歌曲,所以没有问题,
非常感谢任何帮助!谢谢!
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
interfaceItemByPersistentID returns an IITTrack
object with the specified persistent
ID
Now the questions are:
- 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.
- Is there anything wrong in the way i'm using the
ITObjectPersistentIDHigh()
andITObjectPersistentIDLow()
- 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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你有最新的nano,并且打开了画外音功能,那么ID会改变,否则不会。我试图弄清楚软件如何知道同步时更新播放计数和时间,因为 ID 不同。
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.
我不认为只有另一种方法可以做到这一点,很长:
将 iPod 中每首曲目的名称、专辑、长度等与您库中的曲目进行比较。然而,我不认为这将是一种非常有效的解决方案,而只是一种“易于编程”的解决方案。
我像您一样使用了 permanentID(尽管在播放列表上)。它应该可以工作...也许您应该将参数设置为 int...
I do not think that there is only one other way of doing it, very long:
compare, for each track in the iPod, the names, albums, lengths, etc with the one you have on your library. However, I don't think that will be a very effective solution, just an "easy to program" one.
I used the persistentID just like you did (although on a playlist). It should work... Maybe you should set the parameter as an int...