首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >基于制表符分隔列表从iTunes播放列表中删除歌曲

基于制表符分隔列表从iTunes播放列表中删除歌曲
EN

Stack Overflow用户
提问于 2018-09-22 20:25:09
回答 1查看 118关注 0票数 0

如果歌曲包含标签分隔的文件中的名称+艺术家+年份,我如何使用Applescript从myPlaylist中删除任何歌曲?

因此,如果myPlaylist的第一轨是:

“绿衣天蝎座1965年”

选项卡分隔的文本文件包含以下行:

格林斯利夫斯1965年天蝎座

它将从播放列表中删除该轨道。而且,它需要确切的标题,因为我的一些歌曲标题中有括号和奇怪的字符。

谢谢!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-22 22:44:20

代码语言:javascript
复制
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“

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52460598

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档