【问题标题】:Getting artwork from current track in Applescript从 Applescript 中的当前曲目获取艺术品
【发布时间】:2013-06-08 01:58:34
【问题描述】:

我正在尝试制作一个脚本来提取当前播放曲目的艺术作品并将其写入文件。我查看了一些指南,但它们似乎都不起作用,有什么提示吗?

tell application "iTunes"
write artwork 1 to "path:to:desktop" of type("JPEG")
end tell

说实话,我不知道自己在做什么。有人觉得有帮助吗?

谢谢

【问题讨论】:

    标签: applescript itunes artwork


    【解决方案1】:

    您可以将raw data of artwork 1 of current track 写入文件:

    -- get the raw bytes of the artwork into a var
    tell application "iTunes" to tell artwork 1 of current track
        set srcBytes to raw data
        -- figure out the proper file extension
        if format is «class PNG » then
            set ext to ".png"
        else
            set ext to ".jpg"
        end if
    end tell
    
    -- get the filename to ~/Desktop/cover.ext
    set fileName to (((path to desktop) as text) & "cover" & ext)
    -- write to file
    set outFile to open for access file fileName with write permission
    -- truncate the file
    set eof outFile to 0
    -- write the image bytes to the file
    write srcBytes to outFile
    close access outFile
    

    您也可以使用http://dougscripts.com/itunes/scripts/ss.php?sp=savealbumart,但它不包含源代码。

    【讨论】:

    • 太棒了,谢谢。我没有意识到您可以在应用程序中向对象艺术品发送“告诉”。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-10-25
    • 2018-07-13
    • 1970-01-01
    • 1970-01-01
    • 2017-01-10
    • 1970-01-01
    • 2016-04-22
    相关资源
    最近更新 更多