libsaria: Add in play count dattr

I want to track how often songs are played.  This patch gives me the
ability to do that.
This commit is contained in:
Bryan Schumaker 2011-05-28 16:13:02 -04:00
parent 49f7829706
commit 0a644752a4
2 changed files with 6 additions and 2 deletions

View File

@ -14,8 +14,7 @@ attrs.load_dattrs()
cur_id = None
def inc_count():
# This will eventually increment a play count...
pass
attrs.inc_count(get_attrs("id")[0])
def find_attrs(file, *attrs):
if file == None:
@ -31,6 +30,8 @@ def find_attrs(file, *attrs):
res.append(id)
elif attr == "like":
res.append(attrs.get_dattr(id, "like"))
elif attr == "count":
res.append(attrs.get_count(id))
else:
res.append(get(attr))
return res

View File

@ -8,6 +8,7 @@ library_lock = threading.Lock()
lock_library = library_lock.acquire
unlock_library = library_lock.release
get_dattr = attrs.get_dattr
get_count = attrs.get_count
# Map directory -> dict()
lib_dict = None
@ -66,6 +67,8 @@ def get_attrs(id, *attrs):
res.append(id)
elif attr == "like":
res.append(get_dattr(id, attr))
elif attr == "count":
res.append(get_count(id))
else:
res.append(get(attr))
unlock_library()