根据 tab-separated 列表从 iTunes 播放列表中删除歌曲

Remove song from iTunes playlist based on tab-separated list

如果歌曲包含 tab-separated 文件中包含的名称 + 艺术家 + 年份之一,我如何使用 Applescript 从 myPlaylist 中删除任何歌曲?

所以如果我的播放列表中的第一个曲目是:

'Greensleeves The Scorpions 1965'

并且 tab-separated 文本文件包含以下行:

绿袖子蝎子 1965

它将从播放列表中删除曲目。另外,它必须是准确的标题,因为我的一些歌名中有括号和奇怪的字符。

谢谢!

use application "iTunes"
use scripting additions
--------------------------------------------------------------------------------
###USER-DEFINED PROPERTIES: path, playlist
property path : "~/Desktop/trackdelete.list"
property playlist : "myPlaylist"
--------------------------------------------------------------------------------
property text item delimiters : tab
--------------------------------------------------------------------------------
###IMPLEMENTATION
#
#
tell the deleteList
    if not (its file exists) then return -1

    read

    repeat with i from 1 to the length of its list
        set [its name, its artist, its year] to ¬
            [text item 1, text item 2, text item 3] of ¬
            item i of its list

        delete (playlistItem's track where ¬
            name = deleteList's name and ¬
            artist = deleteList's artist and ¬
            year = deleteList's year)
    end repeat
end tell
--------------------------------------------------------------------------------
###SCRIPT OBJECTS & HANDLERS
#
#
script playlistItem
    property playlist : a reference to the playlist named (my playlist)
    property track : a reference to every track of my playlist
end script

script deleteList
    property application : application "System Events"
    property file : a reference to file (my path) of my application
    property list : null
    property name : null
    property artist : null
    property year : null

    to read
        tell AppleScript to read (my file as alias)
        set my list to the result's paragraphs
    end read
end script
---------------------------------------------------------------------------❮END❯

系统信息: AppleScript 版本:“2.7”,系统版本:“10.13.6”