Applescript 问题 - 将曲目添加到播放列表 [英] Applescript Question - Adding Tracks to Playlists

查看:22
本文介绍了Applescript 问题 - 将曲目添加到播放列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说真的,我什至不好意思问这个.

Seriously, I'm embarrassed to even be asking this.

我有一个 Applescript,它应该可以为一堆整张专辑建立一个播放列表.一切正常,除了实际将曲目添加到播放列表.相关代码如下:

I've got an Applescript that is supposed to build a playlist of a bunch of whole albums. Everything works fine, except for actually adding the tracks to the playlist. Here's the relevant code:

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 出现错误:发生描述符类型不匹配."

The error I get is "iTunes got an error: A descriptor type mismatch occurred."

randAlbums 是唯一专辑名称的列表,Playlist 是之前在脚本中创建的播放列表.

randAlbums is a list of unique album names, and thePlaylist is a playlist that is created earlier in the script.

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

I've been banging my head against this for what feels like a week and I haven't been able to figure it out. Thanks in advance for any assistance you can offer :)

推荐答案

Duplicate 是您想要的命令.试试这个:

Duplicate is the command you want. Try this:

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

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

Within the iTunes interface add is used to add a new track to the iTunes library using a file system path, while duplicate is used to place a reference to an existing track in a playlist.

当使用 add 命令时,iTunes 最终会发现该曲目已经是库的一部分并执行您想要的操作,但不会在读取文件的元数据、安排它进行专辑封面检索等之前进行.所有这些相当于一个相当慢的操作,所以如果你在循环中使用它来处理大量曲目,iTunes 会慢到爬行.

When the add command is used iTunes will eventually figure out that the track is already part of the library and do what you want, but not before it reads the file's metadata, schedules it for album art retrieval, etc. All of this amounts to a pretty slow operation so if you're using it within a loop for a large number of tracks iTunes will slow to a crawl.

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

Duplicate performs a native database lookup and adds the results to the playlist all at once so it is very fast.

这篇关于Applescript 问题 - 将曲目添加到播放列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆