Created
May 24, 2009 21:31
-
-
Save jptix/117266 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require "osx/cocoa" | |
require "erb" | |
require "base64" | |
include OSX | |
def pict_bytes_for(artwork) | |
image_rep = artwork.data.representations.first | |
data = image_rep.PICTRepresentation | |
bytestr = "\0"*512 + data.bytes.bytestr(data.length) | |
Base64.encode64 bytestr | |
end | |
require_framework "ScriptingBridge" | |
itunes = SBApplication.applicationWithBundleIdentifier 'com.apple.iTunes' | |
track = itunes.currentTrack | |
puts ERB.new(DATA.read, 0, "%-<>").result(binding) | |
__END__ | |
<?xml version="1.0" encoding="UTF-8"?> | |
<track> | |
<name><%= track.name %></name> | |
<artist><%= track.artist %></artist> | |
<album><%= track.album %></album> | |
<artworks> | |
<% track.artworks.each do |artwork| %> | |
<artwork><%= pict_bytes_for artwork %></artwork> | |
<% end %> | |
</artworks> | |
</track> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment