Skip to content

Instantly share code, notes, and snippets.

@youpy
Created July 5, 2009 23:51
Show Gist options
  • Save youpy/141188 to your computer and use it in GitHub Desktop.
Save youpy/141188 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'rbosa'
OSA.utf8_strings = true
itunes = OSA.app('iTunes')
library = itunes.sources.find {|s| s.kind == OSA::ITunes::ESRC::LIBRARY }
tracks = {}
library.playlists[0].tracks.sort_by {|t| t.rating }.reverse.each do |track|
key = [
track.artist,
track.name,
#track.album,
track.duration.to_i.to_s
].join("\t").downcase
if tracks[key]
track.rating = 20
end
tracks[key] = true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment