The file source is used to play and get attributes for files on disk that the user wants us to play.
65 lines
1.1 KiB
Python
65 lines
1.1 KiB
Python
# Bryan Schumaker (12/7/2010)
|
|
|
|
import libsaria
|
|
path = libsaria.path
|
|
tagpy = None
|
|
|
|
source = None
|
|
cur_file = None
|
|
file_ref = None
|
|
tags = None
|
|
|
|
def init():
|
|
global source
|
|
global tagpy
|
|
|
|
import tagpy
|
|
|
|
source = libsaria.sources.Source()
|
|
source.get_attrs = get_attrs
|
|
source.get_cur_id = get_cur_file
|
|
|
|
load_file = source.load_file
|
|
print load_file
|
|
|
|
def load_file(file):
|
|
global file_ref
|
|
global tags
|
|
global cur_file
|
|
file_ref = tagpy.FileRef(file)
|
|
tags = file_ref.tag()
|
|
cur_file = file
|
|
source.load_file(file)
|
|
|
|
def get_cur_file():
|
|
return cur_file
|
|
|
|
def get_attrs(file, *attrs):
|
|
print "Getting attributes for: %s" % file
|
|
#print " Requested attributes: %s" % attrs
|
|
|
|
res = []
|
|
id = libsaria.path.file_id(file)
|
|
for attr in attrs:
|
|
if attr == "id":
|
|
res += [id]
|
|
elif attr == "filepath":
|
|
res += [file]
|
|
elif attr == "art":
|
|
from libsaria import lastfm
|
|
res += [id]
|
|
elif attr == "artist":
|
|
res += [tags.artist]
|
|
elif attr == "album":
|
|
res += [tags.album]
|
|
elif attr == "title":
|
|
res += [tags.title]
|
|
else:
|
|
return "???"
|
|
if len(res) == 1:
|
|
return res[0]
|
|
return res
|
|
|
|
|
|
init()
|