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

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

问题描述

说真的,我很尴尬,甚至会问这个。

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

我有一个应该建立一个整体一堆唱片的播放列表的AppleScript。一切工作正常,除了实际添加曲目的播放列表。下面是相关的code:

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是独特的专辑名称的列表,并且thePlaylist是先前在脚本创建的播放列表

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 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界面添加用于使用文件系统路径中的新轨道添加到iTunes资料库,而复制是用来放置在播放列表中,以现有的轨道的基准

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曲目的循环中会慢如蜗牛无异于pretty缓慢的操作。

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 performs a native database lookup and adds the results to the playlist all at once so it is very fast.

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

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