require “cddb_parser/version”
# File oldcode/cddb.rb, line 32 def initialize() @files = [] #@albums = {} end
# File oldcode/last_cddb.rb, line 157 def fix_mins(secs) puts "SECS: (#{secs})" secs = secs.to_i puts "SECS: (#{secs})" if secs >= 60 mins = (secs / 60).to_i secs = secs % 60 else mins = 0 end #puts "TIME: (#{time})" sprintf "%d:%02d", mins, secs end
# File oldcode/last_cddb.rb, line 132 def fix_offsets(disk_secs,offsets) puts "Got disk_secs: (#{disk_secs})" offsets << disk_secs.to_i * @@FrameConversion #disk_frames = disk_secs * @@FrameConversion length = offsets.length puts "Offset length: #{length}" puts "Elements: (" << offsets.join(", ") << ")" times = [] #working_offsets = offsets << disk_frames #[offsets,disk_frames].each_with_index do |val,idx| offsets.each_with_index do |val,idx| puts "IDX" break if idx == offsets.length - 1 len = (offsets[idx+1].to_i - offsets[idx].to_i) / @@FrameConversion time = self.fix_mins(len) times << time end #puts "TIMES: (" << times.join(", ") << ") (#{times.length})" puts "TIMES: (" << times.join(", ") << ") (#{times.length})" times end
# File oldcode/last_cddb.rb, line 109 def parse_header(header) puts "IN parse_header" offsets = [] disk_secs = 0.to_i header.split(%r\n/).each do |cur| #puts "CUR: (#{cur})" if cur =~ %r^#\s+(\d+)\s*$/ puts "offset: (#{offsets})" offsets << $1 elsif cur =~ %r^#\s+Disc\s+length:?\s+(\d+)\s+sec/ puts "Found disc_secs: #{$1}" disk_secs = $1 end end #puts "DISK_SECS: (#{disk_secs})" disk_time = self.fix_mins(disk_secs) puts "DISK_TIME: (#{disk_time})" track_times = self.fix_offsets(disk_secs, offsets) end
# File oldcode/cddb.rb, line 37 def read_directory() Dir.foreach(@@Options[:cddb_dir]) do |cddb_file| puts "File: #{cddb_file}" unless cddb_file =~ %r^\.\.?$/ #@files << [@@Options[:cddb_dir], "/", x].join Album.new([@@Options[:cddb_dir], cddb_file].join("/")) end #break end end