=begin AUTHOR: Kesiev WHAT IT DOES: Adds Audio CD support. Press the refresh button to update the playlist once the disc is inserted. =end begin $cdaudio=require "freedb"; rescue LoadError; end if $cdaudio then $lists << { :icon=>"drive-cdrom", :label=>"Audio CD", :device=>"/dev/cdrom", :onrefresh=>Proc.new { |l| open_cd(l) }, :file=>"#{$opt[:root]}/cdaudio", :protected=>true, :root=>"cdda://" } def open_cd(section) open(section[:file],"w") { |f| begin freedb = Freedb.new(section[:device]) freedb.fetch freedb.get_result(0) freedb.tracks.each_with_index { |t,i| f.puts(formatrecord({:year=>freedb.year,:artist=>freedb.artist,:album=>freedb.title,:file=>i+1,:trackno=>i+1,:title=>t["title"]})) } rescue => error puts "Error: #{error}" end } end end