2009-02-10 74 views
7

說真的,我很尷尬地問這個問題。AppleScript腳本問題 - 將歌曲添加到播放列表

我已經有一個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是唯一相冊名稱的列表,而Playlist是在腳本的早期創建的播放列表。

我一直在抨擊我的頭,因爲感覺像一個星期,我一直沒能弄明白。預先感謝任何幫助,您可以提供:)

回答

8

重複是你想要的命令。試試這個:

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執行本機數據庫查找並將結果一次性添加到播放列表中,因此速度非常快。

0

AppleScript的真的很怪......但檢出腳本here dougscripts.com

看起來他使用複製而不是添加到播放列表中添加時。我在看One Song From Each腳本

嗯......怎麼樣?

add (a reference to the_track) to playlist thePlaylist 
+0

我已經在Doug的網站上查看了許多*腳本的靈感和/或關於如何解決這個問題的線索,但無濟於事。謝謝雖然:) – inkedmn 2009-02-10 09:53:18

+0

是的,我其實已經打開了該腳本。不幸的是,'重複'給了我同樣的錯誤:\ – inkedmn 2009-02-10 10:03:51

0

嘗試改變該行:

add (get location of the_track) to playlist thePlaylist 

,或者,如果thePlaylist已經是一個播放列表引用(而不是隻是一個播放列表的字符串名稱):

add (get location of the_track) to thePlaylist 
0

嘗試:

copy the_track to end of playlist thePlaylist 

代替。

相關問題