Find songs to remove when removing a library
This commit is contained in:
parent
b673309a20
commit
22f9d8108f
|
@ -8,6 +8,7 @@ __date__ ="$Jan 27, 2010 6:21:27 PM$"
|
|||
|
||||
|
||||
from bt.message import write
|
||||
from sqlite3 import *
|
||||
from bt import sql
|
||||
|
||||
def init():
|
||||
|
@ -56,8 +57,28 @@ def newlib(name,path):
|
|||
|
||||
|
||||
def rmlib(name):
|
||||
rm = sql.Remove("library","name='"+name+"'")
|
||||
rm.execute()
|
||||
sel = sql.Select("id","library","name='"+name+"'")
|
||||
result = sel.execute().fetchall()
|
||||
if result == []:
|
||||
return
|
||||
libid = result[0][0]
|
||||
|
||||
sel = sql.Select("track","libtrack","library="+str(libid))
|
||||
result = sel.execute().fetchall()
|
||||
|
||||
for track in result:
|
||||
where = "track="+str(track[0])+" AND library!="+str(libid)
|
||||
sel = sql.Select("track,library","libtrack",where )
|
||||
r = sel.execute().fetchall()
|
||||
# If track is not in any other library, it can be removed
|
||||
if r == []:
|
||||
write(r)
|
||||
|
||||
|
||||
|
||||
#rm = sql.Remove("library","name='"+name+"'")
|
||||
#rm.execute()
|
||||
#write("Removed library: "+str(libid))
|
||||
|
||||
|
||||
def listlib():
|
||||
|
|
|
@ -15,7 +15,7 @@ class Plugin(plugin.Plugin):
|
|||
def __init__(self):
|
||||
plugin.Plugin.__init__(self)
|
||||
self.help = "Used to access various parts of the library"
|
||||
self.usage = "library [create, list]"
|
||||
self.usage = "library [create, list, prcnt, remove, update]"
|
||||
|
||||
|
||||
def create(self,args):
|
||||
|
|
Loading…
Reference in New Issue