lib/audioinfo.rb in ruby-audioinfo-0.3.2 vs lib/audioinfo.rb in ruby-audioinfo-0.3.3

- old
+ new

@@ -34,11 +34,11 @@ "trackid" => "Track Id" } SUPPORTED_EXTENSIONS = %w{mp3 ogg mpc wma mp4 aac m4a flac} - VERSION = "0.3.2" + VERSION = "0.3.3" attr_reader :path, :extension, :musicbrainz_infos, :tracknum, :bitrate, :vbr attr_reader :artist, :album, :title, :length, :date # Part of testing API - you should not use this directly @@ -252,10 +252,17 @@ @needs_commit = true @tracknum = v end end + def picture=(filepath) + if @picture != filepath + @needs_commit = true + @picture = filepath + end + end + # hash-like access to tag def [](key) @hash[key] end @@ -272,18 +279,25 @@ Mp3Info.open(@path) do |info| info.tag.artist = @artist info.tag.title = @title info.tag.album = @album info.tag.tracknum = @tracknum + if @picture + info.tag2.remove_pictures + info.tag2.add_picture(File.binread(@picture)) + end end when OggInfo OggInfo.open(@path) do |ogg| { "artist" => @artist, "album" => @album, "title" => @title, "tracknumber" => @tracknum}.each do |k,v| ogg.tag[k] = v.to_s end + if @picture + ogg.picture = @picture + end end when ApeTag ape = ApeTag.new(@path) ape.update do |fields|