Guest User

Untitled

a guest
Apr 19th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. -- Paths and stuff
  2. set ArtworkFromiTunes to ((path to home folder) as text) & ¬
  3. "Pictures:iTunes Artwork:From iTunes:albumArt.pict" as alias
  4. set iTunesArtwork to ((path to home folder) as text) & ¬
  5. "Pictures:iTunes Artwork:From iTunes:albumArt.pict"
  6. set DefaultArtwork to ((path to home folder) as text) & ¬
  7. "Pictures:iTunes Artwork:Default:albumArt.pict"
  8. set displayArtwork to ((path to home folder) as text) & ¬
  9. "Pictures:iTunes Artwork:albumArt.pict"
  10.  
  11. -- Unix versions of the above path strings
  12. set unixITunesArtwork to the quoted form of POSIX path of iTunesArtwork
  13. set unixDefaultArtwork to the quoted form of POSIX path of DefaultArtwork
  14. set unixDisplayArtwork to the quoted form of POSIX path of displayArtwork
  15.  
  16. set whichArt to "blank"
  17. tell application "System Events"
  18. if exists process "iTunes" then -- iTunes is running
  19. tell application "iTunes"
  20. if player state is playing then -- iTunes is playing
  21. set aLibrary to name of current playlist -- Name of Current Playlist
  22. set aTrack to current track
  23. set aTrackArtwork to null
  24. if (count of artwork of aTrack) ≥ 1 then -- there's an album cover
  25. "Running and playing and art"
  26. set aTrackArtwork to data of artwork 1 of aTrack
  27. set fileRef to ¬
  28. (open for access ArtworkFromiTunes with write permission)
  29. try
  30. set eof fileRef to 512
  31. write aTrackArtwork to fileRef starting at 513
  32. close access fileRef
  33. on error errorMsg
  34. try
  35. close access fileRef
  36. end try
  37. error errorMsg
  38. end try
  39.  
  40. tell application "Finder" to ¬
  41. set creator type of ArtworkFromiTunes to "????"
  42. set whichArt to "iTunes"
  43. end if
  44. end if
  45. end tell
  46. end if
  47. end tell
  48.  
  49. if whichArt is "iTunes" then
  50. do shell script "ditto -rsrc " & unixITunesArtwork & space & unixDisplayArtwork
  51. else
  52. do shell script "ditto -rsrc " & unixDefaultArtwork & space & unixDisplayArtwork
  53. end if
Add Comment
Please, Sign In to add comment