tw3*_*tw3 4 applescript itunes artwork
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
Run Code Online (Sandbox Code Playgroud)
To be honest I've no idea what I'm doing. Anyone feeling helpful?
Thanks
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
Run Code Online (Sandbox Code Playgroud)
您也可以使用http://dougscripts.com/itunes/scripts/ss.php?sp=savealbumart,但它不包含源代码.
| 归档时间: |
|
| 查看次数: |
3477 次 |
| 最近记录: |