Author: duncan
Date: Tue Sep 25 14:01:52 2007
New Revision: 9902
Log:
[ 1800063 ] Log file view webpage
New web pages by Don Locke added
Added:
branches/rel-1/freevo/src/www/htdocs/pluginconfig.rpy (contents, props
changed)
branches/rel-1/freevo/src/www/htdocs/scripts/pluginconfig.js (contents,
props changed)
branches/rel-1/freevo/src/www/htdocs/scripts/viewlogfile.js (contents,
props changed)
branches/rel-1/freevo/src/www/htdocs/viewlogfile.rpy (contents, props
changed)
Modified:
branches/rel-1/freevo/src/www/htdocs/config.rpy
branches/rel-1/freevo/src/www/htdocs/scripts/config.js
branches/rel-1/freevo/src/www/htdocs/scripts/youtube.js
branches/rel-1/freevo/src/www/htdocs/youtube.rpy
Modified: branches/rel-1/freevo/src/www/htdocs/config.rpy
==============================================================================
--- branches/rel-1/freevo/src/www/htdocs/config.rpy (original)
+++ branches/rel-1/freevo/src/www/htdocs/config.rpy Tue Sep 25 14:01:52 2007
@@ -47,8 +47,8 @@
color = cred
status = 'NOT Updated, Error'
blOK = False
-
newline = varName + " = " + varValue
+
# Check the syntax of the new line.
if CheckSyntax(newline):
blOK = True
@@ -119,11 +119,20 @@
return itemlist
def GetGroupList(cfgvars):
- grps = []
+ grps = ['Other']
+ agrps = []
for vrs in cfgvars:
grp = vrs['group']
+ agrps.append(grp)
if not grp in grps:
grps.append(grp)
+
+ for vrs in cfgvars:
+ ngrp = agrps.count(vrs['group'])
+ if ngrp == 1:
+ grps.remove(vrs['group'])
+ vrs['group'] = 'Other'
+
grps.sort()
return grps
@@ -131,7 +140,7 @@
ctrl = ""
ctrl += '<input id="newname" name="newname" size="40"> ='
ctrl += '<input id="newvalue" name="newvalue" size="40">'
- ctrl += '<input type="button" onclick="FilterList(\'filterlist\')"
value="New Setting"><br><br>\n'
+ ctrl += '<input type="button" onclick="AddNewLine()" value="New
Setting"><br><br>\n'
return ctrl
@@ -147,9 +156,10 @@
cvalue = cvalue.replace(elemsep,elemsep + "\n")
ctrl = '<textarea id= "%s_tb" rows = %s cols=55 wrap="SOFT"
name=%s_tb>%s</textarea>' % (cname, str(rows),cname,cvalue)
return ctrl
+
def CreateFilterControl(grps,cvalue):
- ctrl = '\n<select name="filterlist" value="%s" id="filterlist">' % cvalue
+ ctrl = '\n<select name="filterlist" value="%s" id="filterlist"
onchange="FilterList(\'filterlist\')">' % cvalue
ctrl += '\n <option value="All">All</option>'
for grp in grps:
if grp == cvalue:
@@ -157,7 +167,6 @@
else:
ctrl += '\n <option value="%s">%s</option>' % (grp,grp)
ctrl += '\n</select>'
- ctrl += '<input type="button" onclick="FilterList(\'filterlist\')"
value="Apply Fiilter"><br><br>\n'
return ctrl
def ParseConfigFile(rconf):
@@ -201,35 +210,6 @@
fconfig.sort()
return fconfig
-def CreatePluginControl(nctrl):
- htmlctrl = HTMLResource()
- htmlctrl.tableRowOpen('class="chanrow"')
-
- checked = "Deactivated"
- btnName = "Activate"
- if nctrl['checked']:
- checked = "Activated"
- btnName = "Deactivate"
-
- cname = "'" + nctrl['ctrlname'] + "'"
- chkbox = ""
- htmlctrl.tableCell('<input type="button" onclick="SaveValue(' + cname +
')" value="' + btnName + '">\n','')
- htmlctrl.tableCell('<input type="button" onclick="DeleteLines(' + cname +
')" value="Delete">\n','')
-
-# chkbox += '<a href="config.rpy?delete=TRUE&startline=' +
str(nctrl['startline']) + '&endline=' + str(nctrl['endline']) + '">delete</a>'
- chkbox += '<input type="hidden" id="' + nctrl['ctrlname'] + '_startline"
value="' + str(nctrl['startline']) + '">\n'
- chkbox += checked + '\n'
-
- htmlctrl.tableCell(chkbox,'')
- htmlctrl.tableCell(nctrl['ctrlname'],'align="right"')
-
- if nctrl['level']:
- inputbox = '<input name="LEVEL' + nctrl['ctrlname'] + '" size="2"
value="' + nctrl['level'] + '">'
- htmlctrl.tableCell(inputbox,'align="right"')
-
- htmlctrl.tableRowClose()
- return htmlctrl.res
-
def CreateControl(nctrl):
htmlctrl = HTMLResource()
htmlctrl.tableRowOpen('class="chanrow"')
@@ -329,33 +309,6 @@
return True
return False
-def ParsePlugin(lparsed,cline):
- lparsed['type'] = "plugin"
- tsplit = cline.split("'")
- if len(tsplit) > 2:
- lparsed['ctrlname'] = tsplit[1].strip()
- else:
- lparsed['ctrlname'] = tsplit[0].strip()
- lparsed['group'] = lparsed['ctrlname'].split(".")[0].upper()
-
- if cline.find("level=") <> -1 or cline.find('level =') <> -1:
- cline=cline.replace(" ","")
- plevel = cline[cline.find("level=")+6:cline.find("level=")+9]
- plevel = plevel.replace(")","")
- plevel = plevel.replace(",","")
- lparsed['level'] = plevel
- else:
- lparsed['level'] = "00"
-
- if cline.startswith('plugin.remove'):
- lparsed['checked'] = False
- ctrlvalue = cline.split("#")
- if len(ctrlvalue) == 2:
- lparsed['comments'] = ctrlvalue[1]
- lparsed['comments'] = cline
- return lparsed
-
-
def VarType(cvalue):
if cvalue.startswith("'") and cvalue.endswith("'"):
return "string"
@@ -392,15 +345,14 @@
tln = tln.lstrip("#")
tln = tln.lstrip()
- if tln.startswith('plugin'):
- return lparsed
-
if len(tln) > 1:
fsplit = tln.split("=")
if len(fsplit) == 2:
lparsed['type'] = "textbox"
lparsed['ctrlname'] = fsplit[0].strip()
- lparsed['group'] = lparsed['ctrlname'].split("_")[0]
+ lparsed['group'] = lparsed['ctrlname'].split("_")[0].capitalize()
+ if lparsed['ctrlname'].endswith("_VOLUME"):
+ lparsed['group'] = "Volume"
if not lparsed['ctrlname'].isupper():
lparsed['type'] = ''
if (not config.__dict__.has_key(lparsed['ctrlname'])):
@@ -422,10 +374,10 @@
def DisplaySettings(fconfig,filterlist):
fv = HTMLResource()
+ groups = GetGroupList(fconfig)
fv.tableOpen('class="library" id="filelist"')
fv.tableRowOpen('class="chanrow"')
- fv.tableCell('','class ="guidehead" colspan="2"')
-# fv.tableCell('','class ="guidehead" colspan="1"')
+ fv.tableCell(CreateFilterControl(groups,filterlist),'class ="guidehead"
colspan="2"')
fv.tableCell('Enable','class ="guidehead" colspan="1"')
fv.tableCell('Name','class ="guidehead" colspan="1"')
fv.tableCell('Value','class ="guidehead" colspan="1"')
@@ -448,7 +400,6 @@
def _render(self, request):
fv = HTMLResource()
form = request.args
-
fv.printHeader(_('Config'),
'styles/main.css','scripts/config.js',selected=_('Config'))
if (not config.__dict__.has_key('CONFIG_EDIT_FILE')):
@@ -476,16 +427,13 @@
dlines = DeleteLines(int(startline),int(endline))
fv.res += "<br><h4>The following Lines were deleted :</h4>" +
dlines
-
rconf = ReadConfig()
fconfig = ParseConfigFile(rconf)
filterlist = fv.formValue(form,"filterlist")
- groups = GetGroupList(fconfig)
fv.res += '\n<br><form id="Url Download" action="config.rpy"
method="get">'
fv.res += '\n <div class="searchform" align="left"><br>'
fv.res += '<div align="left">'
- fv.res += CreateFilterControl(groups,filterlist)
# fv.res += NewLineControl()
fv.res += '</div>'
Added: branches/rel-1/freevo/src/www/htdocs/pluginconfig.rpy
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/www/htdocs/pluginconfig.rpy Tue Sep 25
14:01:52 2007
@@ -0,0 +1,314 @@
+#! /usr/bin/python
+# -----------------------------------------------------------------------
+# plugins.rpy - Show all plugins
+# -----------------------------------------------------------------------
+# $Id$
+#
+# Notes:
+# Todo:
+#
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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
+#
+# -----------------------------------------------------------------------
+
+import sys, time
+
+from www.web_types import HTMLResource, FreevoResource
+import util, config
+from plugin import is_active
+from helpers.plugins import parse_plugins
+from helpers.plugins import info_html
+
+TRUE = 1
+FALSE = 0
+
+def ReadConfig():
+ lconf = config.CONFIG_EDIT_FILE
+ lconf_hld = open(lconf,"r")
+ fconf = lconf_hld.readlines()
+ lconf_hld.close
+ return fconf
+
+def WriteConfigFile(filename,conf):
+ cfile = open(filename,"w")
+ for ln in conf:
+ cfile.write(ln)
+ cfile.close
+
+def UpdatePlugin(pcmd,pname,pline):
+ lconf = ReadConfig()
+
+ # Check to see if a line exists all ready.
+ status = "ERROR"
+ print pline
+ pline = int(pline)
+
+ if pline == -1:
+ lconf.append("")
+ pline = len(lconf) - 1
+
+ if pline <> -1:
+ lcline = lconf[pline]
+ if pcmd == "Disabled":
+ nline = "# plugin.activate('%s') \n" % pname
+ status = "DISABLE Plugin " + pname + "\n" + nline
+ lconf[pline] = nline
+ WriteConfigFile(config.CONFIG_EDIT_FILE,lconf)
+
+ elif pcmd == "REMOVE":
+ nline = "plugin.remove('%s')\n" % pname
+ status = "REMOVE Plugin " + pname + "\n" + nline
+ lconf[pline] = nline
+ WriteConfigFile(config.CONFIG_EDIT_FILE,lconf)
+
+ elif pcmd == "Enabled":
+ nline = "plugin.activate('%s')\n" % pname
+ status = "ACTIVATE Plugin " + pname + "\n" + nline
+ lconf[pline] = nline
+ WriteConfigFile(config.CONFIG_EDIT_FILE,lconf)
+
+ elif pcmd == "DELETE":
+ status = "ACTIVATE Plugin " + pname
+
+ return status
+
+def ParsePluginName(line):
+ sline = line.split("'")
+ if len(sline) > 2:
+ pname = sline[1]
+ else:
+ pname = "error"
+ return pname
+
+def GetConfigSetting(vname):
+ lconf = ReadConfig()
+ print "Search for Congin Setting = %s" % vname
+ ret = ""
+ for ln in lconf:
+ ln = ln.strip("#")
+ ln = ln.strip()
+ if ln.startswith(vname):
+ print "LINE FOUND"
+ sln = ln.split("=")
+ print sln
+ if len(sln) > 1:
+ ret = sln[1].split("#")[0]
+ return ret
+
+def ReadConfigPlugins():
+ rconf = ReadConfig()
+ pluginlines = []
+ cnt = 0
+ while cnt < len(rconf):
+ pline =
{'name':'','lineno':0,'orgline':'','enabled':False,'removed':False}
+ ln = rconf[cnt].strip()
+ pline['enabled'] = True
+
+ if ln.startswith('#'):
+ pline['enabled'] = False
+ ln = ln.strip('#')
+ ln = ln.strip()
+
+ if ln.startswith('plugin'):
+ pline['name'] = ParsePluginName(ln)
+ pline['lineno'] = cnt
+ pline['orgline'] = rconf[cnt]
+ pluginlines.append(pline)
+
+
+ cnt += 1
+
+ return pluginlines
+
+def GetPlugConfig(pname,all_plugins):
+ config_list = []
+ for p in all_plugins:
+ if p[0] == pname:
+ if p[5].find('config') > 0:
+ exec (p[5])
+ config_list = return_config()
+ return config_list
+
+def CreateListBox(cname,grps,cvalue,opts):
+ ctrl = '\n<select name="%s" value="" id="%s" %s>' % ( cname , cname, opts
)
+ for grp in grps:
+ if grp == cvalue:
+ ctrl += '\n <option value="' + grp + '" selected="yes">' + grp
+ '</option>'
+ else:
+ ctrl += '\n <option value="' + grp + '">' + grp + '</option>'
+ ctrl += '\n</select>'
+ return ctrl
+
+def displayplugin(plugin,group,pfilter,lconf,plugins_all):
+ html = HTMLResource()
+
+ pluginname = plugin[0]
+ for e in plugin:
+ if e.find("level") <> -1:
+ level = "30"
+
+ status = "Deactive"
+ btnlabel = "Disabled"
+ jscmd = "EnablePlugin"
+ if is_active(plugin[0]):
+ status = "Active"
+ btnlabel = "Enabled"
+ jscmd = "DisablePlugin"
+
+ # check tos ee fi the plugin has a line in localconf
+ lconfline = "No local_conf.py entry"
+ confentry = False
+ linenumber = -1
+ for lnum , lcline in enumerate(lconf):
+ if lcline['name'] == plugin[0]:
+ lconfline = lcline['orgline']
+ linenumber = lcline['lineno']
+ confentry = True
+ level = "N/A"
+
+ if is_active(plugin[0]) and not confentry:
+ status = "Active"
+ btnlabel = "Enabled"
+ jscmd = "RemovePlugin"
+
+ if lconfline.startswith("plugin.remove"):
+ status = "Removed"
+ btnlabel = "Removed"
+ jscmd = "EnablePlugin"
+
+ cmds = ["Enabled","Disabled","Removed"]
+ jsupdate = 'onchange="UpdatePlugin(\'%s\')"' % pluginname
+ btns = CreateListBox(pluginname + "_cmd",cmds,btnlabel,jsupdate)
+ btns += '<input type="hidden" id="%s_lineno" value="%i">\n' % ( pluginname
, linenumber )
+
+ if pfilter == "(All)" or status == pfilter:
+ html.tableRowOpen()
+ html.tableCell(group)
+ html.tableCell(btns)
+ html.tableCell(status)
+ html.tableCell(plugin[0],'align="left"')
+ html.tableCell(lconfline,'align="left"')
+ html.tableRowClose()
+
+ clist = GetPlugConfig(plugin[0],plugins_all)
+ for vr in clist:
+ html.tableRowOpen()
+ html.tableCell("")
+ html.tableCell("")
+ html.tableCell(vr[0],'align="Right"')
+ curvalue = GetConfigSetting(vr[0])
+ print "CURRENT VALUE = %s" % curvalue
+ html.tableCell('<input type="textbox" value="%s">' % curvalue
,'align="Left"')
+ html.tableCell(vr[2],'align="Left"')
+ html.tableRowClose()
+
+ return html.res
+
+class ConfigurePluginsResource(FreevoResource):
+
+ def _render(self, request):
+
+ fv = HTMLResource()
+ form = request.args
+ if not hasattr(config, 'all_plugins'):
+ config.all_plugins = parse_plugins()
+
+ all_plugins = config.all_plugins
+ special_plugins = ['tv', 'video', 'audio', 'image', 'idlebar']
+ plugincontrol = ['Active','Remove','Delete']
+
+ cmd = fv.formValue(form,"cmd")
+ pluginname = fv.formValue(form,"pluginname")
+ pluginline = fv.formValue(form,"pluginline")
+ if cmd and pluginname and pluginline:
+ print "PLUGIN COMMAND - " + cmd
+ fv.res = UpdatePlugin(cmd,pluginname,pluginline)
+ return String( fv.res )
+
+ fv.printHeader(_('configplugins'),
'styles/main.css','scripts/pluginconfig.js',selected=_('Plugins'))
+ #fv.tableBodyOpen()
+ fv.res += '\n<div class="searchform" align="left"><br>'
+ fv.res += '\n<br><form id="Url Download" action="pluginconfig.rpy"
method="get">'
+ fv.res += '<br>'
+
+ filterlist = special_plugins
+ filterlist.insert(0,"Global")
+ filterlist.insert(0,"(All)")
+
+ # Read the settings from localconf for plugins.
+ lcplugins = ReadConfigPlugins()
+
+ pluginfilter = fv.formValue(form, 'pluginfilter')
+ if not pluginfilter:
+ pluginfilter = "(All)"
+
+ filter = fv.formValue(form, 'filterlist')
+ if not filter:
+ filter = "(All)"
+
+ fv.tableOpen()
+ fv.tableRowOpen('class="chanrow"')
+ jsfilter = 'onchange="FilterListPlugin()"'
+ filterboxes =CreateListBox('grpfilter',filterlist,filter,jsfilter)
+ fb = ['(All)','Active','Deactive']
+ filterboxes += CreateListBox('statfilter', fb ,pluginfilter,jsfilter)
+ fv.tableCell(filterboxes,'class ="guidehead" colspan="2"')
+ fv.tableCell("Status",'class ="guidehead" colspan="1"')
+ fv.tableCell("Plugin",'class ="guidehead" colspan="1" align="left"')
+ fv.tableCell('Comments','class ="guidehead" colspan="1" align="left"')
+ fv.tableRowClose()
+
+ grp = "Global"
+ fv.tableRowOpen()
+ if filter == "(All)" or filter == "Global":
+ for p in all_plugins:
+ if not p[0][:p[0].find('.')] in special_plugins:
+ fv.res +=
displayplugin(p,grp,pluginfilter,lcplugins,all_plugins)
+ grp = ""
+
+ if filter == "(All)":
+ for type in special_plugins:
+ grp = type
+ for p in all_plugins:
+ if p[0][:p[0].find('.')] == type:
+ fv.res +=
displayplugin(p,grp,pluginfilter,lcplugins,all_plugins)
+ grp = ""
+
+ else:
+ grp = filter
+ for p in all_plugins:
+ if p[0][:p[0].find('.')] == filter:
+ fv.res +=
displayplugin(p,grp,pluginfilter,lcplugins,all_plugins)
+ grp = ""
+
+ fv.tableClose()
+ fv.res += '</form>'
+ fv.res += '</div>\n'
+ fv.res += '<br><br>'
+ fv.tableBodyClose()
+
+ fv.printLinks(request.path.count('/')-1)
+ fv.printFooter()
+
+
+
+ return String( fv.res )
+
+resource = ConfigurePluginsResource()
Modified: branches/rel-1/freevo/src/www/htdocs/scripts/config.js
==============================================================================
--- branches/rel-1/freevo/src/www/htdocs/scripts/config.js (original)
+++ branches/rel-1/freevo/src/www/htdocs/scripts/config.js Tue Sep 25
14:01:52 2007
@@ -5,6 +5,27 @@
window.location = 'config.rpy?filterlist=' + filter
}
+function EnablePlugin(pname) {
+ alert("Enable Plugin - " + pname)
+}
+
+function DisablePlugin(pname) {
+ var lineno;
+
+ // Get the Line Number of the Plugin.
+ lineno = document.getElementById(pname + "_lineno").value
+ alert("Disable Plugin - " + pname)
+}
+
+
+function FilterListPlugin(cname) {
+ var filter;
+
+ filter = document.getElementById(cname).value;
+ window.location = 'pluginconfig.rpy?' + cname + '=' + filter
+}
+
+
function DeleteLines(sline,eline) {
var filter,url;
Added: branches/rel-1/freevo/src/www/htdocs/scripts/pluginconfig.js
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/www/htdocs/scripts/pluginconfig.js Tue Sep
25 14:01:52 2007
@@ -0,0 +1,131 @@
+function FilterList(cname) {
+ var filter;
+
+ filter = document.getElementById(cname).value;
+ window.location = 'config.rpy?filterlist=' + filter
+}
+
+function UpdatePlugin(pname) {
+ var cmd,lineno,url;
+
+ cmd = document.getElementById(pname + "_cmd").value;
+ lineno = document.getElementById(pname + "_lineno").value;
+ url = "pluginconfig.rpy?cmd=" + cmd + "&pluginname=" + pname +
"&pluginline=" + lineno;
+ makeRequest(url , pname);
+}
+
+
+function RemovePlugin(pname) {
+ var lineno,url;
+
+ // Get the Line Number of the Plugin.
+ lineno = document.getElementById(pname + "_lineno").value;
+ url = "pluginconfig.rpy?cmd=REMOVE&pluginname=" + pname + "&pluginline=" +
lineno;
+ makeRequest(url , pname);
+}
+
+function EnablePlugin(pname) {
+ var lineno,url;
+
+ // Get the Line Number of the Plugin.
+ lineno = document.getElementById(pname + "_lineno").value
+ url = "pluginconfig.rpy?cmd=ACTIVATE&pluginname=" + pname + "&pluginline="
+ lineno
+ makeRequest(url , pname)
+}
+
+function DisablePlugin(pname) {
+ var lineno,url;
+
+ // Get the Line Number of the Plugin.
+ lineno = document.getElementById(pname + "_lineno").value
+ url = "pluginconfig.rpy?cmd=DISABLE&pluginname=" + pname + "&pluginline="
+ lineno
+ makeRequest(url , pname)
+}
+
+
+function FilterListPlugin() {
+ var grpfilter,statfilter;
+
+ grpfilter = document.getElementById('grpfilter').value;
+ statfilter = document.getElementById('statfilter').value;
+
+ window.location = 'pluginconfig.rpy?filterlist=' + grpfilter +
"&pluginfilter=" + statfilter
+}
+
+function UpdateStatus(hRequest,cname) {
+ var cell;
+
+ if (hRequest.readyState == 4) {
+ if (hRequest.status == 200) {
+ cell = ""
+// alert(hRequest.responseText)
+ } else {
+
+ alert('There was a problem with the request.');
+ }
+ }
+}
+
+function makeRequest(url,cname) {
+ var httpRequest;
+
+ if (window.XMLHttpRequest) { // Mozilla, Safari, ...
+ httpRequest = new XMLHttpRequest();
+ if (httpRequest.overrideMimeType) {
+ httpRequest.overrideMimeType('text/xml');
+ }
+ }
+ else if (window.ActiveXObject) { // IE
+ try {
+ httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
+ }
+ catch (e) {
+ try {
+ httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ catch (e) {}
+ }
+ }
+
+ if (!httpRequest) {
+ alert('Giving up :( Cannot create an XMLHTTP instance');
+ return false;
+ }
+ httpRequest.onreadystatechange = function() {
UpdateStatus(httpRequest,cname); };
+ httpRequest.open('GET', url, true);
+ httpRequest.send('');
+}
+
+function SaveValue(sname) {
+ // Get the Value from the text box.
+ var svalue,tb,chk,updateurl,strenable;
+ var startline,endline;
+
+ tb = document.getElementById(sname + "_tb")
+ chk = document.getElementById(sname + "_chk")
+ startline = document.getElementById(sname + "_startline").value
+ endline = document.getElementById(sname + "_endline").value
+ svalue = tb.value
+ strenable = "FALSE"
+ if (chk.checked)
+ strenable = "TRUE"
+ updateurl = 'config.rpy?update=TRUE&udname=' + sname + '&udvalue=' +
svalue + '&udenable=' + strenable
+ updateurl = updateurl + "&startline=" + startline + '&endline=' + endline
+
+ makeRequest(updateurl,sname);
+}
+
+function DeleteValue(sname) {
+ // Get the Value from the text box.
+ var svalue,tb,chk,updateurl,strenable;
+ var startline,endline;
+
+ startline = document.getElementById(sname + "_startline").value
+ endline = document.getElementById(sname + "_endline").value
+ svalue = tb.value
+ strenable = "FALSE"
+ if (chk.checked)
+ strenable = "TRUE"
+ updateurl = 'config.rpy?delete=TRUE&startline=' + startline + '&endline='
+ endline
+// makeRequest(updateurl);
+}
Added: branches/rel-1/freevo/src/www/htdocs/scripts/viewlogfile.js
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/www/htdocs/scripts/viewlogfile.js Tue Sep 25
14:01:52 2007
@@ -0,0 +1,94 @@
+if (document.images){
+ var parselimit=2
+}
+
+function UpdateDelay() {
+ parselimit=document.forms[0].delayamount.value
+}
+
+function UpdateDisplay() {
+ var cellObj,displayfile;
+
+ cellObj = document.getElementById("refresh");
+ cellObj.childNodes[0].nodeValue="Updating";
+ parselimit=document.forms[0].delayamount.value
+ displayfile = document.getElementById("logfile").value;
+ numlines = document.getElementById("numlines").value;
+ makeRequest('viewlogfile.rpy?update=TRUE&displayfile=' + displayfile +
"&rows=" + numlines);
+}
+
+function beginrefresh(){
+ var cellObj,displayfile;
+
+ if (!document.images)
+ return
+
+ if (parselimit==1) {
+ UpdateDisplay();
+ parselimit=document.forms[0].delayamount.value
+ setTimeout("beginrefresh()",1000);
+ }
+ else{
+ parselimit-=1
+ cellObj = document.getElementById("refresh");
+ cellObj.childNodes[0].nodeValue="Refresh In : " + parselimit;
+ curmin=Math.floor(parselimit/60)
+ cursec=parselimit%60
+ if (curmin!=0)
+ curtime=curmin+" minutes and "+cursec+" seconds left until page
refresh!"
+ else
+ curtime=cursec+" seconds left until page refresh!"
+ window.status=curtime
+ setTimeout("beginrefresh()",1000)
+ }
+}
+window.onload=beginrefresh
+
+function makeRequest(url) {
+ var httpRequest;
+
+ if (window.XMLHttpRequest) { // Mozilla, Safari, ...
+ httpRequest = new XMLHttpRequest();
+ if (httpRequest.overrideMimeType) {
+ httpRequest.overrideMimeType('text/xml');
+ }
+ }
+ else if (window.ActiveXObject) { // IE
+ try {
+ httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
+ }
+ catch (e) {
+ try {
+ httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ catch (e) {}
+ }
+ }
+
+ if (!httpRequest) {
+ alert('Giving up :( Cannot create an XMLHTTP instance');
+ return false;
+ }
+ httpRequest.onreadystatechange = function() { UpdateTable(httpRequest); };
+ httpRequest.open('GET', url, true);
+ httpRequest.send('');
+
+}
+
+function UpdateTable(httpRequest) {
+ var filelist,logfile,winWidth,winHeight,loffset,toffset,nWidth,nHeight;
+
+ nodls = true;
+ if (httpRequest.readyState == 4) {
+ if (httpRequest.status == 200) {
+ logfile = document.getElementById("loglines");
+ logfile.value = httpRequest.responseText;
+ } else {
+ alert('There was a problem with the request.');
+ }
+ }
+}
+
+
+
+
Modified: branches/rel-1/freevo/src/www/htdocs/scripts/youtube.js
==============================================================================
--- branches/rel-1/freevo/src/www/htdocs/scripts/youtube.js (original)
+++ branches/rel-1/freevo/src/www/htdocs/scripts/youtube.js Tue Sep 25
14:01:52 2007
@@ -1,21 +1,22 @@
-//enter refresh time in "minutes:seconds" Minutes should range from 0 to
inifinity. Seconds should range from 0 to 59'
-//var limit="0:10"
if (document.images){
- var parselimit=5
+ var parselimit=2
}
function beginrefresh(){
if (!document.images)
return
+
+ cellObj = document.getElementById("refresh");
if (parselimit==1) {
- document.refreshForm.visited.value = "-1";
+
+ cellObj.childNodes[0].nodeValue="Updating";
+ parselimit=60
makeRequest('youtube.rpy?xml=1');
- parselimit=5
setTimeout("beginrefresh()",1000)
}
else{
parselimit-=1
- document.refreshForm.visited.value = parselimit
+ cellObj.childNodes[0].nodeValue="Refresh In : " + parselimit;
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
if (curmin!=0)
@@ -35,7 +36,6 @@
httpRequest = new XMLHttpRequest();
if (httpRequest.overrideMimeType) {
httpRequest.overrideMimeType('text/xml');
- // See note below about this line
}
}
else if (window.ActiveXObject) { // IE
@@ -54,7 +54,7 @@
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
- httpRequest.onreadystatechange = function() { alertContents(httpRequest);
};
+ httpRequest.onreadystatechange = function() { UpdateTable(httpRequest); };
httpRequest.open('GET', url, true);
httpRequest.send('');
@@ -64,6 +64,8 @@
var tbl,lastrow,newrow,cellLeft;
var textNode;
+ var pickLink,pickText
+
tbl = document.getElementById("filelist")
lastrow = tbl.rows.length;
newrow = tbl.insertRow(lastrow);
@@ -71,15 +73,26 @@
newrow.className = "chanrow"
cellLeft = newrow.insertCell(0);
- textNode = document.createTextNode("Delete");
- cellLeft.appendChild(textNode);
+ delLink=document.createElement('a');
+ pickText=document.createTextNode('delete');
+ delLink.appendChild(pickText);
+ delLink.setAttribute('href','youtube.rpy?Delete=1&file=' + file);
+ cellLeft.appendChild(delLink);
cellLeft.className = "basic"
cellLeft = newrow.insertCell(1);
- textNode = document.createTextNode(file);
- cellLeft.appendChild(textNode);
+ delLink=document.createElement('a');
+ pickText=document.createTextNode(file);
+ delLink.appendChild(pickText);
+ delLink.setAttribute('href','youtube.rpy?playfile=' + file);
+ cellLeft.appendChild(delLink);
cellLeft.className = "basic"
+// cellLeft = newrow.insertCell(1);
+// textNode = document.createTextNode(file);
+// cellLeft.appendChild(textNode);
+// cellLeft.className = "basic"
+
cellLeft = newrow.insertCell(2);
textNode = document.createTextNode(percent);
cellLeft.appendChild(textNode);
@@ -109,14 +122,12 @@
cellLeft.appendChild(textNode);
cellLeft.id = file + ".ETA"
cellLeft.className = "basic"
-
- lastrow = tbl.rows.length;
}
function RemoveRows(lfiles) {
var tbl,r,cnt,rfile,fnd,xfile ;
+
tbl = document.getElementById("filelist");
-
for (r=1; r < tbl.rows.length; r++) {
rfile = tbl.rows[r].id
fnd = 0
@@ -128,20 +139,27 @@
j = lfiles.childNodes.length
}
}
+
if (fnd == 0) {
fnd = 1;
tbl.deleteRow(r);
- //alert("Delete Row - " + rfile);
}
cnt = 0;
}
-
}
-function alertContents(httpRequest) {
- var j,cellObj;
+function UpdateCell(cellname,value) {
+ var cellObj;
+
+ cellObj = document.getElementById(cellname);
+ cellObj.childNodes[0].nodeValue=value;
+}
+
+function UpdateTable(httpRequest) {
+ var j,cellObj,nodls;
var cfile,filename,percent,amtdone,filesize,speed,eta;
+ nodls = true;
if (httpRequest.readyState == 4) {
if (httpRequest.status == 200) {
@@ -155,25 +173,22 @@
filesize = cfile.childNodes[3].firstChild.nodeValue;
speed = cfile.childNodes[4].firstChild.nodeValue;
eta = cfile.childNodes[5].firstChild.nodeValue;
+ if (amtdone != "done") {
+ parselimit = 10;
+ }
// Check to see if a table row exists for the file.
- cellObj = document.getElementById(filename + ".FILESIZE");
+ cellObj = document.getElementById(filename);
if (cellObj == null) {
- TableAddRow(filename,filesize,percent,amtdone,speed,eta)
+ TableAddRow(filename,filesize,percent,amtdone,speed,eta)
}
else {
- cellObj = document.getElementById(filename + ".FILESIZE");
- cellObj.childNodes[0].nodeValue=filesize;
- cellObj = document.getElementById(filename + ".PERCENT");
- cellObj.childNodes[0].nodeValue=percent;
- cellObj = document.getElementById(filename + ".SOFAR");
- cellObj.childNodes[0].nodeValue=amtdone;
- cellObj = document.getElementById(filename + ".SPEED");
- cellObj.childNodes[0].nodeValue=speed;
- cellObj = document.getElementById(filename + ".ETA");
- cellObj.childNodes[0].nodeValue=eta;
- }
-
+ UpdateCell(filename + ".FILESIZE",filesize)
+ UpdateCell(filename + ".PERCENT",percent)
+ UpdateCell(filename + ".SOFAR",amtdone)
+ UpdateCell(filename + ".SPEED",speed)
+ UpdateCell(filename + ".ETA",eta)
+ }
}
RemoveRows(filelist);
} else {
Added: branches/rel-1/freevo/src/www/htdocs/viewlogfile.rpy
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/www/htdocs/viewlogfile.rpy Tue Sep 25
14:01:52 2007
@@ -0,0 +1,145 @@
+#! /usr/bin/python
+# -----------------------------------------------------------------------
+# plugins.rpy - Show all plugins
+# -----------------------------------------------------------------------
+# $Id$
+#
+# Notes:
+# Todo:
+#
+# -----------------------------------------------------------------------
+# Freevo - A Home Theater PC framework
+# Copyright (C) 2002 Krister Lagerstrom, et al.
+# Please see the file freevo/Docs/CREDITS for a complete list of authors.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
+# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 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
+#
+# -----------------------------------------------------------------------
+
+import sys, time
+
+from www.web_types import HTMLResource, FreevoResource
+import util, config
+import os
+from plugin import is_active
+from helpers.plugins import parse_plugins
+from helpers.plugins import info_html
+
+TRUE = 1
+FALSE = 0
+
+def ReadFile(file,numberlines = 40):
+# print "READING FILE = %s Number lines = %i" % ( file , numberlines )
+ lconf_hld = open(file,"r")
+ retlines = lconf_hld.readlines()[numberlines * -1:]
+
+ rlines = ""
+ retlines.reverse()
+ for ln in retlines:
+ rlines += ln
+
+ return rlines
+
+def CreateListBox(cname,grps,cvalue,opts):
+ ctrl = '\n<select name="%s" value="" id="%s" %s>' % ( cname , cname, opts
)
+
+ for grp in grps:
+ if grp == cvalue:
+ ctrl += '\n <option value="' + grp + '" selected="yes">' + grp
+ '</option>'
+ else:
+ ctrl += '\n <option value="' + grp + '">' + grp + '</option>'
+ ctrl += '\n</select>'
+ return ctrl
+
+def GetLogFiles():
+ filelist = os.listdir( config.LOGDIR)
+ for l in filelist:
+ if not l.endswith(".log"):
+ filelist.remove(l)
+ return filelist
+
+def addPageRefresh():
+ style = 'style="z-index:100; position:absolute; top:150px; a"'
+ style = ""
+ prhtml = '<script
type="text/JavaScript">window.onload=beginrefresh</script>'
+ prhtml += '\n<div class="searchform" id="refresh" %s
align="Center">Refresh In : ??</div>' % style
+ return prhtml
+
+
+class ViewLogFileResource(FreevoResource):
+
+ def _render(self, request):
+
+ fv = HTMLResource()
+ form = request.args
+ dfile = fv.formValue(form,"displayfile")
+# print "LOG FILE = %s " % dfile
+ if not dfile:
+ dfile = 'webserver-0.log'
+
+ dfile = config.LOGDIR + "/" + dfile
+ update = fv.formValue(form,"update")
+ rows = fv.formValue(form,"rows")
+# print update
+ if not rows:
+ rows = '20'
+ rows = int(rows)
+
+ if update:
+ fv.res = ReadFile(dfile,rows)
+ return String( fv.res )
+
+ autorefresh = fv.formValue(form,"autorefresh")
+ if not autorefresh:
+ autorefresh = ""
+ autorefresh = "checked"
+
+ numlines = fv.formValue(form,"numlines")
+ if not numlines:
+ numlines = 20
+
+ delayamount = fv.formValue(form,"delayamount")
+ if not delayamount:
+ delayamount = 9999
+
+ fv.printHeader(_('viewlog'),
'styles/main.css','scripts/viewlogfile.js',selected=_('View Logs'))
+
+ fv.res += '\n<div class="searchform" align="left"><br>'
+ fv.res += '\n<div align="left">'
+ fv.res += '\n<form id="form1" name="form1" action="viewlogfile.rpy"
method="get">'
+ fv.res += '<br>'
+
+ logfiles = GetLogFiles()
+ opts = 'onchange="UpdateDisplay()"'
+ fv.res += "Log File : " +
CreateListBox("logfile",logfiles,dfile,opts)
+# fv.res += '<input type="submit" value="View File">'
+ fv.res += '<input type="textbox" name="delayamount" id="delayamount"
value="%s" size="3" onchange="UpdateDelay()"> Refresh Delay' % delayamount
+ fv.res += '<input type="textbox" name="numlines" id="numlines"
value="%s" size="3" onchange="UpdateDisplay()"> Number Lines' % numlines
+# fv.res += '<input type=checkbox name="autorefresh" id="autorefresh"
%s> Auto Refresh' % autorefresh
+ fv.res += addPageRefresh()
+ fv.res += "</form>"
+
+ style = 'style="z-index:100; left:1%; width: 95%; height: 50%;
position:absolute; top:220px; bottom:2%; padding: 2px;"'
+ fv.res += '<br><textarea id="loglines" name="loglines" rows = %i
cols=120 wrap="OFF" READONLY %s ></textarea>' % ( rows , style )
+
+# fv.res += '</form>'
+ fv.res += '</div>\n'
+ fv.res += '</div>\n'
+ fv.res += '<br><br>'
+ fv.printFooter()
+
+ return String( fv.res )
+
+resource = ViewLogFileResource()
Modified: branches/rel-1/freevo/src/www/htdocs/youtube.rpy
==============================================================================
--- branches/rel-1/freevo/src/www/htdocs/youtube.rpy (original)
+++ branches/rel-1/freevo/src/www/htdocs/youtube.rpy Tue Sep 25 14:01:52 2007
@@ -32,44 +32,39 @@
from www.web_types import HTMLResource, FreevoResource
from urllib import urlopen
from getopt import getopt
-
-print "CONFIG====="
-print (config)
+from stat import *
def xmlStatus(fstatus):
- xmlstatus = ""
+ xmlstatus = ""
xmlstatus += "<PERCENT>" + fstatus['percent'] + "</PERCENT>"
xmlstatus += "<DOWNLOADED>" + fstatus['downloaded'] + "</DOWNLOADED>"
xmlstatus += "<FILESIZE>" + fstatus['filesize'] + "</FILESIZE>"
xmlstatus += "<SPEED>" + fstatus['speed'] + "</SPEED>"
xmlstatus += "<ETA>" + fstatus['eta'] + "</ETA>"
-
return xmlstatus
# Get optimum 1k exponent to represent a number of bytes
def optimum_k_exp(num_bytes):
- const_1k = 1024
- if num_bytes == 0:
- return 0
- return long(math.log(num_bytes, const_1k))
-
+ const_1k = 1024
+ if num_bytes == 0:
+ return 0
+ return long(math.log(num_bytes, const_1k))
# Get optimum representation of number of bytes
def format_bytes(num_bytes):
- const_1k = 1024
- try:
- exp = optimum_k_exp(num_bytes)
- suffix = 'bkMGTPEZY'[exp]
- if exp == 0:
- return '%s%s' % (num_bytes, suffix)
- converted = float(num_bytes) / float(const_1k**exp)
- return '%.2f%s' % (converted, suffix)
- except IndexError:
- return "Error"
-
+ const_1k = 1024
+ try:
+ exp = optimum_k_exp(num_bytes)
+ suffix = 'bkMGTPEZY'[exp]
+ if exp == 0:
+ return '%s%s' % (num_bytes, suffix)
+ converted = float(num_bytes) / float(const_1k**exp)
+ return '%.2f%s' % (converted, suffix)
+ except IndexError:
+ return "Error"
def getStatus(ytfile):
- fileStatus = {'percent': '--.-%', 'downloaded': 'done' , 'filesize':
'DONE' ,'speed' : '--', 'eta' : '--:--'}
+ fileStatus = {'percent': '-', 'downloaded': 'done' , 'filesize': 'done'
,'speed' : '--', 'eta' : '--:--'}
fileStatus['filesize'] = format_bytes(os.path.getsize(config.YOUTUBE_DIR +
ytfile))
logfile = config.YOUTUBE_DIR + ".tmp/" + os.path.splitext(ytfile)[0] +
".log"
if os.path.exists(logfile):
@@ -88,7 +83,7 @@
fileStatus['percent'] = "NA"
fileStatus['downloaded'] = "NA"
fileStatus['speed'] = "NA"
- fileStatus['eta'] = "Unknown"
+ fileStatus['eta'] = "Unknown"
except Exception, e:
fileStatus['percent'] = "NA"
fileStatus['downloaded'] = "NA"
@@ -97,30 +92,28 @@
return fileStatus
-def getXML():
-
- dfiles = '<?xml version="1.0" encoding="ISO-8859-1" ?>'
- dfiles += '<FILELIST>'
- enablerefresh = False
+def getXML():
+ filesXML = '<?xml version="1.0" encoding="ISO-8859-1" ?>'
+ filesXML += '<FILELIST>'
filelist = os.listdir(config.YOUTUBE_DIR)
filelist.sort()
for fl in filelist :
- if fl != ".tmp" and fl != "folder.fxd" :
+ fstat = os.stat(config.YOUTUBE_DIR + fl)[ST_MODE]
+ isdir = S_ISDIR(fstat)
+ if not isdir and fl != "folder.fxd" :
# check for log file.
- dfiles += '<FILE id="' + fl + '">'
- dfiles += '<FILENAME>' + fl + '</FILENAME>'
+ filesXML += '<FILE id="' + fl + '">'
+ filesXML += '<FILENAME>' + fl + '</FILENAME>'
fstats = getStatus(fl)
- dfiles += xmlStatus(fstats)
- dfiles += '</FILE>'
- dfiles += "</FILELIST>"
- retdfile = []
- retdfile.append(dfiles)
- retdfile.append(enablerefresh)
- return retdfile
+ filesXML += xmlStatus(fstats)
+ filesXML += '</FILE>'
+ filesXML += "</FILELIST>"
+ return filesXML
+
+def displaytableheader():
+ fvhtml = HTMLResource()
-def displayfiles(fvhtml):
- fvhtml.res += ''
fvhtml.tableOpen('class="library" id="filelist"')
fvhtml.tableRowOpen('class="chanrow"')
fvhtml.tableCell('Current Downloads','class ="guidehead" colspan="2"')
@@ -130,178 +123,151 @@
fvhtml.tableCell('Speed','class ="guidehead" colspan="1"')
fvhtml.tableCell('ETA','class ="guidehead" colspan="1"')
fvhtml.tableRowClose()
-
- enablerefresh = False
-
- filelist = os.listdir(config.YOUTUBE_DIR)
- filelist.sort()
- for fl in filelist :
-
- # check to see if the file is currently being downloaded.
- if fl != ".tmp" and fl != "folder.fxd" :
-
- # check for log file.
- flstatus = getStatus(fl)
- fvhtml.tableRowOpen('class="chanrow" colspan="1" id="'+fl +'"')
- fvhtml.tableCell('<a href="youtube.rpy?Delete=1&file=' + fl +
'">DELETE</a>','class="basic" colspan="1"')
- fvhtml.tableCell(fl,'class="basic" colspan="1"')
- fvhtml.tableCell(flstatus['percent'],'class="basic" colspan="1"
id="' + fl + '.PERCENT"')
- fvhtml.tableCell(flstatus['downloaded'],'class="basic" colspan="1"
id = "' + fl + '.SOFAR"')
- fvhtml.tableCell(flstatus['filesize'],'class="basic" colspan="1"
id="' + fl + '.FILESIZE"')
- fvhtml.tableCell(flstatus['speed'],'class="basic" colspan="1"
id="' + fl + '.SPEED"')
- fvhtml.tableCell(flstatus['eta'],'class="basic" colspan="1" id="'
+ fl + '.ETA"')
- fvhtml.tableRowClose()
-
fvhtml.tableClose()
- retdfile = []
- retdfile.append(fvhtml.res)
- retdfile.append(enablerefresh)
- return retdfile
-
+ return fvhtml.res
def CleanupLogFiles():
logfiles = os.listdir(config.YOUTUBE_DIR + ".tmp/")
-
for lfile in logfiles:
# Check to see if the movie file exists.
vfile = config.YOUTUBE_DIR + os.path.splitext(lfile)[0] + ".flv"
if not os.path.exists(vfile):
os.remove(config.YOUTUBE_DIR + ".tmp/" + lfile)
-
-def download_youtube(yt_url, yt_out):
-
- stime = time.localtime()
- cmd = "python " + config.YOUTUBE_DL + " -t " + yt_url
+def startdownload(dlcommand,logfile):
pwdcur = os.getcwd()
os.chdir(config.YOUTUBE_DIR)
-
- # get the file name from the url.
- logfile = config.YOUTUBE_DIR + ".tmp/" + yt_url.split("=")[-1] + ".log"
- ytpid = 0
lfile = open (logfile, "w")
- ytpid =
subprocess.Popen((config.YOUTUBE_DL,"-t",yt_url),universal_newlines=True,stdout=lfile).pid
+ ytpid =
subprocess.Popen(dlcommand,universal_newlines=True,stdout=lfile).pid
os.chdir(pwdcur)
- dlstatus = "<br><br>Starting download of " + yt_url + " <br>"
- dlstatus = dlstatus + '<input type="text" name="pid" size="40" value="' +
str(ytpid) + '" />'
-
- return dlstatus
-def download_url(dl_url, dl_out):
-
- stime = time.localtime()
- cmd = "python " + config.DOWNLOAD_DL + " " + dl_url
- pwdcur = os.getcwd()
- os.chdir(config.YOUTUBE_DIR)
+def download_youtube(yt_url):
+ logfile = config.YOUTUBE_DIR + ".tmp/" + yt_url.split("=")[-1] + ".log"
+ startdownload((config.YOUTUBE_DL,"-t",yt_url),logfile)
+
+def download_url(dl_url):
# get the file name from the url.
logfile = config.YOUTUBE_DIR + ".tmp/partfile" + dl_url.split("/")[-1]
logfile = os.path.splitext(logfile)[0] + ".log"
- ytpid = 0
- lfile = open (logfile, "w")
- ytpid =
subprocess.Popen((config.DOWNLOAD_DL,dl_url),universal_newlines=True,stdout=lfile).pid
- os.chdir(pwdcur)
- dlstatus = ""
-
- return dlstatus
-
-
+ startdownload((config.DOWNLOAD_DL,dl_url),logfile)
+
def addPageRefresh():
-
prhtml = '<script type="text/JavaScript"
src="scripts/youtube.js">window.onload=beginrefresh</script>'
- prhtml += '\n<form name="refreshForm">'
- prhtml += '\n <div class="searchform"><br><b>Refresh In :</b>'
- prhtml += '\n <input type="text" name="visited" value="1" size="4"
align="middle" />'
- prhtml += '\n </div>'
- prhtml += '\n</form><br>'
+ prhtml += '\n<div class="searchform" id="refresh">Refresh In : ??</div>'
return prhtml
+def envCheck():
+ yterrors = []
+ if (not config.__dict__.has_key('YOUTUBE_DIR')):
+ yterrors.append('Unable to Find YOUTUDE_DIR setting in local_conf.py')
+ yterrors.append('Add YOUTUBE_DIR = "Directory to Save Downloads." to
your local_conf.py')
+ config.YOUTUBE_DIR = "MISSING"
+
+ if (not config.__dict__.has_key('YOUTUBE_DL')):
+ yterrors.append('Unable to Find YOUTUDE_DL setting in local_conf.py')
+ yterrors.append('Add YOUTUBE_DL = "Path to youtube-dl script" to your
local_conf.py')
+ config.YOUTUBE_DL = "MISSING"
+
+ if (not config.__dict__.has_key('DOWNLOAD_DL')):
+ yterrors.append('Unable to Find DOWNLOAD_DL setting in local_conf.py')
+ yterrors.append('Add DOWNLOAD_DL = "Path to downloadurl.py script" to
your local_conf.py')
+ config.DOWNLOAD_DL = "MISSING"
+ return yterrors
+
+def doFlowPlayer(pfile):
+ flash = '\n<br><br><script type="text/javascript"
src="flowplayer/swfobject.js"></script>'
+ flash += '\n<div align="center" id="flowplayerholder">'
+ flash += '\nThis will be replaced by the player. '
+ flash += '\n</div>'
+ flash += '\n<script type="text/javascript">'
+ flash += '\n// <![CDATA['
+ flash += '\nvar fo = new SWFObject("flowplayer/FlowPlayerThermo.swf",
"FlowPlayer", "468", "350", "7", "#ffffff", true);'
+ flash += '\n// need this next line for local testing, its optional if your
swf is on the same domain as your html page'
+ flash += '\nfo.addParam("allowScriptAccess", "always");'
+ flash += '\nfo.addVariable("config", "{ showPlayListButtons: true,
playList: [ {overlayId: \'play\' },'
+ flash += ' { url: \'http://archserve/youtube/'+ pfile + '\' } ],
initialScale: \'fit\' }");'
+ flash += '\nfo.write("flowplayerholder");'
+ flash += '\n// ]]>'
+ flash += '\n</script>'
+ return flash
class YouTubeResource(FreevoResource):
def _render(self, request):
- fv = HTMLResource()
- form = request.args
+ fv = HTMLResource()
+ form = request.args
- blxml = fv.formValue(form,"xml")
- if blxml :
- fdisplay = getXML()
- fv.res += fdisplay[0]
- return String( fv.res )
-
- fv.printHeader(_('YouTube'), 'styles/main.css',selected=_('YouTube'))
-
- yterrors = []
- if (not config.__dict__.has_key('YOUTUBE_DIR')):
- yterrors.append('Unable to Find YOUTUDE_DIR setting in
local_conf.py')
- yterrors.append('Add YOUTUBE_DIR = "Directory to Save Downloads."
to your local_conf.py')
- config.YOUTUBE_DIR = "MISSING"
- if (not config.__dict__.has_key('YOUTUBE_DL')):
- yterrors.append('Unable to Find YOUTUDE_DL setting in
local_conf.py')
- yterrors.append('Add YOUTUBE_DL = "Path to youtube-dl script" to
your local_conf.py')
- config.YOUTUBE_DL = "MISSING"
- if (not config.__dict__.has_key('DOWNLOAD_DL')):
- yterrors.append('Unable to Find DOWNLOAD_DL setting in
local_conf.py')
- yterrors.append('Add DOWNLOAD_DL = "Path to downloadurl.py script"
to your local_conf.py')
- config.DOWNLOAD_DL = "MISSING"
-
- if len(yterrors) > 0:
- fv.printMessages(yterrors)
- return String( fv.res )
-
-
- fldelete = fv.formValue(form,'Delete')
- if fldelete:
- filename = fv.formValue(form,'file')
+ blxml = fv.formValue(form,"xml")
+ if blxml :
+ fv.res = getXML()
+ #fv.res += fdisplay[0]
+ return String( fv.res )
+
+ fv.printHeader(_('YouTube'), 'styles/main.css',selected=_('YouTube'))
+ yterrors = envCheck()
+
+ playfile = fv.formValue(form,"playfile")
+ if playfile:
+ fv.res += doFlowPlayer(playfile)
+
+ if config.YOUTUBE_DIR == "MISSING" or ((config.YOUTUBE_DL ==
"MISSING") and (config.DOWNLOAD_DL == "MISSING")):
+ fv.printMessages(yterrors)
+ return String( fv.res )
+
+ if not os.path.exists(config.YOUTUBE_DIR):
+ fv.res += '<br><b>Unable to locate youtube download location "' +
config.YOUTUBE_DIR + '" </b><br>'
+ fv.res += 'Add YOUTUBE_DIR = "download directory" to your
local_conf.py'
+
+ if not os.path.exists(config.YOUTUBE_DL):
+ fv.res += '<br><br><br><b>Unable to locate youtube-dl script "' +
config.YOUTUBE_DL + '" </b><br>'
+ fv.res += 'Download scripts from <a
href="http://www.arrakis.es/~rggi3/youtube-dl/">http://www.arrakis.es/~rggi3/youtube-dl/</a>'
+ fv.res += '<br>Add YOUTUBE_DL = "path and file name to youtube_dl
script"<br>'
+
+ if not os.path.exists(config.DOWNLOAD_DL):
+ fv.res += '<br><b>Unable to locate downloadurl.py script "' +
config.YOUTUBE_DL + '" </b><br>'
+ fv.res += 'Download scripts from <a
href="http://www.arrakis.es/~rggi3/youtube-dl/">http://www.arrakis.es/~rggi3/youtube-dl/</a>'
+ fv.res += '<br>Add YOUTUBE_DL = "path and file name to youtube_dl
script"<br><br>'
+
+ if os.path.exists(config.YOUTUBE_DIR):
+ if not os.path.exists(config.YOUTUBE_DIR + ".tmp"):
+ os.mkdir(config.YOUTUBE_DIR + ".tmp")
+
+ fldelete = fv.formValue(form,'Delete')
+ if fldelete:
+ filename = fv.formValue(form,'file')
if filename:
filename = config.YOUTUBE_DIR + filename
if os.path.exists(filename):
- os.remove(filename)
- fv.res += "DELETED FILE - " + filename
+ os.remove(filename)
+ fv.res += "DELETED FILE - " + filename
- yturl = ""
- if not os.path.exists(config.YOUTUBE_DL):
- fv.res += '<br><br><br><b>Unable to locate youtube-dl script "' +
config.YOUTUBE_DL + '" </b><br>'
- fv.res += 'Download scripts from <a
href="http://www.arrakis.es/~rggi3/youtube-dl/">http://www.arrakis.es/~rggi3/youtube-dl/</a>'
- fv.res += '<br>Add YOUTUBE_DL = "path and file name to youtube_dl
script"<br>'
- else:
- fv.res += '\n<br><form id="YouTube Download" action="youtube.rpy"
method="get">'
- fv.res += '\n<div class="searchform"><br><b>Youtube URL
:</b><input type="text" name="yt_url" size="40" value="' + yturl + '" />'
- fv.res += '\n<input type="submit" value=" Download! " />'
- fv.res += '\n</div>'
- fv.res += '\n</form>'
-
- yturl = fv.formValue(form,'yt_url')
- if yturl :
- yt_status = str(download_youtube(yturl,""))
- refreshon = True
-
- if not os.path.exists(config.YOUTUBE_DIR):
- fv.res += '<br><b>Unable to locate youtube download location "' +
config.YOUTUBE_DIR + '" </b><br>'
- fv.res += 'Add YOUTUBE_DIR = "download directory" to your
local_conf.py'
-
-
- if os.path.exists(config.YOUTUBE_DIR):
- if not os.path.exists(config.YOUTUBE_DIR + ".tmp"):
- os.mkdir(config.YOUTUBE_DIR + ".tmp")
-
- dlurl = fv.formValue(form,'dl_url')
- if dlurl :
- dl_status = download_url(dlurl,"")
- fv.res += "<br>" + dl_status
- refreshon = True
-
- dlurl = ""
- fv.res += '\n<form id="Url Download" action="youtube.rpy"
method="get">'
- fv.res += '\n <div class="searchform"><br><b>Download URL :</b>'
- fv.res += '\n <input type="text" name="dl_url" size="40"
value="' + dlurl + '" />'
- fv.res += '\n <input type="submit" value=" Download! " />'
- fv.res += '\n </div>'
- fv.res += '\n</form><br>\n'
+ dlurl = ""
+ fv.res += '\n<br><form id="Url Download" action="youtube.rpy"
method="get">'
+ fv.res += '\n <div class="searchform"><br><b>Download URL :</b>'
+ fv.res += '\n <input type="text" name="dl_url" size="40"
value="' + dlurl + '" />'
+ fv.res += '\n <select name="dlscript" value="downloadurl">'
+ fv.res += '\n <option value="youtube">Youtube</option>'
+ fv.res += '\n <option value="downloadurl">Donwload
Url</option>'
+ fv.res += '\ </select>'
+ fv.res += '\n <input type="submit" value=" Download! " />'
+ fv.res += '\n </div>'
+ fv.res += '\n</form><br>\n'
+
+ dltype = fv.formValue(form,'dlscript')
+ dlurl = fv.formValue(form,'dl_url')
+ if dltype and dlurl:
+ if dltype == "youtube":
+ download_youtube(dlurl)
+ if dltype == "downloadurl":
+ download_url(dlurl)
- fdisplay = displayfiles(fv)
- fv.res += addPageRefresh()
+ fv.res += displaytableheader()
+ fv.res += addPageRefresh()
- return String( fv.res )
+# fv.res += '<object width="425" height="350"><param name="movie"
value="http://www.youtube.com/v/grCTXGW3sxQ"></param><param name="wmode"
value="transparent"></param><embed src="http://www.youtube.com/v/grCTXGW3sxQ"
type="application/x-shockwave-flash" wmode="transparent" width="425"
height="350"></embed></object>'
+
+ return String( fv.res )
resource = YouTubeResource()
+
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog