New playlist module
The playlist should be a standalone module rather than inheriting from the same base class as the library.
This commit is contained in:
parent
9e89283b19
commit
73de67f386
|
@ -15,7 +15,8 @@ QUEUE = 2
|
||||||
|
|
||||||
import lens
|
import lens
|
||||||
import library
|
import library
|
||||||
playlist = lens.Playlist()
|
import playlist
|
||||||
|
#playlist = lens.Playlist()
|
||||||
|
|
||||||
file_to_id = library.file_to_id
|
file_to_id = library.file_to_id
|
||||||
play_id = library.play_id
|
play_id = library.play_id
|
||||||
|
@ -44,41 +45,15 @@ def lib_get_cur_id():
|
||||||
global cur_lib_id
|
global cur_lib_id
|
||||||
return cur_lib_id
|
return cur_lib_id
|
||||||
|
|
||||||
def walk_plist():
|
|
||||||
global playlist
|
|
||||||
global library
|
|
||||||
get_attr = library.get_attr
|
|
||||||
for id in playlist.walk_ids():
|
|
||||||
yield [get_attr(id, "artist"), get_attr(id, "album"),
|
|
||||||
get_attr(id, "title"), id, get_attr(id, "year"),
|
|
||||||
get_attr(id, "lenstr")]
|
|
||||||
|
|
||||||
def plist_save():
|
|
||||||
global playlist
|
|
||||||
playlist.save()
|
|
||||||
|
|
||||||
def plist_add_libid(lib_id):
|
|
||||||
global playlist
|
|
||||||
# Hey, Future Bryan. I really want to use a lib_get_attrs() function
|
|
||||||
# to return a list of attributes. Can you do that for me, please?
|
|
||||||
# Thank you, Past Bryan
|
|
||||||
artist = library.get_attr(lib_id, "artist")
|
|
||||||
album = library.get_attr(lib_id, "album")
|
|
||||||
title = library.get_attr(lib_id, "title")
|
|
||||||
playlist.insert_tags(artist, album, title, lib_id)
|
|
||||||
|
|
||||||
def plist_is_visible(id):
|
def plist_is_visible(id):
|
||||||
global playlist
|
return True
|
||||||
return playlist.is_visible(id)
|
#global playlist
|
||||||
|
#return playlist.is_visible(id)
|
||||||
|
|
||||||
def plist_filter(text):
|
def plist_filter(text):
|
||||||
global playlist
|
return True
|
||||||
return playlist.filter(text)
|
#global playlist
|
||||||
|
#return playlist.filter(text)
|
||||||
def plist_reset():
|
|
||||||
global playlist
|
|
||||||
playlist.reset()
|
|
||||||
playlist.save()
|
|
||||||
|
|
||||||
def plist_refresh():
|
def plist_refresh():
|
||||||
return call("PLISTREFRESH")
|
return call("PLISTREFRESH")
|
||||||
|
|
36
libsaria/collection/playlist.py
Normal file
36
libsaria/collection/playlist.py
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# Bryan Schumaker (11/07/2010)
|
||||||
|
|
||||||
|
import libsaria
|
||||||
|
|
||||||
|
song_list = None
|
||||||
|
song_set = None
|
||||||
|
|
||||||
|
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
|
||||||
|
song_list = libsaria.data.load("playlist", ".list")
|
||||||
|
if song_list == None:
|
||||||
|
reset()
|
||||||
|
return
|
||||||
|
song_set = set(song_list)
|
||||||
|
load()
|
||||||
|
|
||||||
|
def save():
|
||||||
|
libsaria.data.save(song_list, "playlist", ".list")
|
||||||
|
|
||||||
|
def walk():
|
||||||
|
global song_list
|
||||||
|
for id in song_list:
|
||||||
|
yield id
|
|
@ -6,7 +6,8 @@ import menu
|
||||||
|
|
||||||
libsaria = ocarina.libsaria
|
libsaria = ocarina.libsaria
|
||||||
from libsaria import collection
|
from libsaria import collection
|
||||||
library = collection.library
|
library = collection.library
|
||||||
|
playlist = collection.playlist
|
||||||
|
|
||||||
event = ocarina.libsaria.event
|
event = ocarina.libsaria.event
|
||||||
gtk = ocarina.gtk
|
gtk = ocarina.gtk
|
||||||
|
@ -46,6 +47,21 @@ class Collection(gtk.ScrolledWindow):
|
||||||
ins_next += 1
|
ins_next += 1
|
||||||
self.list.thaw()
|
self.list.thaw()
|
||||||
|
|
||||||
|
def populate2(self, func):
|
||||||
|
self.list.freeze()
|
||||||
|
insert = self.list.list.insert
|
||||||
|
getattr = library.get_attr
|
||||||
|
ins_next = 0
|
||||||
|
for id in func():
|
||||||
|
title = getattr(id, "title")
|
||||||
|
length = getattr(id, "lenstr")
|
||||||
|
artist = getattr(id, "artist")
|
||||||
|
album = getattr(id, "album")
|
||||||
|
year = getattr(id, "year")
|
||||||
|
insert(ins_next, [id, title, length, artist, album, year, ""])
|
||||||
|
ins_next += 1
|
||||||
|
self.list.thaw()
|
||||||
|
|
||||||
def on_mouse_motion(self, widget, pos):
|
def on_mouse_motion(self, widget, pos):
|
||||||
list = self.list
|
list = self.list
|
||||||
x,y = list.convert_bin_window_to_widget_coords(int(pos.x), int(pos.y))
|
x,y = list.convert_bin_window_to_widget_coords(int(pos.x), int(pos.y))
|
||||||
|
@ -60,8 +76,8 @@ class Collection(gtk.ScrolledWindow):
|
||||||
"Played: %s Score: %s" % items)
|
"Played: %s Score: %s" % items)
|
||||||
|
|
||||||
def add_selected_to_playlist(self, *args):
|
def add_selected_to_playlist(self, *args):
|
||||||
self.list.for_each_selected(collection.plist_add_libid)
|
self.list.for_each_selected(playlist.add_id)
|
||||||
collection.plist_save()
|
playlist.save()
|
||||||
collection.plist_refresh()
|
collection.plist_refresh()
|
||||||
|
|
||||||
|
|
||||||
|
@ -128,13 +144,15 @@ class Playlist(Collection):
|
||||||
self.populate()
|
self.populate()
|
||||||
|
|
||||||
def reset(self):
|
def reset(self):
|
||||||
collection.plist_reset()
|
playlist.reset()
|
||||||
|
playlist.save()
|
||||||
self.clear()
|
self.clear()
|
||||||
|
|
||||||
def populate(self):
|
def populate(self):
|
||||||
#import datetime
|
#import datetime
|
||||||
#before = datetime.datetime.now()
|
#before = datetime.datetime.now()
|
||||||
Collection.populate(self, collection.walk_plist)
|
#Collection.populate(self, collection.walk_plist)
|
||||||
|
Collection.populate2(self, playlist.walk)
|
||||||
#after = datetime.datetime.now()
|
#after = datetime.datetime.now()
|
||||||
#print "Populating took: %s" % (after - before)
|
#print "Populating took: %s" % (after - before)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user