Created new library plugin, can create a library in sqlite
This commit is contained in:
parent
198855211f
commit
e5edd7a9dd
|
@ -0,0 +1,5 @@
|
||||||
|
__author__="bjschuma"
|
||||||
|
__date__ ="$Jan 27, 2010 6:20:54 PM$"
|
||||||
|
|
||||||
|
|
||||||
|
__all__ = ["db"]
|
|
@ -0,0 +1,53 @@
|
||||||
|
#! /usr/bin/python
|
||||||
|
|
||||||
|
# To change this template, choose Tools | Templates
|
||||||
|
# and open the template in the editor.
|
||||||
|
|
||||||
|
__author__="bjschuma"
|
||||||
|
__date__ ="$Jan 27, 2010 6:21:27 PM$"
|
||||||
|
|
||||||
|
|
||||||
|
from bt.message import write
|
||||||
|
from bt import sql
|
||||||
|
|
||||||
|
def init():
|
||||||
|
if sql.dbexists() == True:
|
||||||
|
return
|
||||||
|
|
||||||
|
table = sql.CTable("library")
|
||||||
|
table.addcol("id","INTEGER","PRIMARY KEY AUTOINCREMENT")
|
||||||
|
table.addcol("name","TEXT","UNIQUE")
|
||||||
|
table.addcol("path","TEXT","UNIQUE")
|
||||||
|
table.execute()
|
||||||
|
|
||||||
|
table = sql.CTable("artist")
|
||||||
|
table.addcol("id","INTEGER","PRIMARY KEY AUTOINCREMENT")
|
||||||
|
table.addcol("name","TEXT","UNIQUE")
|
||||||
|
table.execute()
|
||||||
|
|
||||||
|
table = sql.CTable("album")
|
||||||
|
table.addcol("id","INTEGER","PRIMARY KEY AUTOINCREMENT")
|
||||||
|
table.addcol("name","TEXT","UNIQUE")
|
||||||
|
table.execute()
|
||||||
|
|
||||||
|
table = sql.CTable("track")
|
||||||
|
table.addcol("id","INTEGER","PRIMARY KEY AUTOINCREMENT")
|
||||||
|
table.addcol("artist","INTEGER")
|
||||||
|
table.addcol("album","INTEGER")
|
||||||
|
table.addcol("count","INTEGER")
|
||||||
|
table.addcol("length","INTEGER")
|
||||||
|
table.addcol("name","TEXT")
|
||||||
|
table.addcol("path","TEXT","UNIQUE")
|
||||||
|
table.execute()
|
||||||
|
|
||||||
|
table = sql.CTable("libtrack")
|
||||||
|
table.addcol("library","INTEGER")
|
||||||
|
table.addcol("track","INTEGER")
|
||||||
|
table.execute()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def newlib(name,path):
|
||||||
|
ins = sql.Insert('library',[None,name,path])
|
||||||
|
ins.execute()
|
||||||
|
ins.commit()
|
|
@ -0,0 +1,38 @@
|
||||||
|
# Basic plugin class
|
||||||
|
|
||||||
|
__author__="bjschuma"
|
||||||
|
__date__ ="$Jan 27, 2010 6:16:01 PM$"
|
||||||
|
|
||||||
|
|
||||||
|
from bt import plugin
|
||||||
|
from bt.file import expandPath
|
||||||
|
from bt.message import write
|
||||||
|
from ct import db
|
||||||
|
|
||||||
|
|
||||||
|
class Plugin(plugin.Plugin):
|
||||||
|
def __init__(self):
|
||||||
|
plugin.Plugin.__init__(self)
|
||||||
|
self.help = "Used to access various parts of the library"
|
||||||
|
self.usage = "library [create]"
|
||||||
|
|
||||||
|
|
||||||
|
def create(self,args):
|
||||||
|
usage = "Usage: library create name path"
|
||||||
|
if len(args) < 2:
|
||||||
|
write(usage)
|
||||||
|
return
|
||||||
|
|
||||||
|
name = args[0]
|
||||||
|
join = ' '
|
||||||
|
path = expandPath(join.join(args[1:]))
|
||||||
|
db.newlib(name,path)
|
||||||
|
|
||||||
|
|
||||||
|
def run(self, args=None):
|
||||||
|
if (args==None) or (len(args)==0):
|
||||||
|
write(self.usage)
|
||||||
|
|
||||||
|
if args[0] == "create":
|
||||||
|
self.create(args[1:])
|
||||||
|
|
|
@ -8,21 +8,14 @@ from bt import plugin
|
||||||
import settings
|
import settings
|
||||||
settings.set("appname","ocarina2")
|
settings.set("appname","ocarina2")
|
||||||
|
|
||||||
|
from ct import db
|
||||||
|
|
||||||
|
|
||||||
class Plugin(plugin.Plugin):
|
class Plugin(plugin.Plugin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
plugin.Plugin.__init__(self)
|
plugin.Plugin.__init__(self)
|
||||||
self.help = ""
|
self.help = "A simple music player written in python"
|
||||||
|
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
pass
|
db.init()
|
||||||
|
|
||||||
|
|
||||||
def close(self):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def run(self, args=None):
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue