【问题标题】:find song with partial name in iTunes在 iTunes 中查找具有部分名称的歌曲
【发布时间】:2012-11-18 03:22:44
【问题描述】:

我知道如何按名称播放播放列表中的歌曲,但可以说我想这样做,以便在播放该歌曲时空格和大小写无关紧要。

所以如果我想播放“someSong”、“some song”或“Some Song”,我仍想在我的播放列表中播放一首名为“Some song”的歌曲。

我该怎么做?

【问题讨论】:

    标签: applescript itunes


    【解决方案1】:

    试试:

    set yourSong to "yoursongname"
    set yourPlaylist to "your playlist"
    
    set searchString to {}
    repeat with i from 1 to count of yourSong
        set aChar to text i of yourSong
        if aChar ≠ space then
            set end of searchString to aChar & " *?"
        end if
    end repeat
    set searchString to searchString as text
    
    tell application "iTunes" to set plTracks to name of every track of playlist yourPlaylist
    set AppleScript's text item delimiters to linefeed
    set plTracks to plTracks as text
    set AppleScript's text item delimiters to {""}
    set targetSong to do shell script "echo " & quoted form of plTracks & " | grep -Ei " & quoted form of searchString
    
    log targetSong
    display dialog "Now Playing: " & targetSong buttons {"Cancel", "OK"} default button "OK" giving up after 2
    
    tell application "iTunes" to play track targetSong of playlist yourPlaylist
    

    【讨论】:

    • 嘿-检查这是否有效,我如何打印?我试过 log(var),但这似乎没有任何作用
    • 您可以通过在 AppleScript Editor 中运行它来测试它。使用不带空格且大小写错误的歌曲名称填充 yourSong 变量。使用 yourSong 所在的播放列表的名称填充 yourPlaylist 变量。
    • 我已经编辑了脚本以记录 targetSong 的值并在播放前短暂显示它。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多