ocarina/libsaria/sources/__init__.py

58 lines
1.0 KiB
Python

# Bryan Schumaker (8/8/2010)
__all__ = ["collection"]
import libsaria
import tagpy
call = libsaria.event.call
exists = libsaria.path.exists
expand = libsaria.path.expand
FileRef = tagpy.FileRef
prefs = None
import library
import playlist
file_to_id = library.file_to_id
play_id = library.play_id
get_attrs = library.get_attrs
reset = library.reset
inc_score = library.inc_score
inc_count = library.inc_count
cur_lib_id = -1
def new_source(path, bg=True):
global library
path = expand(path)
if not exists(path):
return 0
return call("NEWSOURCE", library.scan, path)
def lib_get_cur_id():
global cur_lib_id
return cur_lib_id
def plist_refresh():
return call("PLISTREFRESH")
def change_score():
prcnt = libsaria.audio.get_progress()
if prcnt > 0.75:
inc_count(cur_lib_id)
inc_score(cur_lib_id)
if prcnt < 0.33:
inc_score(cur_lib_id, -1)
def plist_next():
change_score()
playlist.next()
def catch_eos(*args):
inc_count(cur_lib_id)
inc_score(cur_lib_id)
playlist.next()
libsaria.event.invite("POSTEOS", catch_eos)