84 lines
1.3 KiB
Python
84 lines
1.3 KiB
Python
#! /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." ) |