gpt4 book ai didi

applescript - 从 Applescript 中的当前轨道获取艺术品

转载 作者:行者123 更新时间:2023-12-04 23:55:27 25 4
gpt4 key购买 nike

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

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

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

谢谢

最佳答案

你可以写 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 ,但它不包括源代码。

关于applescript - 从 Applescript 中的当前轨道获取艺术品,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16995273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com