diff --git a/libsaria/collection/__init__.py b/libsaria/collection/__init__.py
index c7d3ca02..46e662b3 100644
--- a/libsaria/collection/__init__.py
+++ b/libsaria/collection/__init__.py
@@ -19,7 +19,7 @@ import playlist
file_to_id = library.file_to_id
play_id = library.play_id
-get_attr = library.get_attr
+get_attrs = library.get_attrs
reset = library.reset
inc_score = library.inc_score
inc_count = library.inc_count
diff --git a/libsaria/collection/lens.py b/libsaria/collection/lens.py
index cbc1eb4a..fdef4739 100644
--- a/libsaria/collection/lens.py
+++ b/libsaria/collection/lens.py
@@ -86,17 +86,17 @@ class Playlist(collection.Collection):
def random(self):
if self.size == 0:
return
- getattr = libsaria.collection.get_attr
+ getattr = libsaria.collection.get_attrs
last = self.last_tracks
for i in xrange(15):
id = self.get_rand_candidate()
- artist = getattr(id, "artist")
- album = getattr(id, "album")
- title = getattr(id, "title")
+ artist = getattr(id, "artist")[0]
+ album = getattr(id, "album")[0]
+ title = getattr(id, "title")[0]
if (artist, title) in last:
print "Skipping %s by %s because it has played recently." % (title, artist)
continue
- score = getattr(id, "score")
+ score = getattr(id, "score")[0]
if score < 0:
play_anyway = rand.randint(0, 100)
if play_anyway < ((20 * score) + 100):
diff --git a/libsaria/collection/library.py b/libsaria/collection/library.py
index 4aa1dff2..12cb09b5 100644
--- a/libsaria/collection/library.py
+++ b/libsaria/collection/library.py
@@ -108,8 +108,7 @@ def inc_count(id):
def play_id(id):
libsaria.collection.cur_lib_id = id
- filepath = get_attr(id, "filepath")
- libsaria.audio.load(filepath)
+ libsaria.audio.load(get_attrs(id, "filepath")[0])
libsaria.audio.play()
def filter(text):
diff --git a/libsaria/lastfm.py b/libsaria/lastfm.py
index 4da4bc12..7a19bf77 100644
--- a/libsaria/lastfm.py
+++ b/libsaria/lastfm.py
@@ -62,8 +62,7 @@ def lfm_cache_album(file, artist, album):
return False
def get_artwork_id(id):
- artist = libsaria.collection.get_attr(id, "artist")
- album = libsaria.collection.get_attr(id, "album")
+ artist, album = libsaria.collection.get_attrs(id, "artist", "album")
cached = cache[artist]
file = cached.get("%s.jpg" % album, lfm_cache_album, artist, album)
return file
diff --git a/ocarina/collection.py b/ocarina/collection.py
index 9f02b777..11613b8f 100644
--- a/ocarina/collection.py
+++ b/ocarina/collection.py
@@ -45,16 +45,11 @@ class Collection(gtk.ScrolledWindow):
def populate2(self, func):
self.list.freeze()
- insert = self.list.list.insert
- getattr = library.get_attr
- ins_next = 0
+ insert = self.list.list.insert
+ get_attrs = library.get_attrs
+ ins_next = 0
for id in func():
- title = getattr(id, "title")
- length = getattr(id, "lenstr")
- artist = getattr(id, "artist")
- album = getattr(id, "album")
- year = getattr(id, "year")
- insert(ins_next, [id, title, length, artist, album, year])
+ insert(ins_next, get_attrs(id, "id", "title", "lenstr", "artist", "album", "year"))
ins_next += 1
self.list.thaw()
diff --git a/ocarina/info.py b/ocarina/info.py
index 6cab2c1d..e9e0ecd1 100644
--- a/ocarina/info.py
+++ b/ocarina/info.py
@@ -11,7 +11,7 @@ label = None
image = None
lib_get_cur_id = libsaria.collection.lib_get_cur_id
-get_attr = libsaria.collection.get_attr
+get_attrs = libsaria.collection.get_attrs
file_to_id = libsaria.collection.file_to_id
filter = None
@@ -74,9 +74,8 @@ class InfoBar(Bar):
def change_title(self, filepath):
id = file_to_id(filepath)
- title = get_attr(id, "title")
- artist = get_attr(id, "artist")
- self.title.set_text("%s by %s" % (title,artist))
+ title, artist = get_attrs(id, "title", "artist")
+ self.title.set_text("%s by %s" % (title, artist))
class InfoTab(gtk.Notebook):
diff --git a/ocarina/label.py b/ocarina/label.py
index 1dc13593..2256293c 100644
--- a/ocarina/label.py
+++ b/ocarina/label.py
@@ -8,17 +8,17 @@ libsaria = ocarina.libsaria
#update = None
get_time = None
-get_attr = None
+get_attrs = None
file_to_id = None
def set_fns():
#global update
global get_time
- global get_attr
+ global get_attrs
global file_to_id
#update = ocarina.libsaria.audio.get_progress
get_time = ocarina.libsaria.audio.get_time
- get_attr = libsaria.collection.get_attr
+ get_attrs = libsaria.collection.get_attrs
file_to_id = libsaria.collection.file_to_id
invite("POSTSTART", set_fns)
@@ -45,10 +45,10 @@ class AttrLabel(gtk.Alignment):
invite("POSTLOAD", self.update)
def update(self, filepath):
- global get_attr
+ global get_attrs
id = file_to_id(filepath)
if id != None:
- text = str(get_attr(id, self.attr))
+ text = str(get_attrs(id, self.attr)[0])
if self.other:
text = "%s %s" % (self.other, text)
self.label.set_text(text)
@@ -73,7 +73,7 @@ class YearLabel(AttrLabel):
class CountLabel(AttrLabel):
def __init__(self):
- AttrLabel.__init__(self, "playcount", "Play count:")
+ AttrLabel.__init__(self, "count", "Play count:")
class LengthLabel(AttrLabel):
def __init__(self):
diff --git a/ocarina/list.py b/ocarina/list.py
index 9de4467f..61fbf9f8 100644
--- a/ocarina/list.py
+++ b/ocarina/list.py
@@ -7,7 +7,7 @@ gtk = ocarina.gtk
gobject = ocarina.gobject
from libsaria.collection import library
-get_attr = library.get_attr
+get_attrs = library.get_attrs
#UNI = gobject.TYPE_UNICHAR
@@ -82,24 +82,25 @@ class List(gtk.TreeView):
row = self.get_dest_row_at_pos(x,y)
if row == None:
return False
- iter = self.filter_model.get_iter(row[0])#self.list.get_iter(row[0])
+ iter = self.filter_model.get_iter(row[0])
id = self.filter_model[iter][0]
+ attrs = get_attrs(id, "art", "title", "artist", "album", "year", "lenstr", "count")
+
art = image.Image()
- art.set_from_file(get_attr(id, "art"))
+ art.set_from_file(attrs[0])
art.set_height(52)
tip.set_icon(art.get_pixbuf())
- title = get_attr(id, "title").replace("&", "&")
- artist = "by %s" % get_attr(id, "artist").replace("&", "&")
- album = "from %s" % get_attr(id, "album").replace("&", "&")
- tip.set_markup("%s\n%s\n%s" % (title, artist, album))
+ tip.set_markup("%s\nby %s\nfrom %s" %
+ (attrs[1].replace("&", "&"),
+ attrs[2].replace("&", "&"),
+ attrs[3].replace("&", "&"))
+ )
- year = "Year: %s" % get_attr(id, "year")
- length = "Length: %s" % get_attr(id, "lenstr")
- count = "Play count: %s" % get_attr(id, "playcount")
extra = gtk.Label()
- extra.set_markup(" %s\n %s\n %s" % (year, length, count))
+ extra.set_markup(" Year: %s\n Length: %s\n Play count: %s" %
+ (attrs[4], attrs[5], attrs[6]) )
tip.set_custom(extra)
return True
diff --git a/plugins/wm_tweaks.py b/plugins/wm_tweaks.py
index c5f21775..7691236f 100644
--- a/plugins/wm_tweaks.py
+++ b/plugins/wm_tweaks.py
@@ -4,7 +4,7 @@ import ocarina
gdk = ocarina.gdk
libsaria = ocarina.libsaria
file_to_id = libsaria.collection.file_to_id
-get_attr = libsaria.collection.get_attr
+get_attrs = libsaria.collection.get_attrs
invite = libsaria.event.invite
@@ -18,7 +18,7 @@ def tweak_icon(file):
def tweak_title(filepath):
if filepath != None:
id = file_to_id(filepath)
- title = get_attr(id, "title")
+ title = get_attrs(id, "title")[0]
else:
title = ocarina.__vers__
ocarina.set_window_title(title)