Correctly store the current library
This commit is contained in:
parent
854b55feaa
commit
c7e8239a35
|
@ -10,6 +10,7 @@ __date__ ="$Jan 27, 2010 6:21:27 PM$"
|
||||||
from bt.message import write
|
from bt.message import write
|
||||||
from sqlite3 import *
|
from sqlite3 import *
|
||||||
from bt import sql
|
from bt import sql
|
||||||
|
import settings
|
||||||
|
|
||||||
def init():
|
def init():
|
||||||
if sql.dbexists() == True:
|
if sql.dbexists() == True:
|
||||||
|
@ -52,8 +53,6 @@ def newlib(name,path):
|
||||||
try:
|
try:
|
||||||
ins = sql.Insert('library',[None,name,path])
|
ins = sql.Insert('library',[None,name,path])
|
||||||
ins.execute()
|
ins.execute()
|
||||||
|
|
||||||
#sel = sql.Insert('library')
|
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -108,11 +107,27 @@ def rmlib(name):
|
||||||
write("Removed library: "+name)
|
write("Removed library: "+name)
|
||||||
|
|
||||||
|
|
||||||
|
def libid(libname):
|
||||||
|
sel = sql.Select("id","library","name='"+libname+"'")
|
||||||
|
result = sel.execute().fetchone()
|
||||||
|
if result == None:
|
||||||
|
return None
|
||||||
|
return result[0]
|
||||||
|
|
||||||
|
|
||||||
def listlib():
|
def listlib():
|
||||||
sel = sql.Select("*","library")
|
sel = sql.Select("*","library")
|
||||||
result = sel.execute().fetchall()
|
result = sel.execute().fetchall()
|
||||||
|
id = settings.get("curlib")
|
||||||
|
curname = ""
|
||||||
write("Id Name Path")
|
write("Id Name Path")
|
||||||
write("------------------")
|
write("------------------")
|
||||||
for row in result:
|
for row in result:
|
||||||
|
if row[0] == id:
|
||||||
|
curname = row[1]
|
||||||
write( str(row[0]) + " " +
|
write( str(row[0]) + " " +
|
||||||
row[1] + " " + row[2] )
|
row[1] + " " + row[2] )
|
||||||
|
|
||||||
|
#if not curname == "":
|
||||||
|
#write("")
|
||||||
|
write("Current: "+curname)
|
|
@ -20,7 +20,8 @@ class Plugin(plugin.Plugin):
|
||||||
|
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
settings.set("curlib",-1)
|
if settings.has("curlib") == False:
|
||||||
|
settings.set("curlib",-1)
|
||||||
|
|
||||||
|
|
||||||
def create(self,args):
|
def create(self,args):
|
||||||
|
@ -34,7 +35,7 @@ class Plugin(plugin.Plugin):
|
||||||
path = expandPath(join.join(args[1:]))
|
path = expandPath(join.join(args[1:]))
|
||||||
db.newlib(name,path)
|
db.newlib(name,path)
|
||||||
if settings.get("curlib")==-1:
|
if settings.get("curlib")==-1:
|
||||||
settings.set("curlib")
|
settings.set("curlib",db.libid(name))
|
||||||
|
|
||||||
|
|
||||||
def remove(self,args):
|
def remove(self,args):
|
||||||
|
@ -62,3 +63,7 @@ class Plugin(plugin.Plugin):
|
||||||
update.go(args[1])
|
update.go(args[1])
|
||||||
elif args[0] == "prcnt":
|
elif args[0] == "prcnt":
|
||||||
update.prcnt()
|
update.prcnt()
|
||||||
|
elif args[0] == "switch":
|
||||||
|
newLib = db.libid(args[1])
|
||||||
|
if not newLib == None:
|
||||||
|
settings.set("curlib",newLib)
|
|
@ -13,7 +13,7 @@ class Plugin(plugin.Plugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
plugin.Plugin.__init__(self)
|
plugin.Plugin.__init__(self)
|
||||||
self.help = "Used to control various aspects of playback"
|
self.help = "Used to control various aspects of playback"
|
||||||
self.usage = "music [load]"
|
self.usage = "music [load, pause, play]"
|
||||||
|
|
||||||
|
|
||||||
def loadTrack(self,args):
|
def loadTrack(self,args):
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
# Basic plugin class
|
||||||
|
|
||||||
|
__author__="bjschuma"
|
||||||
|
__date__ ="$Feb 7, 2010 7:40:01 PM$"
|
||||||
|
|
||||||
|
|
||||||
|
from bt import plugin
|
||||||
|
|
||||||
|
|
||||||
|
class Plugin(plugin.Plugin):
|
||||||
|
def __init__(self):
|
||||||
|
plugin.Plugin.__init__(self)
|
||||||
|
self.help = "next"
|
||||||
|
|
||||||
|
|
||||||
|
def open(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def close(self):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def run(self, args=None):
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in New Issue