Correctly store the current library

This commit is contained in:
bjschuma 2010-02-07 20:22:13 -05:00
parent 854b55feaa
commit c7e8239a35
4 changed files with 52 additions and 6 deletions

View File

@ -10,6 +10,7 @@ __date__ ="$Jan 27, 2010 6:21:27 PM$"
from bt.message import write
from sqlite3 import *
from bt import sql
import settings
def init():
if sql.dbexists() == True:
@ -52,8 +53,6 @@ def newlib(name,path):
try:
ins = sql.Insert('library',[None,name,path])
ins.execute()
#sel = sql.Insert('library')
except:
pass
@ -108,11 +107,27 @@ def rmlib(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():
sel = sql.Select("*","library")
result = sel.execute().fetchall()
id = settings.get("curlib")
curname = ""
write("Id Name Path")
write("------------------")
for row in result:
if row[0] == id:
curname = row[1]
write( str(row[0]) + " " +
row[1] + " " + row[2] )
row[1] + " " + row[2] )
#if not curname == "":
#write("")
write("Current: "+curname)

View File

@ -20,7 +20,8 @@ class Plugin(plugin.Plugin):
def open(self):
settings.set("curlib",-1)
if settings.has("curlib") == False:
settings.set("curlib",-1)
def create(self,args):
@ -34,7 +35,7 @@ class Plugin(plugin.Plugin):
path = expandPath(join.join(args[1:]))
db.newlib(name,path)
if settings.get("curlib")==-1:
settings.set("curlib")
settings.set("curlib",db.libid(name))
def remove(self,args):
@ -62,3 +63,7 @@ class Plugin(plugin.Plugin):
update.go(args[1])
elif args[0] == "prcnt":
update.prcnt()
elif args[0] == "switch":
newLib = db.libid(args[1])
if not newLib == None:
settings.set("curlib",newLib)

View File

@ -13,7 +13,7 @@ class Plugin(plugin.Plugin):
def __init__(self):
plugin.Plugin.__init__(self)
self.help = "Used to control various aspects of playback"
self.usage = "music [load]"
self.usage = "music [load, pause, play]"
def loadTrack(self,args):

26
src/core/next.py Normal file
View File

@ -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