一件艺术品从AppleScript的当前曲目 [英] Getting artwork from current track in Applescript

查看:199
本文介绍了一件艺术品从AppleScript的当前曲目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图做一个脚本来拉动当前播放曲目的作品,并将其写入文件。我已经签出了一些指导,但他们都不工作,任何提示?

I'm trying to make a script to pull the artwork of the currently playing track and write it to a file. I've checked out a few guides but none of them seem to work, any tips?

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

说实话我不知道我在做什么。任何人都觉得有用吗?

To be honest I've no idea what I'm doing. Anyone feeling helpful?

感谢

推荐答案

您可以写当前曲目的艺术品1 到文件中的原始数据:

You can write raw data of artwork 1 of current track to a file:

-- 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 ,但它不包括源$ C ​​$ C。

You might also use http://dougscripts.com/itunes/scripts/ss.php?sp=savealbumart, but it doesn't include source code.

这篇关于一件艺术品从AppleScript的当前曲目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆