76 lines
1.6 KiB
Python
76 lines
1.6 KiB
Python
# This is a simple test plugin, to make sure everything is working
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$Jan 2, 2010 1:18:37 PM$"
|
|
|
|
|
|
global name, app, type, path, opt
|
|
name = "next"
|
|
app = "ocarina"
|
|
type = "core"
|
|
path = ""
|
|
opt = []
|
|
|
|
from bt.message import write
|
|
from bt.file import join
|
|
import settings
|
|
from tools import database
|
|
from manager import manager
|
|
|
|
|
|
def next():
|
|
cur = str(settings.get("curlib"))
|
|
count = database.select("count(*)","libtrack","library="+cur).fetchone()[0]
|
|
|
|
curtrk = settings.get("current")
|
|
if curtrk > count:
|
|
curtrk = 0
|
|
else:
|
|
curtrk += 1
|
|
rows = database.select("track","libtrack","library="+cur).fetchall()
|
|
return rows[curtrk][0],curtrk
|
|
|
|
|
|
|
|
# Called every time the plugin is enabled
|
|
def open():
|
|
if settings.has("current") == False:
|
|
settings.set("current",0)
|
|
settings.init("next",next)
|
|
|
|
|
|
# Called every time the plugin is stopped
|
|
def close():
|
|
settings.delete("next")
|
|
pass
|
|
|
|
|
|
def help():
|
|
return "Advances to the next song"
|
|
|
|
|
|
# Called when the plugin needs to perform some action
|
|
def run(args=None):
|
|
if settings.has("curlib") == False:
|
|
return
|
|
curlib = str(settings.get("curlib"))
|
|
id,curtrk = settings.get("next")()
|
|
|
|
database.open()
|
|
a = database.select("path","library","id="+curlib).fetchone()[0]
|
|
b = database.select("path","track","id="+str(id)).fetchone()[0]
|
|
|
|
info = database.select("track.name, artist.name, album.name",
|
|
"track, album, artist",
|
|
"track.id="+str(id)+" and track.artist=artist.id and track.album=album.id").fetchone()
|
|
|
|
database.close()
|
|
settings.set("current",curtrk)
|
|
manager.run("load",([a+b]))
|
|
|
|
write(info[0])
|
|
write("By: "+info[1])
|
|
write("From: "+info[2])
|
|
|
|
manager.run("play")
|