class MusicMetaFixer::ItunesLibParser
Constants
- ARTIST
- ITUNES_API
- LOCATION
- NAME
- SONG_END_PATH
- SONG_KEY_PATH
- SONG_VALUE_DATE_PATH
- SONG_VALUE_STRING_PATH
Public Class Methods
new(options={})
click to toggle source
# File lib/music_meta_fixer/itunes_lib_parser.rb, line 16 def initialize(options={}) @counter = 0 @path = [] @pretty_printer = PrettyPrinter.new end
Public Instance Methods
characters(chars)
click to toggle source
# File lib/music_meta_fixer/itunes_lib_parser.rb, line 30 def characters chars if @path == SONG_KEY_PATH if chars == "Location" @key = LOCATION else @key = nil end elsif @path == SONG_VALUE_STRING_PATH && @key if @key == LOCATION @song_path = CGI.unescape(chars).gsub(/file:\/\/localhost/, "") end end end
end_document()
click to toggle source
# File lib/music_meta_fixer/itunes_lib_parser.rb, line 22 def end_document puts "Finished reading iTunesLibary file" end
end_element(name)
click to toggle source
# File lib/music_meta_fixer/itunes_lib_parser.rb, line 44 def end_element name @path.pop if @path == SONG_END_PATH && name == "dict" @song = TagEditor.get_song_info(@song_path) if @song itunes_api = ItunesAPI.new("#{@song.artist} #{@song.name}" ) @pretty_printer.print_itunes_api_query(itunes_api) @new_song = itunes_api.get_song_info if @new_song && (diff = @song.compare_to(@new_song)) && !diff.empty? @pretty_printer.print_song_diff(@song, @new_song, diff) puts "Change? (y/n)" print "> " answer = gets.chomp if answer.match(/y/i) puts "Changing #{@song.name} at #{@song_path}\n\n" TagEditor.change_tag_info(@song_path, @new_song) else puts "Moving on\n\n" end end end end end
start_element(name, attributes = [])
click to toggle source
# File lib/music_meta_fixer/itunes_lib_parser.rb, line 26 def start_element name, attributes = [] @path += [name] end