Permalink
Browse files

small bugfixes, 0.9.7 updates

  • Loading branch information...
1 parent 00e3790 commit 00821ebd40c74de74fd376a859ce2dfb5f704a8f @ralfonso committed Sep 20, 2009
View
@@ -1,6 +1,8 @@
#!/bin/sh
SELF=$(cd $(dirname $0); pwd -P)/
+CWD=$(pwd)
+cd $SELF
start() {
if [ ! -e "$SELF/env/bin/paster" ]
@@ -29,3 +31,4 @@ case $1 in
;;
esac
+cd $CWD
@@ -32,8 +32,7 @@ def load_environment(global_conf, app_conf):
directories=paths['templates'],
module_directory=os.path.join(app_conf['cache_dir'], 'templates'),
input_encoding='utf-8', output_encoding='utf-8',
- imports=['from webhelpers.html import escape'],
- default_filters=['escape'])
+ imports=['from webhelpers.html import escape'], default_filters=['escape'])
# CONFIGURATION OPTIONS HERE (note: all config options will override
# any Pylons config options)
@@ -43,6 +43,7 @@ def status(self):
m = g.p.connect()
current = m.currentsong()
status = m.status()
+ m.close()
return dict(track=current,status=status)
@@ -76,6 +77,7 @@ def fs_status(self):
track += 1
+ m.close()
return dict(status=status,current=current,playlist=remaining_playlist)
def setvolume(self,id):
@@ -87,6 +89,8 @@ def setvolume(self,id):
except ValueError:
pass
+ m.close()
+
def seek(self,id,val):
m = g.p.connect()
try:
@@ -96,17 +100,22 @@ def seek(self,id,val):
except ValueError:
pass
+ m.close()
+
def stop(self):
m = g.p.connect()
m.stop()
+ m.close()
def previous(self):
m = g.p.connect()
m.previous()
+ m.close()
def next(self):
m = g.p.connect()
m.next()
+ m.close()
def play(self):
m = g.p.connect()
@@ -115,10 +124,12 @@ def play(self):
m.pause()
else:
m.play()
+ m.close()
def pause(self):
m = g.p.connect()
m.pause()
+ m.close()
def reorderplaylist(self):
tracklist = request.POST.getall('track[]')
@@ -132,12 +143,14 @@ def reorderplaylist(self):
m.moveid(parts[0],iter)
iter += 1
+ m.close()
def addtoplaylist(self):
file = request.POST.get('file').encode('utf-8')
m = g.p.connect()
m.add(file)
+ m.close()
def addalbumtoplaylist(self):
artist = request.GET.get('artist').encode('utf-8')
@@ -151,6 +164,7 @@ def addalbumtoplaylist(self):
m.add(t['file'])
m.command_list_end()
+ m.close()
def addartistalbums(self):
artist = request.GET.get('artist').encode('utf-8')
@@ -169,6 +183,7 @@ def addartistalbums(self):
m.add(t['file'])
m.command_list_end()
+ m.close()
def addpathtoplaylist(self):
@@ -190,13 +205,25 @@ def addpathtoplaylist(self):
m.add(t['file'])
m.command_list_end()
+ m.close()
def removetrack(self,id):
m = g.p.connect()
try:
m.deleteid(id)
except CommandError,e: # exception if the track to be removed doesn't exist
return str(e)
+ finally:
+ m.close()
+
+ def removemultipletracks(self,id):
+ m = g.p.connect()
+ for id in id.split(','):
+ if id:
+ try:
+ m.deleteid(id)
+ except CommandError,e: # exception if the track to be removed doesn't exist
+ pass
def playnow(self,id):
m = g.p.connect()
@@ -205,24 +232,29 @@ def playnow(self,id):
m.play()
except CommandError,e:
return str(e)
-
+ finally:
+ m.close()
def repeat(self,id):
m = g.p.connect()
m.repeat(id)
+ m.close()
def random(self,id):
m = g.p.connect()
m.random(id)
+ m.close()
def clearplaylist(self):
m = g.p.connect()
m.clear()
+ m.close()
def shuffle(self):
m = g.p.connect()
m.shuffle()
+ m.close()
def trimplaylist(self):
""" trims the playlist of everything leading up to the currently playing track """
@@ -245,11 +277,13 @@ def trimplaylist(self):
break
m.command_list_end()
+ m.close()
def playnext(self,id):
m = g.p.connect()
current = m.currentsong()
if not 'pos' in current:
return
m.moveid(id,int(current['pos'])+1)
+ m.close()
@@ -23,7 +23,7 @@ def __init__(self):
variable
"""
- self.p = QueuePool(self.get_mpd_conn, max_overflow=1, pool_size=2, recycle=60,use_threadlocal=True,timeout=5)
+ self.p = QueuePool(self.get_mpd_conn, max_overflow=5, pool_size=2, recycle=60,use_threadlocal=True,timeout=5)
self.tc = TConfig()
self.get_genres()
pass
@@ -24,6 +24,13 @@ def format_time(seconds):
except TypeError:
return '00:00'
+def format_track_time(track):
+ try:
+ seconds = track['time']
+ return format_time(seconds)
+ except KeyError:
+ return '00:00'
+
def format_filesize(bytes):
kb = "%02.2fKB" % (bytes / 1024.0)
return kb
@@ -220,10 +220,19 @@ ul#playlist li {
cursor:move;
}
+ul#playlist li.selected {
+ background-color:#aaa;
+}
+
ul#playlist li a {
cursor:pointer;
}
+ul#playlist li:hover span.displaytitle {
+ font-size:11px;
+ font-weight:bold;
+}
+
ul#playlist li a img {
opacity:0.6;
}
@@ -387,6 +387,43 @@ function removeTrack(el,id) {
});
}
+function removeMultipleTracks() {
+ var url = '/mpdcontrol/removemultipletracks/'
+
+ var all_ids = Array();
+ var iter = 0;
+
+ alert($('ul#playlist li.selected'));
+ $('ul#playlist li.selected').each(
+ function() {
+ var id = $(this).attr('id').split('_');
+ all_ids[iter] = id
+ id = id[1];
+ id = id.split(':');
+ id = id[0];
+ url += id + ',';
+
+ alert(id);
+
+ iter += 1;
+ });
+
+ $.ajax({
+ url: url,
+ type: 'GET',
+ cache: false,
+ success: function() {
+ for(i = 0; i < all_ids.length(); i++) {
+ $('ul#playlist li#' + all_ids[i]).remove();
+ }
+ setPlaylistColors(document)
+ if ($('#playlist li').length == 0) {
+ empty_playlist_background();
+ }
+ }
+ });
+}
+
function setPlaylistColors(scope,force) {
var addl = '';
@@ -119,7 +119,6 @@
$('ul#playlist li a img').hover(function() {$(this).css('opacity','1.0')},
function() {$(this).css('opacity','0.6')});
-
}
);
</script>
@@ -193,14 +192,14 @@
%>
<li id="track_${t['id']}:${t['pos']}">
<a onclick="removeTrack(this,${t['id']})" title="remove this track" style="padding-right:1px;"><img src="/img/remove.png" /></a><a onclick="window.parent.playNow(${t['id']})" title="play this track now"><img src="/img/playnow.png" /></a>
- ${display_title}
+ <span class="displaytitle">${display_title}</span>
% if 'artist' in t and 'album' in t:
<div class="playlist-tooltip">
<a onclick="window.parent.artistAlbums('${t['artist'].replace("'","\\'")}')">${t['artist']}</a>
<br />
<a onclick="window.parent.artistAlbums('${t['artist'].replace("'","\\'")}','${t['album'].replace("'","\\'")}')">${t['album']}</a>
<br />
- ${h.format_time(t['time'])}
+ ${h.format_track_time(t)}
&lt;<a onclick="playNext(${t['id']})">play this next</a>&gt;
</div>
% endif
@@ -1,4 +1,5 @@
<%inherit file="body.html"/>
+
<script language="javascript">
$(document).ready(
function() {
@@ -30,7 +31,14 @@
<div id="container-tracks">
<ul id="list">
% for t in c.tracks:
- <li><a onclick="addToPlaylist('${h.html.url_escape(t['file'])}')"><img src="/img/add.png" /> ${t['formattedtrack']}</a></li>
+ <%
+ if not c.album_safe:
+ title = h.html.literal("title=\"Album: " + t['album'].replace('"','\\"') + "\"")
+ else:
+ title = ''
+ %>
+
+ <li><a ${title} onclick="addToPlaylist('${h.html.url_escape(t['file'])}')"><img src="/img/add.png" /> ${t['formattedtrack']}</a></li>
% endfor
</ul>
</div>

0 comments on commit 00821eb

Please sign in to comment.