7

说真的,我连问这个都不好意思。

我有一个 Applescript,它应该建立一个包含整张专辑的播放列表。一切正常,除了将曲目实际添加到播放列表中。以下是相关代码:

repeat with theAlbum in randAlbums
    set these_tracks to (tracks of library playlist 1 whose album is theAlbum)
    repeat with the_track in these_tracks
        add the_track to playlist thePlaylist  (* doesn't work *)
    end repeat
end repeat

我得到的错误是“iTunes 出错:发生描述符类型不匹配”。

randAlbums 是唯一专辑名称的列表,而 thePlaylist 是在脚本前面创建的播放列表。

一个星期以来,我一直在努力解决这个问题,但我一直无法弄清楚。提前感谢您提供的任何帮助:)

4

4 回答 4

9

重复是您想要的命令。试试这个:

repeat with theAlbum in randAlbums
    duplicate (tracks of library playlist 1 whose album is theAlbum) to thePlaylist
end repeat

在 iTunes 界面内,add用于使用文件系统路径将新曲目添加到 iTunes 库,同时duplicate用于在播放列表中放置对现有曲目的引用。

当使用 add 命令时,iTunes 最终会发现该曲目已经是库的一部分并执行您想要的操作,但不是在它读取文件的元数据、安排它以进行专辑封面检索等之前。所有这些都相当于一个运行速度非常慢,因此如果您在循环中使用它来播放大量曲目,iTunes 会慢得像爬行一样。

Duplicate 执行本地数据库查找并将结果一次性添加到播放列表中,因此速度非常快。

于 2009-02-10T15:00:04.560 回答
1

尝试:

copy the_track to end of playlist thePlaylist

反而。

于 2009-02-14T00:59:23.920 回答
0

Applescript 真的很奇怪......但是在这里查看脚本 dougscripts.com

看起来他在添加到播放列表时使用重复而不是添加。我正在看每个剧本中的一首歌

嗯……怎么样?

add (a reference to the_track) to playlist thePlaylist
于 2009-02-10T09:51:52.403 回答
0

尝试将该行更改为:

add (get location of the_track) to playlist thePlaylist

或者,如果thePlaylist已经是播放列表引用(而不仅仅是播放列表的字符串名称):

add (get location of the_track) to thePlaylist
于 2009-02-10T09:55:46.453 回答