libsaria sources change
Change files to reflect the rename of libsaria.collection to libsaria.sources
This commit is contained in:
parent
caeb77e58c
commit
701306fef6
|
@ -1,6 +1,6 @@
|
||||||
# Bryan Schumaker (8/7/2010)
|
# Bryan Schumaker (8/7/2010)
|
||||||
|
|
||||||
__all__ = [ "collection", "audio",
|
__all__ = [ "audio", "sources",
|
||||||
"data", "event", "map", "path", "plugin"]
|
"data", "event", "map", "path", "plugin"]
|
||||||
|
|
||||||
__major__ = 1
|
__major__ = 1
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import libsaria
|
import libsaria
|
||||||
from libsaria import path
|
from libsaria import path
|
||||||
|
from libsaria.sources import library
|
||||||
import xm as xml
|
import xm as xml
|
||||||
|
|
||||||
add_child = xml.add_child
|
add_child = xml.add_child
|
||||||
|
|
|
@ -1,63 +0,0 @@
|
||||||
# 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
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
def init():
|
|
||||||
libsaria.init_pref("random", False)
|
|
||||||
libsaria.event.invite("POSTINIT", init)
|
|
||||||
|
|
||||||
def toggle_rand():
|
|
||||||
libsaria.prefs["random"] = not libsaria.prefs["random"]
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
|
|
|
@ -1,70 +0,0 @@
|
||||||
# Bryan Schumaker (8/10/2010)
|
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
translate = unicode.translate
|
|
||||||
split = unicode.split
|
|
||||||
space_ord = ord(" ")
|
|
||||||
stripc = u"\"#$%&'*+<=>@[]^`{|}~.?!"
|
|
||||||
splitc = u"-\/,:;()_~+"
|
|
||||||
|
|
||||||
ttable = None
|
|
||||||
|
|
||||||
def format_once(text):
|
|
||||||
import string
|
|
||||||
global ttable
|
|
||||||
upper = string.uppercase
|
|
||||||
lower = string.lowercase
|
|
||||||
|
|
||||||
ttable = dict((ord(c),None) for c in stripc)
|
|
||||||
splitt = dict((ord(c),space_ord) for c in splitc)
|
|
||||||
lowert = dict((ord(c),ord(lower[i])) for i,c in enumerate(upper))
|
|
||||||
for t in (splitt, lowert):
|
|
||||||
for c in t:
|
|
||||||
ttable[c] = t[c]
|
|
||||||
format = format_rest
|
|
||||||
return format_rest(text)
|
|
||||||
def format_rest(text):
|
|
||||||
return text.translate(ttable).split()
|
|
||||||
format = format_once
|
|
||||||
|
|
||||||
|
|
||||||
class Index(dict):
|
|
||||||
def __init__(self):
|
|
||||||
dict.__init__(self)
|
|
||||||
|
|
||||||
def insert(self, id, tags):
|
|
||||||
get = self.get
|
|
||||||
for tag in tags:
|
|
||||||
for word in format(tag):
|
|
||||||
ids = get(word, None)
|
|
||||||
if ids == None:
|
|
||||||
self[word] = set([id])
|
|
||||||
else:
|
|
||||||
ids.add(id)
|
|
||||||
|
|
||||||
def filter(self, text):
|
|
||||||
text = unicode(text)
|
|
||||||
terms = format(text)
|
|
||||||
results = dict()
|
|
||||||
|
|
||||||
search = re.search
|
|
||||||
get = self.get
|
|
||||||
|
|
||||||
for t in terms:
|
|
||||||
results[t] = set()
|
|
||||||
|
|
||||||
for key in self.keys():
|
|
||||||
for term in terms:
|
|
||||||
if search(term, key):
|
|
||||||
results[term].update(get(key))
|
|
||||||
|
|
||||||
visible = set()
|
|
||||||
for i,t in enumerate(terms):
|
|
||||||
if i == 0:
|
|
||||||
visible.update(results[t])
|
|
||||||
else:
|
|
||||||
visible.intersection_update(results[t])
|
|
||||||
return visible
|
|
||||||
|
|
||||||
|
|
|
@ -1,195 +0,0 @@
|
||||||
# Bryan Schumaker (11/05/2010)
|
|
||||||
|
|
||||||
import os
|
|
||||||
import tagpy
|
|
||||||
import libsaria
|
|
||||||
import string
|
|
||||||
from track import Track
|
|
||||||
splitext = libsaria.path.splitext
|
|
||||||
|
|
||||||
fs_tree = None
|
|
||||||
tag_tree = None
|
|
||||||
index = None
|
|
||||||
tracks = None
|
|
||||||
sources = None
|
|
||||||
size = None
|
|
||||||
visible = None
|
|
||||||
|
|
||||||
FileRef = tagpy.FileRef
|
|
||||||
|
|
||||||
filtered = False
|
|
||||||
badfiles = set()
|
|
||||||
|
|
||||||
ttable = dict()
|
|
||||||
for s in string.punctuation:
|
|
||||||
ttable[ord(s)] = u""
|
|
||||||
for s in string.lowercase:
|
|
||||||
ttable[ord(s)] = ord(s) - 32
|
|
||||||
|
|
||||||
def reset():
|
|
||||||
from libsaria.trees import FSTree, DLFSTree, DLValTree
|
|
||||||
from index import Index
|
|
||||||
|
|
||||||
global index
|
|
||||||
global tracks
|
|
||||||
global fs_tree
|
|
||||||
global tag_tree
|
|
||||||
global sources
|
|
||||||
global visible
|
|
||||||
|
|
||||||
sources = FSTree()
|
|
||||||
|
|
||||||
fs_tree = DLFSTree()
|
|
||||||
tag_tree = DLValTree()
|
|
||||||
index = Index()
|
|
||||||
tracks = dict()
|
|
||||||
size = 0
|
|
||||||
visible = set()
|
|
||||||
|
|
||||||
def load():
|
|
||||||
global fs_tree
|
|
||||||
global tag_tree
|
|
||||||
global index
|
|
||||||
global tracks
|
|
||||||
global sources
|
|
||||||
objects = libsaria.data.load("library", ".lib")
|
|
||||||
if objects == None or len(objects) != 5:
|
|
||||||
reset()
|
|
||||||
return
|
|
||||||
(sources, tracks, fs_tree, tag_tree, index) = objects
|
|
||||||
libsaria.event.start("POSTLIBLOAD")
|
|
||||||
|
|
||||||
def save():
|
|
||||||
global sources
|
|
||||||
libsaria.data.save( (sources, tracks, fs_tree, tag_tree, index),
|
|
||||||
"library", ".lib")
|
|
||||||
|
|
||||||
def walk():
|
|
||||||
for tag in tag_tree.walk():
|
|
||||||
yield tag[3]
|
|
||||||
|
|
||||||
def file_to_id(file):
|
|
||||||
return os.stat(file).st_ino
|
|
||||||
|
|
||||||
def get_attrs(id, *attrs):
|
|
||||||
res = []
|
|
||||||
rec = tracks.get(id, None)
|
|
||||||
if rec == None:
|
|
||||||
return [0] * len(attrs)
|
|
||||||
|
|
||||||
get = rec.__dict__.get
|
|
||||||
tags = rec.tags.walk_vals_backwards()
|
|
||||||
for attr in attrs:
|
|
||||||
if attr == "id":
|
|
||||||
res += [id]
|
|
||||||
elif attr == "filepath":
|
|
||||||
res += [rec.fs.walk_path_backwards()]
|
|
||||||
elif attr == "art":
|
|
||||||
from libsaria import lastfm
|
|
||||||
res += [lastfm.get_artwork_id(id)]
|
|
||||||
elif attr == "artist":
|
|
||||||
res += [tags[0]]
|
|
||||||
elif attr == "album":
|
|
||||||
res += [tags[1]]
|
|
||||||
elif attr == "title":
|
|
||||||
res += [tags[2]]
|
|
||||||
else:
|
|
||||||
res += [get(attr, None)]
|
|
||||||
return res
|
|
||||||
|
|
||||||
def inc_score(id, amount=1):
|
|
||||||
rec = tracks.get(id, None)
|
|
||||||
if rec:
|
|
||||||
rec.score += amount
|
|
||||||
save()
|
|
||||||
|
|
||||||
def inc_count(id):
|
|
||||||
rec = tracks.get(id, None)
|
|
||||||
if rec:
|
|
||||||
rec.count += 1
|
|
||||||
save()
|
|
||||||
|
|
||||||
def play_id(id):
|
|
||||||
libsaria.collection.cur_lib_id = id
|
|
||||||
libsaria.audio.load(get_attrs(id, "filepath")[0])
|
|
||||||
libsaria.audio.play()
|
|
||||||
|
|
||||||
def filter(text):
|
|
||||||
global visible
|
|
||||||
global index
|
|
||||||
global filtered
|
|
||||||
|
|
||||||
if len(text) > 0:
|
|
||||||
visible = index.filter(text)
|
|
||||||
filtered = True
|
|
||||||
else:
|
|
||||||
visible = None
|
|
||||||
filtered = False
|
|
||||||
|
|
||||||
def test_filter(text):
|
|
||||||
return index.filter(text)
|
|
||||||
|
|
||||||
def is_visible(id):
|
|
||||||
global filtered
|
|
||||||
global visible
|
|
||||||
if filtered == False:
|
|
||||||
return True
|
|
||||||
else:
|
|
||||||
return id in visible
|
|
||||||
|
|
||||||
def add_source(path):
|
|
||||||
global sources
|
|
||||||
sources.insert_path(path)
|
|
||||||
|
|
||||||
def scan(path):
|
|
||||||
add_source(path)
|
|
||||||
update()
|
|
||||||
save()
|
|
||||||
|
|
||||||
def insert_track(path, ref):
|
|
||||||
global tracks
|
|
||||||
global ttable
|
|
||||||
global fs_tree
|
|
||||||
global tag_tree
|
|
||||||
global index
|
|
||||||
tags = ref.tag()
|
|
||||||
audio = ref.audioProperties()
|
|
||||||
ino = os.stat(path).st_ino
|
|
||||||
track = Track(tags, audio)
|
|
||||||
artist = tags.artist or u"Unknown Artist"
|
|
||||||
album = tags.album or u"Unknown Album"
|
|
||||||
title = tags.title or u"Unknown Title"
|
|
||||||
fs = fs_tree.insert_path(path)
|
|
||||||
tag = tag_tree.insert( [artist.translate(ttable),
|
|
||||||
album.translate(ttable),
|
|
||||||
title.translate(ttable), ino],
|
|
||||||
[artist, album, title, ino]
|
|
||||||
)
|
|
||||||
|
|
||||||
index.insert(ino, (artist, album, title))
|
|
||||||
track.fs = fs
|
|
||||||
track.tags = tag
|
|
||||||
tracks[ino] = track
|
|
||||||
|
|
||||||
def update_path(path):
|
|
||||||
global badfiles
|
|
||||||
tree = libsaria.path.make_tree(path)
|
|
||||||
for path in tree.walk_paths():
|
|
||||||
ext = splitext(path)[1]
|
|
||||||
if ext in badfiles:
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
ref = FileRef(path)
|
|
||||||
except:
|
|
||||||
badfiles.add(ext)
|
|
||||||
continue
|
|
||||||
try:
|
|
||||||
insert_track(path, ref)
|
|
||||||
except Exception, e:
|
|
||||||
print e
|
|
||||||
|
|
||||||
def update():
|
|
||||||
global sources
|
|
||||||
sep = libsaria.path.sep
|
|
||||||
for path in sources.walk_paths():
|
|
||||||
update_path(path)
|
|
|
@ -1,115 +0,0 @@
|
||||||
# Bryan Schumaker (11/07/2010)
|
|
||||||
|
|
||||||
import random as rand
|
|
||||||
|
|
||||||
import libsaria
|
|
||||||
from libsaria.collection import library
|
|
||||||
call = libsaria.event.call
|
|
||||||
|
|
||||||
song_list = None
|
|
||||||
song_set = None
|
|
||||||
|
|
||||||
filtered = False
|
|
||||||
visible = None
|
|
||||||
recent = []
|
|
||||||
recent_msg = "Skipping %s by %s because it has played recently"
|
|
||||||
skip_msg = "Skipping %s by %s because I don't think you like it"
|
|
||||||
cur_index = -1
|
|
||||||
|
|
||||||
def add_id(id):
|
|
||||||
global song_list
|
|
||||||
global song_set
|
|
||||||
song_list.append(id)
|
|
||||||
song_set.add(id)
|
|
||||||
|
|
||||||
def reset():
|
|
||||||
global song_list
|
|
||||||
global song_set
|
|
||||||
song_list = []
|
|
||||||
song_set = set()
|
|
||||||
|
|
||||||
def load():
|
|
||||||
global song_list
|
|
||||||
global song_set
|
|
||||||
global visible
|
|
||||||
song_list = libsaria.data.load("playlist", ".list")
|
|
||||||
if song_list == None:
|
|
||||||
reset()
|
|
||||||
return
|
|
||||||
song_set = set(song_list)
|
|
||||||
|
|
||||||
def save():
|
|
||||||
libsaria.data.save(song_list, "playlist", ".list")
|
|
||||||
|
|
||||||
def walk():
|
|
||||||
global song_list
|
|
||||||
for id in song_list:
|
|
||||||
yield id
|
|
||||||
|
|
||||||
def filter(text):
|
|
||||||
global visible
|
|
||||||
global song_set
|
|
||||||
global filtered
|
|
||||||
if len(text) > 0:
|
|
||||||
visible = song_set.intersection(library.test_filter(text))
|
|
||||||
filtered = True
|
|
||||||
else:
|
|
||||||
visible = song_set
|
|
||||||
filtered = False
|
|
||||||
|
|
||||||
def is_visible(id):
|
|
||||||
global visible
|
|
||||||
global filtered
|
|
||||||
if filtered == True:
|
|
||||||
return id in visible
|
|
||||||
return True
|
|
||||||
|
|
||||||
def num_visible():
|
|
||||||
if filtered == True:
|
|
||||||
return len(visible)
|
|
||||||
return len(song_list)
|
|
||||||
|
|
||||||
def seq_next():
|
|
||||||
global cur_index
|
|
||||||
global song_list
|
|
||||||
cur_index += 1
|
|
||||||
while is_visible(song_list[cur_index]) == False:
|
|
||||||
cur_index += 1
|
|
||||||
return song_list[cur_index]
|
|
||||||
|
|
||||||
def rand_candidate(max):
|
|
||||||
index = rand.randint(0, max-1)
|
|
||||||
if filtered == False:
|
|
||||||
return song_list[index]
|
|
||||||
return list(visible)[index]
|
|
||||||
|
|
||||||
def rand_next():
|
|
||||||
n = num_visible()
|
|
||||||
if n == 0:
|
|
||||||
return
|
|
||||||
get_attrs = library.get_attrs
|
|
||||||
for i in xrange(15):
|
|
||||||
id = rand_candidate(n)
|
|
||||||
(artist, title, score) = get_attrs(id, "artist", "title", "score")
|
|
||||||
if (artist, title) in recent:
|
|
||||||
print recent_msg % (artist, title)
|
|
||||||
continue
|
|
||||||
if score < 0:
|
|
||||||
do_play = rand.randint(0, 100)
|
|
||||||
if do_play < ((20 * score) + 100):
|
|
||||||
print skip_msg % (artist, title)
|
|
||||||
continue
|
|
||||||
recent.append((artist, title))
|
|
||||||
if len(recent) > 50:
|
|
||||||
recent.pop(0)
|
|
||||||
if i > 0:
|
|
||||||
print "Picking a song took %s iterations" % i
|
|
||||||
return id
|
|
||||||
|
|
||||||
def next():
|
|
||||||
if libsaria.prefs["random"] == True:
|
|
||||||
id = rand_next()
|
|
||||||
else:
|
|
||||||
id = seq_next()
|
|
||||||
if id != None:
|
|
||||||
return call("NEXT", library.play_id, id)
|
|
|
@ -1,13 +0,0 @@
|
||||||
# Bryan Schumaker (8/8/2010)
|
|
||||||
|
|
||||||
class Table(dict):
|
|
||||||
def __init__(self):
|
|
||||||
dict.__init__(self)
|
|
||||||
self.next_id = 0
|
|
||||||
|
|
||||||
|
|
||||||
def insert(self, tags):
|
|
||||||
id = self.next_id
|
|
||||||
self[id] = tags
|
|
||||||
self.next_id += 1
|
|
||||||
return id
|
|
|
@ -1,24 +0,0 @@
|
||||||
# Bryan Schumaker (11/09/2010)
|
|
||||||
|
|
||||||
import datetime
|
|
||||||
timedelta = datetime.timedelta
|
|
||||||
|
|
||||||
class Track:
|
|
||||||
def __init__(self, tags, audio):
|
|
||||||
self.score = 0
|
|
||||||
self.count = 0
|
|
||||||
self.genre = tags.genre or u"Unknown Genre"
|
|
||||||
self.track = tags.track
|
|
||||||
self.year = tags.year
|
|
||||||
self.rate = audio.bitrate
|
|
||||||
self.channel = audio.channels
|
|
||||||
self.seconds = audio.length
|
|
||||||
self.sample = audio.sampleRate
|
|
||||||
lenstr = "%s" % timedelta(seconds=self.seconds)
|
|
||||||
if lenstr[0] == "0" and lenstr[1] == ":":
|
|
||||||
self.lenstr = lenstr[2:]
|
|
||||||
else:
|
|
||||||
self.lenstr = lenstr
|
|
||||||
|
|
||||||
self.fs = None
|
|
||||||
self.tags = None
|
|
|
@ -44,7 +44,7 @@ def universal_open(file):
|
||||||
file = file.replace("%20", " ")
|
file = file.replace("%20", " ")
|
||||||
file = file.replace("%22", "\"")
|
file = file.replace("%22", "\"")
|
||||||
if path.is_dir(file):
|
if path.is_dir(file):
|
||||||
libsaria.collection.new_source(file)
|
libsaria.sources.new_source(file)
|
||||||
return
|
return
|
||||||
split = path.splitext(file)
|
split = path.splitext(file)
|
||||||
ext = split[1]
|
ext = split[1]
|
||||||
|
@ -55,9 +55,9 @@ def universal_open(file):
|
||||||
plugin.install(file)
|
plugin.install(file)
|
||||||
return
|
return
|
||||||
try:
|
try:
|
||||||
id = libsaria.collection.file_to_id(file)
|
id = libsaria.sources.file_to_id(file)
|
||||||
if id:
|
if id:
|
||||||
libsaria.collection.play_id(id)
|
libsaria.sources.play_id(id)
|
||||||
else:
|
else:
|
||||||
libsaria.audio.load(file)
|
libsaria.audio.load(file)
|
||||||
except Exception,e:
|
except Exception,e:
|
||||||
|
|
|
@ -4,7 +4,7 @@ import libsaria
|
||||||
import web
|
import web
|
||||||
import xm
|
import xm
|
||||||
|
|
||||||
file_to_id = libsaria.collection.file_to_id
|
file_to_id = libsaria.sources.file_to_id
|
||||||
cache = libsaria.cache
|
cache = libsaria.cache
|
||||||
pref_attr = xm.find_preferred_attribute
|
pref_attr = xm.find_preferred_attribute
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ def lfm_cache_album(file, artist, album):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_artwork_id(id):
|
def get_artwork_id(id):
|
||||||
artist, album = libsaria.collection.get_attrs(id, "artist", "album")
|
artist, album = libsaria.sources.get_attrs(id, "artist", "album")
|
||||||
cached = cache[artist]
|
cached = cache[artist]
|
||||||
file = cached.get("%s.jpg" % album, lfm_cache_album, artist, album)
|
file = cached.get("%s.jpg" % album, lfm_cache_album, artist, album)
|
||||||
return file
|
return file
|
||||||
|
|
|
@ -72,7 +72,7 @@ class NextButton(Button):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Button.__init__(self, gtk.STOCK_MEDIA_NEXT)
|
Button.__init__(self, gtk.STOCK_MEDIA_NEXT)
|
||||||
def clicked(self, button):
|
def clicked(self, button):
|
||||||
LS.collection.plist_next()
|
LS.sources.plist_next()
|
||||||
|
|
||||||
|
|
||||||
class ForwardButton(Button):
|
class ForwardButton(Button):
|
||||||
|
@ -121,7 +121,7 @@ class RandomButton(gtk.ToggleButton):
|
||||||
self.show()
|
self.show()
|
||||||
|
|
||||||
def toggle(self, button):
|
def toggle(self, button):
|
||||||
LS.collection.toggle_rand()
|
LS.sources.toggle_rand()
|
||||||
|
|
||||||
|
|
||||||
class UpButton(Button):
|
class UpButton(Button):
|
||||||
|
|
|
@ -5,9 +5,9 @@ import list
|
||||||
import menu
|
import menu
|
||||||
|
|
||||||
libsaria = ocarina.libsaria
|
libsaria = ocarina.libsaria
|
||||||
from libsaria import collection
|
from libsaria import sources
|
||||||
library = collection.library
|
library = sources.library
|
||||||
playlist = collection.playlist
|
playlist = sources.playlist
|
||||||
|
|
||||||
event = ocarina.libsaria.event
|
event = ocarina.libsaria.event
|
||||||
gtk = ocarina.gtk
|
gtk = ocarina.gtk
|
||||||
|
@ -46,7 +46,7 @@ class Collection(gtk.ScrolledWindow):
|
||||||
def add_selected_to_playlist(self, *args):
|
def add_selected_to_playlist(self, *args):
|
||||||
self.list.for_each_selected(playlist.add_id)
|
self.list.for_each_selected(playlist.add_id)
|
||||||
playlist.save()
|
playlist.save()
|
||||||
collection.plist_refresh()
|
sources.plist_refresh()
|
||||||
|
|
||||||
|
|
||||||
class Library(Collection):
|
class Library(Collection):
|
||||||
|
@ -76,13 +76,13 @@ class Library(Collection):
|
||||||
#self.populate()
|
#self.populate()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
collection.reset()
|
sources.reset()
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
def select_row(self, row):
|
def select_row(self, row):
|
||||||
collection.change_score()
|
sources.change_score()
|
||||||
collection.play_id(row[0])
|
sources.play_id(row[0])
|
||||||
collection.inc_score(row[0], 1)
|
sources.inc_score(row[0], 1)
|
||||||
|
|
||||||
def filter(self, text):
|
def filter(self, text):
|
||||||
library.filter(text)
|
library.filter(text)
|
||||||
|
@ -122,9 +122,9 @@ class Playlist(Collection):
|
||||||
#print "Populating took: %s" % (after - before)
|
#print "Populating took: %s" % (after - before)
|
||||||
|
|
||||||
def select_row(self, row):
|
def select_row(self, row):
|
||||||
collection.change_score()
|
sources.change_score()
|
||||||
collection.play_id(row[0])
|
sources.play_id(row[0])
|
||||||
collection.inc_score(row[0], 1)
|
sources.inc_score(row[0], 1)
|
||||||
|
|
||||||
def filter(self, text):
|
def filter(self, text):
|
||||||
playlist.filter(text)
|
playlist.filter(text)
|
||||||
|
|
|
@ -10,9 +10,9 @@ pbar = None
|
||||||
label = None
|
label = None
|
||||||
image = None
|
image = None
|
||||||
|
|
||||||
lib_get_cur_id = libsaria.collection.lib_get_cur_id
|
lib_get_cur_id = libsaria.sources.lib_get_cur_id
|
||||||
get_attrs = libsaria.collection.get_attrs
|
get_attrs = libsaria.sources.get_attrs
|
||||||
file_to_id = libsaria.collection.file_to_id
|
file_to_id = libsaria.sources.file_to_id
|
||||||
|
|
||||||
filter = None
|
filter = None
|
||||||
info = None
|
info = None
|
||||||
|
|
|
@ -18,8 +18,8 @@ def set_fns():
|
||||||
global file_to_id
|
global file_to_id
|
||||||
#update = ocarina.libsaria.audio.get_progress
|
#update = ocarina.libsaria.audio.get_progress
|
||||||
get_time = ocarina.libsaria.audio.get_time
|
get_time = ocarina.libsaria.audio.get_time
|
||||||
get_attrs = libsaria.collection.get_attrs
|
get_attrs = libsaria.sources.get_attrs
|
||||||
file_to_id = libsaria.collection.file_to_id
|
file_to_id = libsaria.sources.file_to_id
|
||||||
invite("POSTSTART", set_fns)
|
invite("POSTSTART", set_fns)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ libsaria = ocarina.libsaria
|
||||||
gtk = ocarina.gtk
|
gtk = ocarina.gtk
|
||||||
gobject = ocarina.gobject
|
gobject = ocarina.gobject
|
||||||
|
|
||||||
from libsaria.collection import library
|
from libsaria.sources import library
|
||||||
get_attrs = library.get_attrs
|
get_attrs = library.get_attrs
|
||||||
|
|
||||||
#UNI = gobject.TYPE_UNICHAR
|
#UNI = gobject.TYPE_UNICHAR
|
||||||
|
|
|
@ -9,7 +9,7 @@ server = None
|
||||||
def play_id(arg):
|
def play_id(arg):
|
||||||
id = int(arg[0])
|
id = int(arg[0])
|
||||||
print "Trying to play id: %s" % id
|
print "Trying to play id: %s" % id
|
||||||
libsaria.collection.library.play_id(id)
|
libsaria.sources.library.play_id(id)
|
||||||
|
|
||||||
def play(*args):
|
def play(*args):
|
||||||
libsaria.audio.play()
|
libsaria.audio.play()
|
||||||
|
@ -21,8 +21,8 @@ def stop(*args):
|
||||||
libsaria.audio.stop()
|
libsaria.audio.stop()
|
||||||
|
|
||||||
def next(*args):
|
def next(*args):
|
||||||
print libsaria.collection
|
print libsaria.sources
|
||||||
libsaria.collection.plist_next()
|
libsaria.sources.plist_next()
|
||||||
|
|
||||||
procs = {"play_id":play_id, "play":play, "pause":pause, "stop":stop, "next":next}
|
procs = {"play_id":play_id, "play":play, "pause":pause, "stop":stop, "next":next}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
import ocarina
|
import ocarina
|
||||||
gdk = ocarina.gdk
|
gdk = ocarina.gdk
|
||||||
libsaria = ocarina.libsaria
|
libsaria = ocarina.libsaria
|
||||||
file_to_id = libsaria.collection.file_to_id
|
file_to_id = libsaria.sources.file_to_id
|
||||||
get_attrs = libsaria.collection.get_attrs
|
get_attrs = libsaria.sources.get_attrs
|
||||||
invite = libsaria.event.invite
|
invite = libsaria.event.invite
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,8 @@ win = None
|
||||||
|
|
||||||
def send(text):
|
def send(text):
|
||||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
s.connect( ("localhost", 4242) )
|
#s.connect( ("localhost", 4242) )
|
||||||
|
s.connect( ("192.168.1.100", 4242) )
|
||||||
total_sent = 0
|
total_sent = 0
|
||||||
length = len(text)
|
length = len(text)
|
||||||
while total_sent < length:
|
while total_sent < length:
|
||||||
|
|
|
@ -16,7 +16,7 @@ def set_state_paused():
|
||||||
from remote import procs
|
from remote import procs
|
||||||
|
|
||||||
class Button(gtk.Button):
|
class Button(gtk.Button):
|
||||||
def __init__(self, stock, size=gtk.ICON_SIZE_DIALOG, func=None, show=True):
|
def __init__(self, stock, size=gtk.ICON_SIZE_LARGE_TOOLBAR, func=None, show=True):
|
||||||
gtk.Button.__init__(self)
|
gtk.Button.__init__(self)
|
||||||
self.func = func
|
self.func = func
|
||||||
img = gtk.image_new_from_stock(stock, size)
|
img = gtk.image_new_from_stock(stock, size)
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
|
|
||||||
import libsaria
|
import libsaria
|
||||||
from libsaria import data
|
from libsaria import data
|
||||||
from libsaria import collection
|
from libsaria import sources
|
||||||
from libsaria import backup
|
from libsaria import backup
|
||||||
library = libsaria.collection.library
|
library = libsaria.sources.library
|
||||||
|
|
||||||
library.load()
|
library.load()
|
||||||
backup.backup()
|
backup.backup()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Bryan Schumaker (8/8/2010)
|
# Bryan Schumaker (8/8/2010)
|
||||||
|
|
||||||
from libsaria import collection
|
from libsaria import sources
|
||||||
|
|
||||||
#src = "~/Music"
|
#src = "~/Music"
|
||||||
#src = "~/Music/Foo Fighters"
|
#src = "~/Music/Foo Fighters"
|
||||||
|
@ -8,5 +8,5 @@ from libsaria import collection
|
||||||
|
|
||||||
src = "/media/Music"
|
src = "/media/Music"
|
||||||
|
|
||||||
collection.new_source(src, bg=False)
|
sources.new_source(src, bg=False)
|
||||||
#print collection.source.index
|
#print collection.source.index
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
# Bryan Schumaker (10/1/2010)
|
# Bryan Schumaker (10/1/2010)
|
||||||
|
|
||||||
|
|
||||||
from libsaria import collection
|
from libsaria import sources
|
||||||
|
|
||||||
|
|
||||||
#collection.new_source("~/Desktop")
|
#sources.new_source("~/Desktop")
|
||||||
collection.new_source("~/Music/")
|
sources.new_source("~/Music/")
|
||||||
#collection.new_source("/media/Music")
|
#sources.new_source("/media/Music")
|
||||||
print collection.library.size
|
print sources.library.size
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
# Bryan Schumaker (8/17/2010)
|
# Bryan Schumaker (8/17/2010)
|
||||||
|
|
||||||
from libsaria import collection
|
from libsaria import sources
|
||||||
|
|
||||||
count = 0
|
count = 0
|
||||||
list = []
|
list = []
|
||||||
append = list.append
|
append = list.append
|
||||||
|
|
||||||
for track in collection.walk_library():
|
for track in sources.walk_library():
|
||||||
get = track.__getitem__
|
get = track.__getitem__
|
||||||
append([get("id"), get("title"), get("length"),
|
append([get("id"), get("title"), get("length"),
|
||||||
get("artist"),
|
get("artist"),
|
||||||
|
|
Loading…
Reference in New Issue