ocarina/libsaria/sources/__init__.py
Bryan Schumaker 3eeb35d81c Stop using file_to_id
We should now use file_id located in libsaria.path
2010-12-05 13:40:39 -05:00

59 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
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 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 play_selected_id(id):
change_score()
play_id(id)
inc_score(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)