79 lines
1.5 KiB
Python
79 lines
1.5 KiB
Python
# Basic plugin class
|
|
|
|
__author__="bjschuma"
|
|
__date__ ="$Feb 5, 2010 7:47:18 PM$"
|
|
|
|
|
|
from bt import plugin
|
|
from bt.message import write
|
|
from bt import sql
|
|
from bt import signal
|
|
|
|
from ct import gstreamer
|
|
import settings
|
|
|
|
|
|
class Plugin(plugin.Plugin):
|
|
def __init__(self):
|
|
plugin.Plugin.__init__(self)
|
|
self.help = "Used to control various aspects of playback"
|
|
self.usage = "music [load, whatis, now, pause, play, vol]"
|
|
|
|
|
|
def loadTrack(self,args):
|
|
if len(args) == 0:
|
|
write("Usage: music load track")
|
|
join = ' '
|
|
path = join.join(args)
|
|
write("Loading: "+path,True)
|
|
gstreamer.close()
|
|
gstreamer.load(path)
|
|
|
|
|
|
def whatIs(self,id):
|
|
curlib = str( settings.get("curlib") )
|
|
selstr = "track.name,artist.name,album.name"
|
|
frmstr = "track,artist,album,libtrack"
|
|
whrstr = "track.artist=artist.id AND track.album=album.id"
|
|
whrstr += " AND libtrack.track=track.id AND libtrack.library="+curlib
|
|
sel = sql.Select(selstr, frmstr, whrstr)
|
|
result = sel.execute().fetchall()
|
|
|
|
result = result[id]
|
|
|
|
write(result[0])
|
|
write("By: "+result[1])
|
|
write("From: "+result[2])
|
|
|
|
|
|
def nowPlaying(self):
|
|
self.whatIs(settings.get("curtrk"))
|
|
|
|
|
|
|
|
def run(self, args=None):
|
|
if args==None or len(args) < 1:
|
|
write(self.help)
|
|
return
|
|
|
|
if args[0] == "load":
|
|
self.loadTrack(args[1:])
|
|
|
|
elif args[0] == "whatis":
|
|
id = int(args[1])
|
|
self.whatIs(id)
|
|
|
|
elif args[0] == "now":
|
|
self.nowPlaying()
|
|
|
|
elif args[0] == "play":
|
|
signal.emit("play")
|
|
|
|
elif args[0] == "pause":
|
|
signal.emit("pause")
|
|
|
|
elif args[0] == "vol":
|
|
gstreamer.setvol(args[1])
|
|
|
|
|