diff --git a/libsaria/collection/index.py b/libsaria/collection/index.py index ac190892..e0307149 100644 --- a/libsaria/collection/index.py +++ b/libsaria/collection/index.py @@ -33,7 +33,7 @@ class Index(dict): def __init__(self): dict.__init__(self) - def insert(self, tags, id): + def insert(self, id, tags): get = self.get for tag in tags: for word in format(tag): diff --git a/libsaria/collection/library.py b/libsaria/collection/library.py index 893715a9..113e0321 100644 --- a/libsaria/collection/library.py +++ b/libsaria/collection/library.py @@ -51,23 +51,23 @@ def reset(): def load(): global fs_tree global tag_tree - #global index + global index global tracks global sources #global size #global songs objects = libsaria.data.load("library", ".lib") - if objects == None or len(objects) != 4: + if objects == None or len(objects) != 5: #if objects == None or len(objects) != 6: reset() return - (sources, tracks, fs_tree, tag_tree) = objects + (sources, tracks, fs_tree, tag_tree, index) = objects #(fs_tree, tag_tree, index, tracks, next_id, size) = objects libsaria.event.start("POSTLIBLOAD") def save(): global sources - libsaria.data.save( (sources, tracks, fs_tree, tag_tree), + libsaria.data.save( (sources, tracks, fs_tree, tag_tree, index), "library", ".lib") def walk(): @@ -165,6 +165,7 @@ def insert_track(path, ref): global ttable global fs_tree global tag_tree + global index tags = ref.tag() audio = ref.audioProperties() ino = os.stat(path).st_ino @@ -179,6 +180,7 @@ def insert_track(path, ref): [artist, album, title, ino] ) + index.insert(ino, (artist, album, title)) track.fs = fs track.tags = tag tracks[ino] = track