libsaria: Began library scanning routines

I can add a new path to a dictionary, but I don't do any actual scanning
yet.  Instead, I just print out each path in the library.
This commit is contained in:
Bryan Schumaker 2011-05-21 07:16:00 -04:00
parent 39c9a7cca8
commit 8debb4a508
5 changed files with 29 additions and 2 deletions

View File

@ -34,7 +34,7 @@ def universal_open(file):
file = file.replace("%20", " ")
file = file.replace("%22", "\"")
if path.is_dir(file):
libsaria.sources.new_source(file)
libsaria.sources.make_library(file)
return
base, ext = path.splitext(file)
func = mapping.get(ext, open_music)

View File

@ -4,6 +4,7 @@ import libsaria
exists = libsaria.path.exists
expand = libsaria.path.expand
import library
import oldlibrary
import playlist
import queue
@ -52,6 +53,13 @@ def new_source(path, bg=True):
oldlibrary.scan(path)
libsaria.callbacks.new_source()
def make_library(path):
path = expand(path)
if not exists(path):
return
library.add_path(path)
library.update()
def play_id(id):
global cur_id
cur_id = id

View File

@ -1,2 +1,8 @@
# Bryan Schumaker (5 / 20 / 2011)
import library
import update
# Function pointers for conveniance
add_path = library.add_path
update = update.update

View File

@ -6,5 +6,11 @@ library_lock = threading.Lock()
lock_library = library_lock.acquire
unlock_library = library_lock.release
# Map fileid(directory) -> dict()
# Map directory -> dict()
lib_dict = dict()
def add_path(path):
lock_library()
lib_dict.setdefault(path, dict())
unlock_library()

View File

@ -0,0 +1,7 @@
# Bryan Schumaker (5 / 21 / 2011)
import library
def update():
for path in library.lib_dict.keys():
print path