print "<tr><td>" if oysterruns: print "<a href='home.py?action=enqueue&file=" + escapedfilename + "' " + \ "title='Enqueue'><img src='themes/" + myconfig['theme'] + "/enqueue" + cssclass + ".png'" +\ "border='0' alt='Enqueue'/></a>" print "<a class='" + cssclass + "' href='fileinfo.py?" + \ "file=/" + escapedfilename + "'>" + displayname + "</a></td>" print "<td class='" + cssclass + "' align='center'>" + reason + "</td></tr>\n" print "</table>" import common common.navigation_header("Statistics") myconfig = config.get_config() mediadir = myconfig['mediadir'][:-1] playlist = config.get_playlist() # Check if oyster is started if os.path.exists(myconfig['basedir']): oysterruns = 1 else: oysterruns = 0 # Load logfile into permanent array logfile = open(myconfig['savedir'] + "logs/" + playlist)
cgitb.enable() import config myconfig = config.get_config() basedir = myconfig['basedir'] mediadir = myconfig['mediadir'][:-1] import cgi form = cgi.FieldStorage() playlist = config.get_playlist() import common common.navigation_header() try: soundfile = form['file'].value except KeyError: soundfile = '' import fifocontrol if 'action' in form: fifocontrol.do_action(form['action'].value, soundfile) import os.path import sys if not os.path.exists(mediadir + soundfile): print "<h1>Error!</h1>" print "<p>File <strong>" + soundfile + "</strong> could not be found.</p>"
import urllib import re import cgitb cgitb.enable() import config myconfig = config.get_config() basedir = myconfig['basedir'] mediadir = myconfig['mediadir'][:-1] import cgi form = cgi.FieldStorage() playlist = config.get_playlist() import common common.navigation_header() try: listname = form['list'].value except KeyError: listname = playlist import os.path import sys if not os.path.exists(myconfig['savedir'] + '/lists/' + playlist): print "<h1>Error!</h1>" print "<p>Playlist <strong>" + listname + "</strong> could not be found.</p>" print "</body></html>" sys.exit()
displayname = taginfo.get_tag_light(filename) filename = filename.replace(mediadir, "", 1) escapedfilename = urllib.quote(filename) print "<tr>" print "<td><strong>" + playdate[9:11] + ":" + playdate[11:13] + "</strong></td>" print "<td><a class='file' href='fileinfo.py?file=" + escapedfilename + "'>" + displayname + "</a><br></td>" print "</tr>" print "</table>" sys.exit() import common common.navigation_header("History") myconfig = config.get_config() mediadir = myconfig["mediadir"][:-1] form = cgi.FieldStorage() playlist = config.get_playlist() try: searchdate = datetime.datetime( int(form["year"].value), int(form["month"].value), int(form["day"].value), int(form["hour"].value), int(form["min"].value), ) timerange = form["range"].value
myconfig = config.get_config() basedir = myconfig['basedir'] savedir = myconfig['savedir'] mediadir = myconfig['mediadir'][:-1] form = cgi.FieldStorage() if 'action' in form and form['action'].value == 'addnewlist' and 'newlistname' in form: fifocontrol.do_action('addnewlist', form['newlistname'].value) if 'playlist' in form: playlist = form['playlist'].value elif 'newlistname' in form: playlist = form['newlistname'].value else: common.navigation_header(title="Oyster-GUI") print "<p>You did not specify a name for the playlist.</p>" print "<p>Please press the <i>Back</i> button in your browser and try again.</a></p>" common.html_footer() sys.exit() if playlist == 'default': common.navigation_header(title="Oyster-GUI") print "<p>It is not allowed to edit the default playlist.</p>" common.html_footer() sys.exit() if not 'mode' in form and not 'delfile' in form and not 'deldir' in form and not 'addfile' in form\ and not 'adddir' in form: print_frameset() sys.exit()
common.html_header(title=_("Browse")) print "<ul id='navigation'>" print "<li class='double'><a href='browse.py?mode=editplaylist&playlist=" + urllib.quote(form['playlist'].value) +\ "'>Browse</a></li>" print "<li class='double'><a href='search.py?mode=playlist&playlist=" + urllib.quote(form['playlist'].value) +\ "'>Search</a></li>" print "</ul>" print "<br/><hr/>" elif 'mode' in form and form['mode'].value == 'browseplaylist' and 'playlist' in form: viewplaylist = True editplaylist = False title = _("Songs in playlist") + " '" + form['playlist'].value + "'" common.navigation_header(title=title) print "<h1>" + title + "</h1>" mode = '&mode=browseplaylist' else: viewplaylist = False editplaylist = False common.navigation_header(title=_("Browse")) mode = '' if 'dir' in form: # Check given parameter for possible security risks givendir = form['dir'].value + '/' givendir = re.sub('//', '/', givendir) givendir = re.sub('\.\./', '', givendir) if givendir == '..': givendir = '/'
if 'password' in form and os.path.exists(config['basedir']): password = form['password'].value if password == config['partymodepassword']: cookie = Cookie.SimpleCookie() sessionid = str(uuid.uuid1()) hashed_id = hashlib.sha1(sessionid).hexdigest() cookie["oyster-sessionid"] = sessionid id_storage = anydbm.open('/tmp/oyster_sessionids', 'c') id_storage[hashed_id] = str(datetime.datetime.now()) id_storage.close() print cookie just_authenticated = True else: password_failed = True common.navigation_header(title="Admin Login") if not os.path.exists(config['basedir']): print "<p>Please start Oyster before trying to login.</p>" common.html_footer() sys.exit() if password_failed: print "<p>Password incorrect.</p>" elif just_authenticated or common.is_authenticated(): print "<p>Authenticated! Please visit the <a class='file' href='home.py'>main page</a> now.</p>" common.html_footer() sys.exit() print """ <form method='post' action='admin.py' " + "enctype='application/x-www-form-urlencoded'>
cgitb.enable() common.hide_page_in_party_mode() _ = common.get_prefered_language() basedir = myconfig['basedir'] savedir = myconfig['savedir'] form = cgi.FieldStorage() if os.path.exists(myconfig['basedir']): oysterruns = True else: oysterruns = False common.navigation_header("Playlists") if 'action' in form and ('listname' in form or 'newlistname' in form): if form['action'].value == 'confirmdelete': confirmdelete() sys.exit() else: if 'listname' in form: filename = form['listname'].value else: filename = form['newlistname'].value fifocontrol.do_action(form['action'].value, filename) if 'playlist' in form and 'action' in form and form['action'].value == 'move': renameform(form['playlist'].value)
os.mkdir(savedir + "config") configs = ["default"] if "action" in form: if form["action"].value == "saveconfig" and "playlist" in form: saveconfig(form["playlist"].value) if form["playlist"].value not in configs: configs.append(form["playlist"].value) elif form["action"].value == "delete" and "playlist" in form: os.unlink(savedir + "config/" + os.path.basename(form["playlist"].value)) if form["playlist"].value in configs: configs.remove(form["playlist"].value) import common common.navigation_header("Config Editor") if "action" not in form and "playlist" in form: configeditor(form["playlist"].value) files = [] sections = [] for entry in playlists: if os.path.isfile(savedir + "lists/" + entry) or entry == "default": files.append(entry) if entry.find("_") > -1: entry = re.sub("_.*", "", entry) if entry not in sections: sections.append(entry)
mode = '&mode=playlist' common.html_header(title="Suchen") print "<ul id='navigation'>" print "<li class='double'><a href='browse.py?mode=editplaylist&playlist=" +\ urllib.quote(form['playlist'].value) + "'>" + _("Browse") + "</a></li>" print "<li class='double'><a href='search.py?mode=playlist&playlist=" +\ urllib.quote(form['playlist'].value) + "'>" + _("Search") + "</a></li>" print "</ul>" print "<br/><hr/>" else: editplaylist = 0 common.navigation_header(title="Suchen") mode = '' if 'searchtype' in form and form['searchtype'].value == 'regex': searchtype = 'regex' regexcheck = "checked='checked'" normalcheck = '' else: searchtype = 'normal' normalcheck = "checked='checked'" regexcheck = '' # Check in which playlist to search if not editplaylist and 'playlist' in form and form['playlist'].value == 'current': playlist = config.get_playlist()
common.html_header(title=_("Browse")) print "<ul id='navigation'>" print "<li class='double'><a href='browse.py?mode=editplaylist&playlist=" + urllib.quote(form['playlist'].value) +\ "'>Browse</a></li>" print "<li class='double'><a href='search.py?mode=playlist&playlist=" + urllib.quote(form['playlist'].value) +\ "'>Search</a></li>" print "</ul>" print "<br/><hr/>" elif 'mode' in form and form[ 'mode'].value == 'browseplaylist' and 'playlist' in form: viewplaylist = True editplaylist = False title = _("Songs in playlist") + " '" + form['playlist'].value + "'" common.navigation_header(title=title) print "<h1>" + title + "</h1>" mode = '&mode=browseplaylist' else: viewplaylist = False editplaylist = False common.navigation_header(title=_("Browse")) mode = '' if 'dir' in form: # Check given parameter for possible security risks givendir = form['dir'].value + '/' givendir = re.sub('//', '/', givendir) givendir = re.sub('\.\./', '', givendir) if givendir == '..': givendir = '/'
mode = '&mode=playlist' common.html_header(title="Suchen") print "<ul id='navigation'>" print "<li class='double'><a href='browse.py?mode=editplaylist&playlist=" +\ urllib.quote(form['playlist'].value) + "'>" + _("Browse") + "</a></li>" print "<li class='double'><a href='search.py?mode=playlist&playlist=" +\ urllib.quote(form['playlist'].value) + "'>" + _("Search") + "</a></li>" print "</ul>" print "<br/><hr/>" else: editplaylist = 0 common.navigation_header(title="Suchen") mode = '' if 'searchtype' in form and form['searchtype'].value == 'regex': searchtype = 'regex' regexcheck = "checked='checked'" normalcheck = '' else: searchtype = 'normal' normalcheck = "checked='checked'" regexcheck = '' # Check in which playlist to search if not editplaylist and common.is_oyster_running() and 'playlist' in form and form['playlist'].value == 'current': playlist = config.get_playlist()
if line[:-1] != affects: newblacklist.write(line) blacklist.close() newblacklist.close() os.unlink(savedir + "blacklist.tmp") myconfig = config.get_config() basedir = myconfig['basedir'] savedir = myconfig['savedir'] mediadir = myconfig['mediadir'][:-1] form = cgi.FieldStorage() playlist = config.get_playlist() import common common.navigation_header("Blacklists") results = [] if form.has_key('affects') and form.has_key('action') \ and form['action'].value == 'test': escaffects = cgi.escape(form['affects'].value) else: escaffects = '' # Create form print "<form method='post' action='blacklist.py' " + \ "enctype='application/x-www-form-urlencoded'>" print "<fieldset class='searchform'>" print "<legend class='searchform'>Add entries to blacklist</legend>"
mediadir = myconfig['mediadir'][:-1] form = cgi.FieldStorage() playlist = config.get_playlist() # Is oyster currently running? if os.path.exists(myconfig['basedir']): oysterruns = 1 else: oysterruns = 0 if form.has_key('action'): fifocontrol.do_action(form['action'].value, form['file'].value) import common common.navigation_header("Scoring") score = {} maxscore = 1 if os.path.exists(myconfig['savedir'] + "scores/" + playlist): scorefile = open (myconfig['savedir'] + "scores/" + playlist) scorefile.readline() # skip initial number for line in scorefile.readlines(): line = line[:-1] if score.has_key(line): score[line] = score[line] + 1 if maxscore < score[line]: maxscore = score[line] else: score[line] = 1
# You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import taginfo import urllib import re import cgitb import sys cgitb.enable() import cgi form = cgi.FieldStorage() import common common.navigation_header("Lyrics") if form.has_key('artist') and form.has_key('song'): artist = form['artist'].value song = form['song'].value else: print "<h1>Error: Artist or songtitle not specified!</h1></body></html>" sys.exit() try: from SOAPpy import WSDL except ImportError: print "<h1>Error: SOAPpy not found. Please install python-soappy to use this function.</h1>" print "</body></html>" sys.exit()
"""Updates all cached Taginfos""" __revision__ = 1 import cgi import config import cgitb import anydbm import os.path import taginfo cgitb.enable() import common common.hide_page_in_party_mode() common.navigation_header("Rebuild Tags") myconfig = config.get_config() mediadir = myconfig['mediadir'][:-1] form = cgi.FieldStorage() playlist = config.get_playlist() cache = anydbm.open(myconfig['savedir'] + 'tagcache-python', 'c') allfiles = cache.keys() cache.close() cache = anydbm.open(myconfig['savedir'] + 'tagcache-python', 'n') cache.close() print "<h1>Regeneration taginfos...</h1>"
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Updates all cached Taginfos""" __revision__ = 1 import cgi import config import cgitb import anydbm import os.path import taginfo cgitb.enable() import common common.hide_page_in_party_mode() common.navigation_header("Rebuild Tags") myconfig = config.get_config() mediadir = myconfig['mediadir'][:-1] form = cgi.FieldStorage() playlist = config.get_playlist() cache = anydbm.open(myconfig['savedir'] + 'tagcache-python', 'c') allfiles = cache.keys() cache.close() cache = anydbm.open(myconfig['savedir'] + 'tagcache-python', 'n') cache.close() print "<h1>Regeneration taginfos...</h1>"
cssclass = 'file' print "<tr><td>" if oysterruns: print "<a href='home.py?action=enqueue&file=" + escapedfilename + "' " + \ "title='Enqueue'><img src='themes/" + myconfig['theme'] + "/enqueue" + cssclass + ".png'" +\ "border='0' alt='Enqueue'/></a>" print "<a class='" + cssclass + "' href='fileinfo.py?" + \ "file=/" + escapedfilename + "'>" + displayname + "</a></td>" print "<td class='" + cssclass + "' align='center'>" + reason + "</td></tr>\n" print "</table>" import common common.navigation_header("Statistics") myconfig = config.get_config() mediadir = myconfig['mediadir'][:-1] playlist = config.get_playlist() # Check if oyster is started if os.path.exists(myconfig['basedir']): oysterruns = 1 else: oysterruns = 0 # Load logfile into permanent array logfile = open (myconfig['savedir'] + "logs/" + playlist)
"""Checks the scorefile for non-existing files""" __revision__ = 1 import cgi import config import cgitb import os.path import fifocontrol import sys cgitb.enable() import common common.hide_page_in_party_mode() common.navigation_header("Clear Scores") myconfig = config.get_config() mediadir = myconfig['mediadir'][:-1] form = cgi.FieldStorage() playlist = config.get_playlist() if not os.path.exists(myconfig['basedir']): print "<h1>Please <a href='home.py?action=start'>" \ + "start oyster</a> before clearing the scorefile!</h1>" sys.exit() # Load scorefile into permanent array scorefile = open (myconfig['savedir'] + "scores/" + playlist) scorefile.readline()
for line in blacklist.readlines(): if line[:-1] != affects: newblacklist.write(line) blacklist.close() newblacklist.close() os.unlink (savedir + "blacklist.tmp") myconfig = config.get_config() basedir = myconfig['basedir'] savedir = myconfig['savedir'] mediadir = myconfig['mediadir'][:-1] form = cgi.FieldStorage() playlist = config.get_playlist() import common common.navigation_header("Blacklists") results = [] if form.has_key('affects') and form.has_key('action') \ and form['action'].value == 'test': escaffects = cgi.escape(form['affects'].value) else: escaffects = '' # Create form print "<form method='post' action='blacklist.py' " + \ "enctype='application/x-www-form-urlencoded'>" print "<fieldset class='searchform'>" print "<legend class='searchform'>Add entries to blacklist</legend>"
os.mkdir(savedir + "config") configs = ['default'] if 'action' in form: if form['action'].value == 'saveconfig' and 'playlist' in form: saveconfig(form['playlist'].value) if form['playlist'].value not in configs: configs.append(form['playlist'].value) elif form['action'].value == 'delete' and 'playlist' in form: os.unlink(savedir + "config/" + os.path.basename(form['playlist'].value)) if form['playlist'].value in configs: configs.remove(form['playlist'].value) import common common.navigation_header("Config Editor") if 'action' not in form and 'playlist' in form: configeditor(form['playlist'].value) files = [] sections = [] for entry in playlists: if os.path.isfile(savedir + "lists/" + entry) or entry == 'default': files.append(entry) if entry.find('_') > -1: entry = re.sub('_.*', '', entry) if entry not in sections: sections.append(entry)
# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Print a static page containing links of the Extras-section""" __revision__ = 1 import cgitb cgitb.enable() import common common.hide_page_in_party_mode() common.navigation_header(title="Extras") print "<h1><a href='playlists.py'>Playlists</a></h1>" print "<div style='padding-left: 2em;'>" print "Manage or select playlist</div>" print "<h1><a href='score.py'>Scoring</a></h1>" print "<div style='padding-left: 2em;'>Specify which songs should be played more often</div>" print "<h1><a href='blacklist.py'>Blacklists</a></h1>" print "<div style='padding-left: 2em;'>" print "Specify files (e.g. audio books) which should never be played</div>" print "<h1><a href='statistics.py'>Statistics</a></h1>" print "<div style='padding-left: 2em;'>" print "Print general statistics like Top-10-Songs, number of played songs, " + \
print "<form action='home.py' method='get'>" print "<img src='themes/" + myconfig['theme'] + "/volume.png' alt='volume'/>" print "<input name='vol' class='volslider' type='range' min='0' max='100' value='" + volume + "'/>" print "<input class='volsubmit' type='image' src='themes/"+ myconfig['theme'] + "/setvolume.png' alt='✓'>" print "</form>" print "</td></tr>" cgitb.enable() myconfig = config.get_config() basedir = myconfig['basedir'] mediadir = myconfig['mediadir'][:-1] form = cgi.FieldStorage() common.navigation_header(title=_("Overview"), refreshpage="home.py") if 'file' in form: filename = form['file'].value else: filename = '' if 'action' in form: action = form['action'].value if action == 'start' or os.path.exists(basedir): fifocontrol.do_action(action, filename) else: action = '' if 'vol' in form: volumeLevel = form['vol'].value
filename = matcher.group(3) if reason == 'PLAYLIST' or reason == 'VOTED' or reason == 'SCORED' or reason == 'ENQUEUED': displayname = taginfo.get_tag_light(filename) filename = filename.replace(mediadir, '', 1) escapedfilename = urllib.quote(filename) print "<tr>" print "<td><strong>" + playdate[9:11] + ":" + playdate[11:13] + "</strong></td>" print "<td><a class='file' href='fileinfo.py?file=" + escapedfilename + "'>" + displayname + "</a><br></td>" print "</tr>" print "</table>" sys.exit() import common common.navigation_header("History") myconfig = config.get_config() mediadir = myconfig['mediadir'][:-1] form = cgi.FieldStorage() playlist = config.get_playlist() try: searchdate = datetime.datetime(int(form['year'].value), int(form['month'].value), int(form['day'].value), \ int(form['hour'].value), int(form['min'].value)) timerange = form['range'].value except KeyError: searchdate = datetime.datetime.today() timerange = "20" print "<h1>What was played?</h1>"
# GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """Print a static page containing links of the Extras-section""" __revision__ = 1 import cgitb cgitb.enable() import common common.hide_page_in_party_mode() common.navigation_header(title="Extras") print "<h1><a href='playlists.py'>Playlists</a></h1>" print "<div style='padding-left: 2em;'>" print "Manage or select playlist</div>" print "<h1><a href='score.py'>Scoring</a></h1>" print "<div style='padding-left: 2em;'>Specify which songs should be played more often</div>" print "<h1><a href='blacklist.py'>Blacklists</a></h1>" print "<div style='padding-left: 2em;'>" print "Specify files (e.g. audio books) which should never be played</div>" print "<h1><a href='statistics.py'>Statistics</a></h1>" print "<div style='padding-left: 2em;'>" print "Print general statistics like Top-10-Songs, number of played songs, " + \
myconfig = config.get_config() basedir = myconfig['basedir'] savedir = myconfig['savedir'] mediadir = myconfig['mediadir'][:-1] form = cgi.FieldStorage() if 'action' in form and form[ 'action'].value == 'addnewlist' and 'newlistname' in form: fifocontrol.do_action('addnewlist', form['newlistname'].value) if 'playlist' in form: playlist = form['playlist'].value elif 'newlistname' in form: playlist = form['newlistname'].value else: common.navigation_header(title="Oyster-GUI") print "<p>You did not specify a name for the playlist.</p>" print "<p>Please press the <i>Back</i> button in your browser and try again.</a></p>" common.html_footer() sys.exit() if playlist == 'default': common.navigation_header(title="Oyster-GUI") print "<p>It is not allowed to edit the default playlist.</p>" common.html_footer() sys.exit() if not 'mode' in form and not 'delfile' in form and not 'deldir' in form and not 'addfile' in form\ and not 'adddir' in form: print_frameset() sys.exit()