Store more track information (play count, location)
This commit is contained in:
parent
947aa73411
commit
b9d36e264e
|
@ -31,20 +31,24 @@ def close():
|
|||
def library(args):
|
||||
name = "Default"
|
||||
root = ""
|
||||
if len(args) >= 1:
|
||||
name = args[0]
|
||||
if len(args) >= 2:
|
||||
name = args[0]
|
||||
#if len(args) >= 2:
|
||||
space = ' '
|
||||
root = expandPath( space.join(args[1:]) )
|
||||
else:
|
||||
return
|
||||
|
||||
#next = settings.get("nextlib")
|
||||
if checkDir(root) == False:
|
||||
return
|
||||
|
||||
# Insert the library into the database
|
||||
database.open()
|
||||
next = database.count('library')
|
||||
database.insert('library',(next,name,root) )
|
||||
database.close()
|
||||
|
||||
if not root == "":
|
||||
manager.run("scan",[root])
|
||||
manager.run("scan",[root])
|
||||
|
||||
|
||||
# Called when the plugin needs to perform some action
|
||||
|
|
|
@ -72,6 +72,12 @@ def run(file=None):
|
|||
if file == None:
|
||||
return
|
||||
|
||||
if len(file) < 2:
|
||||
return
|
||||
|
||||
root = file[0]
|
||||
file = file[1]
|
||||
|
||||
if validFile(file) == False:
|
||||
return
|
||||
|
||||
|
@ -82,20 +88,28 @@ def run(file=None):
|
|||
return
|
||||
|
||||
# Find artist information
|
||||
artist = t.artist#.replace("\'","\'\'")
|
||||
artist = t.artist
|
||||
if artist == "":
|
||||
artist = "Unknown Artist"
|
||||
|
||||
# Insert the artist of it is new
|
||||
arid,inserted = findId("artist",artist)
|
||||
if inserted == False:
|
||||
database.insert("artist", (arid, artist) )
|
||||
|
||||
album = t.album#.replace("\'","\'\'")
|
||||
|
||||
# Find album information
|
||||
album = t.album
|
||||
if album == "":
|
||||
album = "Unknown Album"
|
||||
|
||||
#alid = database.count("album")
|
||||
# Insert the album if it is new
|
||||
alid,inserted = findId("album",album)
|
||||
if inserted == False:
|
||||
database.insert("album", (alid, album) )
|
||||
#database.commit()
|
||||
|
||||
# Find the track information
|
||||
title = t.title
|
||||
if title == "":
|
||||
title = "Unknown Title"
|
||||
# Insert the track if it is new
|
||||
trid,inserted = findId("track",title)
|
||||
if inserted == False:
|
||||
database.insert("track", (trid,arid,alid,0,title,file[len(root):]))
|
||||
|
|
|
@ -22,6 +22,7 @@ from manager import manager
|
|||
from tools import database
|
||||
#from library.scan import scan
|
||||
|
||||
global root
|
||||
|
||||
# Called every time the plugin is enabled
|
||||
def open():
|
||||
|
@ -42,7 +43,8 @@ def scan(dir):
|
|||
scan(path)
|
||||
else:
|
||||
write(path,True)
|
||||
manager.run("extract", path)
|
||||
global root
|
||||
manager.run("extract", (root,path))
|
||||
#database.insert(path)
|
||||
#self.files += [path]
|
||||
|
||||
|
@ -52,16 +54,19 @@ def run(args=None):
|
|||
if args == None:
|
||||
return
|
||||
space = ' '
|
||||
path = expandPath( space.join(args) )
|
||||
global root
|
||||
root = expandPath( space.join(args) )
|
||||
|
||||
database.open()
|
||||
scan(path)
|
||||
scan(root)
|
||||
|
||||
#count = str(database.count("files"))
|
||||
count = str(database.count("artist"))
|
||||
write("Library contains "+count+" artists.")
|
||||
count = str(database.count("album"))
|
||||
write("Library contains "+count+" albums.")
|
||||
count = str(database.count("track"))
|
||||
write("Library contains "+count+" tracks.")
|
||||
|
||||
database.close()
|
||||
|
||||
|
|
|
@ -61,6 +61,16 @@ def create():
|
|||
path TEXT UNIQUE
|
||||
);
|
||||
|
||||
CREATE TABLE track
|
||||
(
|
||||
id INTEGER PRIMARY KEY,
|
||||
artist INTEGER,
|
||||
album INTEGER,
|
||||
count INTEGER,
|
||||
name TEXT,
|
||||
path TEXT UNIQUE
|
||||
);
|
||||
|
||||
|
||||
""")
|
||||
|
||||
|
@ -69,6 +79,7 @@ def create():
|
|||
vals["artist"]= "?,?"
|
||||
vals["album"] = "?,?"
|
||||
vals["library"] = "?,?,?"
|
||||
vals["track"] = "?,?,?,?,?,?"
|
||||
|
||||
|
||||
|
||||
|
@ -127,9 +138,5 @@ def select(select,table,where=None):
|
|||
if not (where==None):
|
||||
statement += ' where '+where
|
||||
#print statement
|
||||
try:
|
||||
result = execute(statement)
|
||||
return result
|
||||
except:
|
||||
print statement
|
||||
return None
|
||||
result = execute(statement)
|
||||
return result
|
Loading…
Reference in New Issue