Tags in DLValTree
I store the tags in a doubly-linked value tree from now on.
This commit is contained in:
parent
88ca239a53
commit
cd78355b74
|
@ -22,12 +22,12 @@ badfiles = set()
|
||||||
|
|
||||||
ttable = dict()
|
ttable = dict()
|
||||||
for s in string.punctuation:
|
for s in string.punctuation:
|
||||||
ttable[ord(s)] = ""
|
ttable[ord(s)] = u""
|
||||||
for s in string.lowercase:
|
for s in string.lowercase:
|
||||||
ttable[ord(s)] = ord(s) - 32
|
ttable[ord(s)] = ord(s) - 32
|
||||||
|
|
||||||
def reset():
|
def reset():
|
||||||
from libsaria.trees import FSTree, DLFSTree
|
from libsaria.trees import FSTree, DLFSTree, DLValTree
|
||||||
from tree import DLTree
|
from tree import DLTree
|
||||||
from index import Index
|
from index import Index
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ def reset():
|
||||||
sources = FSTree()
|
sources = FSTree()
|
||||||
|
|
||||||
fs_tree = DLFSTree()
|
fs_tree = DLFSTree()
|
||||||
tag_tree = DLTree()
|
tag_tree = DLValTree()
|
||||||
index = Index()
|
index = Index()
|
||||||
tracks = dict()
|
tracks = dict()
|
||||||
size = 0
|
size = 0
|
||||||
|
@ -49,32 +49,30 @@ def reset():
|
||||||
#save()
|
#save()
|
||||||
|
|
||||||
def load():
|
def load():
|
||||||
#global fs_tree
|
global fs_tree
|
||||||
#global tag_tree
|
global tag_tree
|
||||||
#global index
|
#global index
|
||||||
global tracks
|
global tracks
|
||||||
global sources
|
global sources
|
||||||
#global size
|
#global size
|
||||||
#global songs
|
#global songs
|
||||||
reset()
|
|
||||||
objects = libsaria.data.load("library", ".lib")
|
objects = libsaria.data.load("library", ".lib")
|
||||||
if objects == None or len(objects) != 3:
|
if objects == None or len(objects) != 4:
|
||||||
#if objects == None or len(objects) != 6:
|
#if objects == None or len(objects) != 6:
|
||||||
reset()
|
reset()
|
||||||
return
|
return
|
||||||
(sources, tracks) = objects
|
(sources, tracks, fs_tree, tag_tree) = objects
|
||||||
#(fs_tree, tag_tree, index, tracks, next_id, size) = objects
|
#(fs_tree, tag_tree, index, tracks, next_id, size) = objects
|
||||||
libsaria.event.start("POSTLIBLOAD")
|
libsaria.event.start("POSTLIBLOAD")
|
||||||
|
|
||||||
def save():
|
def save():
|
||||||
global sources
|
global sources
|
||||||
libsaria.data.save( (sources, tracks), "library", ".lib")
|
libsaria.data.save( (sources, tracks, fs_tree, tag_tree),
|
||||||
|
"library", ".lib")
|
||||||
|
|
||||||
def walk():
|
def walk():
|
||||||
return []
|
for tag in tag_tree.walk():
|
||||||
for tag in tag_tree.walk_forwards():
|
yield tag[3]
|
||||||
#yield tag[3]
|
|
||||||
pass
|
|
||||||
|
|
||||||
def file_to_id(file):
|
def file_to_id(file):
|
||||||
global fs_tree
|
global fs_tree
|
||||||
|
@ -166,17 +164,24 @@ def insert_track(path, ref):
|
||||||
global tracks
|
global tracks
|
||||||
global ttable
|
global ttable
|
||||||
global fs_tree
|
global fs_tree
|
||||||
|
global tag_tree
|
||||||
tags = ref.tag()
|
tags = ref.tag()
|
||||||
audio = ref.audioProperties()
|
audio = ref.audioProperties()
|
||||||
id = os.stat(path).st_ino
|
ino = os.stat(path).st_ino
|
||||||
track = Track(tags, audio)
|
track = Track(tags, audio)
|
||||||
artist = tags.artist or u"Unknown Artist"
|
artist = tags.artist or u"Unknown Artist"
|
||||||
album = tags.album or u"Unknown Album"
|
album = tags.album or u"Unknown Album"
|
||||||
title = tags.title or u"Unknown Title"
|
title = tags.title or u"Unknown Title"
|
||||||
fs = fs_tree.insert_path(path)
|
fs = fs_tree.insert_path(path)
|
||||||
|
tag = tag_tree.insert( [artist.translate(ttable),
|
||||||
|
album.translate(ttable),
|
||||||
|
title.translate(ttable), ino],
|
||||||
|
[artist, album, title, ino]
|
||||||
|
)
|
||||||
|
|
||||||
track.fs = fs
|
track.fs = fs
|
||||||
tracks[id] = track
|
track.tags = tag
|
||||||
|
tracks[ino] = track
|
||||||
|
|
||||||
def update_path(path):
|
def update_path(path):
|
||||||
global badfiles
|
global badfiles
|
||||||
|
|
|
@ -21,4 +21,4 @@ class Track:
|
||||||
self.lenstr = lenstr
|
self.lenstr = lenstr
|
||||||
|
|
||||||
self.fs = None
|
self.fs = None
|
||||||
#self.tags = None
|
self.tags = None
|
||||||
|
|
Loading…
Reference in New Issue