Skip to content

Instantly share code, notes, and snippets.

@kejadlen
Created July 25, 2012 15:07
Show Gist options
  • Save kejadlen/3176659 to your computer and use it in GitHub Desktop.
Save kejadlen/3176659 to your computer and use it in GitHub Desktop.
require 'rbosa'
OSA.utf8_strings = true
itunes = OSA.app('iTunes')
library = itunes.sources.find {|source| source.name == 'Library' }.playlists[0].tracks
library.each do |track|
count = (track.played_count + track.skipped_count).to_f
stat = track.played_count / count
comment = track.comment
if count > 5 and stat > 0.95 and track.video_kind == OSA::ITunes::EVDK::NONE
comment << "\n" unless track.comment.empty?
comment << "AlphaRating: 5"
track.comment = comment
elsif track.comment =~ /AlphaRating: 5/
comment.sub!(/\n?AlphaRating: 5/, "")
track.comment = comment
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment