2013-06-08 13 views
3

현재 재생중인 트랙의 아트 워크를 가져 와서 파일에 쓰도록 스크립트를 만들려고합니다. 나는 약간의 가이드를 조사했다. 그러나 그들 중의 누구도 일하지 않는 것처럼 보인다, 어떤 팁?현재 트랙에서 AppleScript로 아트 워크 가져 오기

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

솔직하게 말해서 나는 무엇을하고 있는지 잘 모릅니다. 누구라도 도움이 되었습니까?

감사

답변

6

파일로 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을 사용할 수 있지만 소스 코드가 포함되어 있지 않습니다.

+0

놀라워요, 감사합니다. 나는 당신이 app 내의 object artwork에 'tell'을 보낼 수 있다는 것을 깨닫지 못했다. – tw3