Began work on scanning / updating a library
This commit is contained in:
parent
1d0a216c12
commit
5dc8dc52e9
|
@ -0,0 +1,84 @@
|
|||
#! /usr/bin/python
|
||||
|
||||
# To change this template, choose Tools | Templates
|
||||
# and open the template in the editor.
|
||||
|
||||
__author__="bjschuma"
|
||||
__date__ ="$Jan 30, 2010 3:57:53 PM$"
|
||||
|
||||
|
||||
from bt import sql
|
||||
from bt import needle
|
||||
from bt.file import *
|
||||
from bt.message import write
|
||||
|
||||
import tagpy
|
||||
|
||||
global total
|
||||
global scanned
|
||||
global added
|
||||
total = 0
|
||||
added = 0
|
||||
scanned = 0
|
||||
|
||||
|
||||
def incr(path):
|
||||
global total
|
||||
total += 1
|
||||
|
||||
|
||||
def addtrk(path):
|
||||
global added
|
||||
global scanned
|
||||
scanned += 1
|
||||
try:
|
||||
f = tagpy.FileRef(path)
|
||||
added += 1
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def scan((dir,func)):
|
||||
files = ls(dir)
|
||||
for file in files:
|
||||
path = join(dir,file)
|
||||
if checkDir(path) == True:
|
||||
scan((path,func))
|
||||
else:
|
||||
func(path)
|
||||
|
||||
|
||||
def go(name):
|
||||
global total
|
||||
global added
|
||||
global scanned
|
||||
total = 0
|
||||
added = 0
|
||||
scanned = 0
|
||||
|
||||
sel = sql.Select("id,path","library","name='"+name+"'")
|
||||
result = sel.execute().fetchall()
|
||||
if result == []:
|
||||
return
|
||||
libid = result[0][0]
|
||||
path = result[0][1]
|
||||
|
||||
# Start a thread to count the total number of files to scan
|
||||
totthr = needle.Needle(scan,(path,incr))
|
||||
totthr.start()
|
||||
|
||||
scthr = needle.Needle(scan,(path,addtrk))
|
||||
scthr.start()
|
||||
|
||||
#scan(path, incr)
|
||||
#write(path)
|
||||
#totthr.join()
|
||||
#write(str(total) + " Files to scan")
|
||||
|
||||
|
||||
def prcnt():
|
||||
global total
|
||||
global scanned
|
||||
global added
|
||||
write( str(scanned) + " / " + str(total) )
|
||||
write( "Added " + str(added) + " tracks." )
|
|
@ -8,6 +8,7 @@ from bt import plugin
|
|||
from bt.file import expandPath
|
||||
from bt.message import write
|
||||
from ct import db
|
||||
from ct import update
|
||||
|
||||
|
||||
class Plugin(plugin.Plugin):
|
||||
|
@ -50,3 +51,7 @@ class Plugin(plugin.Plugin):
|
|||
db.listlib()
|
||||
elif args[0] == "remove":
|
||||
self.remove(args[1:])
|
||||
elif args[0] == "update":
|
||||
update.go(args[1])
|
||||
elif args[0] == "prcnt":
|
||||
update.prcnt()
|
||||
|
|
Loading…
Reference in New Issue