Modified backup code
The backup code needed to be modified so that it works with Ocarina 4.1. This involved writing a function to walk library ids, and using the lib_get_attr function from the collection.
This commit is contained in:
parent
e0cfc08ba3
commit
1703fff378
|
@ -1,12 +1,12 @@
|
|||
# Bryan Schumaker (11/12/2010)
|
||||
|
||||
import libsaria
|
||||
from libsaria import path
|
||||
from libsaria.collection import library
|
||||
import xm as xml
|
||||
|
||||
add_child = xml.add_child
|
||||
add_text = xml.add_text
|
||||
get_attrs = library.get_attrs
|
||||
get_attr = libsaria.collection.lib_get_attr
|
||||
lib_file = path.join(path.saria_dir(), "library.xml")
|
||||
|
||||
def encode_attr(doc, node, attr, value):
|
||||
|
@ -16,11 +16,15 @@ def encode_attr(doc, node, attr, value):
|
|||
|
||||
def encode_track(doc, node, id):
|
||||
child = add_child(doc, node, "track")
|
||||
(artist, album, title, filepath, score, count, genre, track, year, rate,
|
||||
channel, seconds, sample, lenstr) = get_attrs(
|
||||
id, "artist", "album", "title", "filepath", "score",
|
||||
"count", "genre", "track", "year", "rate", "channel",
|
||||
"seconds", "sample", "lenstr")
|
||||
|
||||
artist = get_attr(id, "artist")
|
||||
album = get_attr(id, "album")
|
||||
title = get_attr(id, "title")
|
||||
count = get_attr(id, "playcount")
|
||||
year = get_attr(id, "year")
|
||||
lenstr = get_attr(id, "lenstr")
|
||||
score = get_attr(id, "score")
|
||||
filepath = get_attr(id, "filepath")
|
||||
|
||||
encode_attr(doc, child, "id", id)
|
||||
encode_attr(doc, child, "artist", artist)
|
||||
|
@ -29,20 +33,14 @@ def encode_track(doc, node, id):
|
|||
encode_attr(doc, child, "filepath", filepath)
|
||||
encode_attr(doc, child, "score", score)
|
||||
encode_attr(doc, child, "count", count)
|
||||
encode_attr(doc, child, "genre", genre)
|
||||
encode_attr(doc, child, "track", track)
|
||||
encode_attr(doc, child, "year", year)
|
||||
encode_attr(doc, child, "rate", rate)
|
||||
encode_attr(doc, child, "channel", channel)
|
||||
encode_attr(doc, child, "seconds", seconds)
|
||||
encode_attr(doc, child, "sample", sample)
|
||||
encode_attr(doc, child, "lenstr", lenstr)
|
||||
|
||||
|
||||
def backup():
|
||||
doc = xml.new()
|
||||
child = add_child(doc, doc, "library")
|
||||
for id in library.walk():
|
||||
for id in libsaria.collection.lib_walk_ids():
|
||||
encode_track(doc, child, id)
|
||||
|
||||
fout = open(lib_file, 'w')
|
||||
|
|
|
@ -38,6 +38,11 @@ def walk_library():
|
|||
for track in library.walk_tags():
|
||||
yield track
|
||||
|
||||
def lib_walk_ids():
|
||||
global library
|
||||
for id in library.walk_ids():
|
||||
yield id
|
||||
|
||||
def lib_reset():
|
||||
global library
|
||||
library.reset()
|
||||
|
|
|
@ -44,6 +44,7 @@ class FilterBar(Bar):
|
|||
self.pack(entry.FilterEntry(), True, True)
|
||||
self.pack(button.OpenButton())
|
||||
self.pack(button.ClearButton())
|
||||
self.pack(button.ExportButton())
|
||||
self.pack(button.RandomButton())
|
||||
self.pack(button.VolumeButton())
|
||||
|
||||
|
|
Loading…
Reference in New Issue