File indexing completed on 2024-05-05 04:49:36
0001 #!/usr/bin/env ruby 0002 # 0003 # script to remove stale entries in some database tables (artist) 0004 # 0005 # (c) 2006 Roland Gigler <rolandg@web.de> 0006 # License: GNU General Public License V2 0007 0008 system("dcop", "amarok", "playlist", "shortStatusMessage", "Removing stale 'artist' entries from the database") 0009 0010 qresult = `dcop amarok collection query "SELECT id FROM artist;"` 0011 result = qresult.split( "\n" ) 0012 0013 i = 0 0014 0015 result.each do |id| 0016 print "Checking: #{id}, " 0017 qresult2 = `dcop amarok collection query "SELECT COUNT(*) FROM tags where artist = #{id};"` 0018 count = qresult2.chomp() 0019 printf "count: %s\n", count 0020 if count == "0" 0021 i = i + 1 0022 qresult3 = `dcop amarok collection query "SELECT name FROM artist where id = #{id} ;"` 0023 result3 = qresult3.split( "\n" ) 0024 puts "==>: Deleting: #{id}, #{result3}" 0025 system("dcop", "amarok", "collection", "query", "DELETE FROM artist WHERE id = '#{id}'") 0026 end 0027 end 0028 puts "i: #{i}" 0029 0030 if i > 0 0031 system("dcop", "amarok", "playlist", "popupMessage", "Removed #{i} stale 'artist' entries from the database") 0032 end 0033