Created
February 9, 2013 15:15
-
-
Save eagletmt/4745660 to your computer and use it in GitHub Desktop.
List purchased songs on iPhone.
ifuse is a part of libimobiledevice.
This file contains hidden or 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/ruby | |
# USAGE: | |
# % ifuse ~/mnt | |
# % ./purchased.rb ~/mnt | |
require 'pathname' | |
require 'sqlite3' | |
iphone = Pathname.new ARGV[0] | |
db = SQLite3::Database.new iphone.join('iTunes_Control', 'iTunes', 'MediaLibrary.sqlitedb').to_s | |
db.results_as_hash = true | |
db.execute('SELECT * FROM item').each do |item| | |
extra = db.execute('SELECT * FROM item_extra WHERE item_pid = ?', item['item_pid'].to_i).first || {} | |
next if extra['is_ota_purchased'].to_i == 0 | |
artist = db.execute('SELECT * FROM item_artist WHERE item_artist_pid = ?', item['item_artist_pid'].to_i).first || {} | |
album = db.execute('SELECT * FROM album WHERE album_pid = ?', item['album_pid'].to_i).first || {} | |
#album_artist = db.execute('SELECT * FROM album_artist WHERE album_artist_pid = ?', item['album_artist_pid'].to_i).first || {} | |
puts [iphone.join('Purchases', extra['location']).to_s, extra['title'], artist['item_artist'], album['album'], extra['artwork_url']].join("\t") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment