diff --git a/src/core/ct/update.py b/src/core/ct/update.py index 197c556b..9582683b 100644 --- a/src/core/ct/update.py +++ b/src/core/ct/update.py @@ -13,16 +13,47 @@ from bt.file import * from bt.message import write import tagpy +import re global total global scanned global added global root +global goodFiles +global search + global libid + total = 0 added = 0 scanned = 0 root = "" +goodFiles = ["ogg", "mp3"] + + +# Generate search string (allows adding to goodFiles later) +def genSearch(): + global goodFiles + global search + search = ".*\.(" + for index,file in enumerate(goodFiles): + if index > 0: + search += "|" + search += file + search += ")" + +genSearch() + + + +# Test if the file extension is in goodFiles +def testPath(path): + global search + match = re.search(search,path,re.IGNORECASE) + if match == None: + return False + return True + def incr(path): @@ -75,6 +106,7 @@ def instrk(arid, alid, title, length, path): def addtrk(path): global added global scanned + scanned += 1 try: f = tagpy.FileRef(path) @@ -98,7 +130,8 @@ def scan((dir,func)): if checkDir(path) == True: scan((path,func)) else: - func(path) + if testPath(path) == True: + func(path) def go(name):