ocarina/src/core/scan.py

68 lines
1.2 KiB
Python
Raw Normal View History

2009-12-27 20:32:41 -05:00
# This is a simple test plugin, to make sure everything is working
__author__="bjschuma"
__date__ ="$Dec 27, 2009 8:07:18 PM$"
global name, app, type, path, opt
name = "scan"
app = "ocarina"
2009-12-27 20:32:41 -05:00
type = "core"
path = ""
opt = []
import tagpy
2009-12-27 20:32:41 -05:00
from bt.message import write
2009-12-27 21:55:56 -05:00
from bt.file import *
2009-12-30 22:41:42 -05:00
import settings
from manager import manager
#from library import *
from tools import database
2009-12-27 21:55:56 -05:00
#from library.scan import scan
2009-12-27 20:32:41 -05:00
# Called every time the plugin is enabled
def open():
pass
# Called every time the plugin is stopped
def close():
pass
2009-12-27 21:55:56 -05:00
# Performs the actual scanning
def scan(dir):
files = ls(dir)
for file in files:
path = join(dir,file)
if checkDir(path)==True:
scan(path)
else:
write(path,True)
manager.run("extract", path)
#database.insert(path)
2009-12-27 21:55:56 -05:00
#self.files += [path]
# Called to scan a directory. Performs initial path expansion before traversing
2009-12-27 20:32:41 -05:00
def run(args=None):
if args == None:
return
space = ' '
2009-12-27 21:55:56 -05:00
path = expandPath( space.join(args) )
2009-12-30 22:41:42 -05:00
database.open()
2009-12-27 21:55:56 -05:00
scan(path)
#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.")
database.close()