60 lines
1.1 KiB
Python
60 lines
1.1 KiB
Python
# Basic plugin class
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$Feb 7, 2010 7:40:01 PM$"
|
|
|
|
|
|
from bt import plugin
|
|
from bt import signal
|
|
from bt.message import write
|
|
from bt import sql
|
|
from ct import db
|
|
import settings
|
|
|
|
from manager import run
|
|
|
|
|
|
class Plugin(plugin.Plugin):
|
|
def __init__(self):
|
|
plugin.Plugin.__init__(self)
|
|
self.help = "Advance to the next track"
|
|
self.usage = "next [, songID]"
|
|
|
|
|
|
def open(self):
|
|
if settings.has("curtrk") == False:
|
|
settings.set("curtrk",-1)
|
|
signal.register("next",self.next)
|
|
|
|
|
|
def close(self):
|
|
pass
|
|
|
|
|
|
def next(self):
|
|
signal.stop("next")
|
|
|
|
curlib = str(settings.get("curlib"))
|
|
count = db.countlib(curlib)
|
|
nxttrk = settings.get("curtrk")
|
|
if nxttrk > count:
|
|
nxttrk = 0
|
|
else:
|
|
nxttrk += 1
|
|
|
|
sel = sql.Select("track","libtrack","library="+str(curlib))
|
|
rows = sel.execute().fetchall()
|
|
run("next",[rows[nxttrk][0], nxttrk])
|
|
|
|
|
|
|
|
def run(self, args=None):
|
|
if args==None or len(args)==0:
|
|
signal.emit("next")
|
|
return
|
|
elif len(args) == 1:
|
|
write("Usage:" + self.usage)
|
|
# db ID, list index
|
|
path = db.getpath(args[0],args[1])
|
|
|