Fixed loading of random songs

I fixed loading of songs not in the library by correctly implementing
the path walk function in the DLTree class
This commit is contained in:
Bryan Schumaker 2010-10-15 23:10:14 -04:00
parent 519f4c0fd8
commit 1da55341d4
5 changed files with 12 additions and 7 deletions

View File

@ -35,7 +35,6 @@ def lib_get_attr(id, attr):
global library
if id >= 0:
return library.get_attr(id, attr)
return None
def lib_play_id(id):
global cur_lib_id
@ -46,7 +45,7 @@ def lib_play_id(id):
def lib_find_id(file):
global library
library.find_id(file)
return library.find_id(file)
def lib_get_cur_id():
global cur_lib_id

View File

@ -70,7 +70,7 @@ class Collection:
def find_id(self, file):
stripped = file.strip(libsaria.path.sep)
split = stripped.split(libsaria.path.sep)
print self.fs_tree.walk_path(split)
return self.fs_tree.walk_path(split)[0]
def get_attr(self, id, attr):
rec = self.records[id]

View File

@ -28,13 +28,16 @@ class DLTree:
# print self.get_path()
def walk_path(self, path):
if len(path) == 0:
return True
p = path[0]
if p not in self.child_fwd:
return False
child = self.child_fwd[p]
val = child.walk_path[path[1:]]
if val != False:
return p + [val]
val = child.walk_path(path[1:])
if val == True:
return child.child_fwd.keys()
return val
def walk_backwards(self, child=None):
cmp = self.child_bck.get(child, None)

View File

@ -39,6 +39,7 @@ def universal_open(file):
global plugin
if path.is_dir(file):
libsaria.collection.new_source(file)
file = file.replace("%20", " ")
split = path.splitext(file)
ext = split[1]
# Install and start a plugin

View File

@ -59,7 +59,9 @@ class InfoBar(Bar):
libsaria.event.invite("POSTLOAD", self.change_title)
def change_title(self, filepath):
id = libsaria.collection.lib_get_cur_id()
#id = libsaria.collection.lib_get_cur_id()
id = libsaria.collection.lib_find_id(filepath)
print id
title = lib_get_attr(id, "title")
artist = libsaria.collection.lib_get_attr(id, "artist")
self.title.set_text("%s by %s" % (title,artist))