# Query is two parts, first ID, then name artist_id = `dcop amarok collection query "SELECT DISTINCT artist FROM tags WHERE url = '#{file}'"`.chomp() artist = `dcop amarok collection query "SELECT DISTINCT artist.name FROM artist WHERE id = '#{artist_id}'"`.chomp() album_id = `dcop amarok collection query "SELECT DISTINCT album FROM tags WHERE url = '#{file}'"`.chomp() album = `dcop amarok collection query "SELECT DISTINCT album.name FROM album WHERE id = '#{album_id}'"`.chomp() puts( "ArtistId : #{artist_id}" ) puts( "Artist : #{artist}" ) puts( "AlbumId : #{album_id}" ) puts( "Album : #{album}" ) if artist_id.empty?() and album_id.empty?() `dcop amarok playlist popupMessage "EmbedCover Error: This track is not in your Collection."` next end md5sum = MD5.hexdigest( "#{artist.downcase()}#{album.downcase()}" ) imagefolder = "#{ENV['HOME']}/.kde/share/apps/amarok/albumcovers/large/" image = "#{imagefolder}#{md5sum}" puts( "Imagepath: #{image}" ) unless FileTest.exist?( image ) `dcop amarok playlist popupMessage "EmbedCover: No image found for this track."` next end output = `ruby #{backend} "#{image}" "#{file}"` if $?.success?() `dcop amarok playlist popupMessage "EmbedCover has successfully embedded the image."` else reg = Regexp.new( "Error:.*", Regexp::MULTILINE ) errormsg = reg.match( output ) `dcop amarok playlist popupMessage "EmbedCover #{errormsg}"` end