Update of /cvsroot/freevo/freevo/src/www/htdocs2
In directory sc8-pr-cvs1:/tmp/cvs-serv30377
Added Files:
.cvsignore __init__.py edit_favorite.py favorites.py guide.py
library.py manualrecord.py record.py search.py
Log Message:
Test of the new internal python webserver.
--- NEW FILE: .cvsignore ---
*.pyc
--- NEW FILE: __init__.py ---
--- NEW FILE: edit_favorite.py ---
#!/usr/bin/python
#if 0 /*
# -----------------------------------------------------------------------
# edit_favorites.cgi - Web interface to edit your favorites.
# -----------------------------------------------------------------------
# $Id: edit_favorite.py,v 1.1 2003/02/28 17:51:54 krister Exp $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# $Log: edit_favorite.py,v $
# Revision 1.1 2003/02/28 17:51:54 krister
# Test of the new internal python webserver.
#
# Revision 1.3 2003/02/15 17:09:14 krister
# Bugfixes for channel number when recording, etc.
#
# Revision 1.2 2003/02/11 06:40:57 krister
# Applied Robs patch for std fileheaders.
#
#
# -----------------------------------------------------------------------
# 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
#
# ----------------------------------------------------------------------- */
#endif
import sys, cgi, time
import html_util as fv
import rec_interface as ri
import rec_favorites as rf
import rec_types
import epg_xmltv
TRUE = 1
FALSE = 0
def run_cgi():
form = cgi.FieldStorage()
chan = fv.formValue(form, 'chan')
start = fv.formValue(form, 'start')
action = fv.formValue(form, 'action')
name = fv.formValue(form, 'name')
prog = ri.findProg(chan, start)
if prog:
print 'PROG: %s' % prog
num_favorites = len(rf.getFavorites())
if action == 'add':
priority = num_favorites + 1
fav = rec_types.Favorite(prog.title, prog, TRUE, TRUE, TRUE, priority)
elif action == 'edit':
fav = rf.getFavorite(name)
else:
pass
guide = epg_xmltv.get_guide()
fv.printContentType()
fv.printHeader('Edit Favorite', 'styles/main.css')
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('<img src="images/logo_200x100.png">', 'align=left')
fv.tableCell('Edit Favorite', 'class="heading" align="left"')
fv.tableRowClose()
fv.tableClose()
print '<br><form name="editfavorite" method="GET" action="favorites.cgi">'
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('Name of favorite', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Program', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Channel', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Day of week', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Time of day', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Action', 'class="guidehead" align="center" colspan="1"')
fv.tableRowClose()
status = 'basic'
fv.tableRowOpen('class="chanrow"')
cell = '<input type="hidden" name="oldname" value="%s">' % fav.name
cell += '<input type="text" size=20 name="name" value="%s">' % fav.name
fv.tableCell(cell, 'class="'+status+'" align="center" colspan="1"')
cell = '<input type="hidden" name="title" value="%s">%s' % (fav.title, fav.title)
fv.tableCell(cell, 'class="'+status+'" align="center" colspan="1"')
cell = '\n<select name="chan" selected="%s">\n' % fav.channel_id
cell += ' <option value=ANY>ANY CHANNEL</option>\n'
i=1
for ch in guide.chan_list:
if ch.id == fav.channel_id:
chan_index = i
cell += ' <option value="%s">%s</option>\n' % (ch.id, ch.id)
i = i +1
cell += '</select>\n'
fv.tableCell(cell, 'class="'+status+'" align="center" colspan="1"')
cell = '\n<select name="dow">\n'
cell += """
<option value=ANY>ANY DAY</option>
<option value=0>Mon</option>
<option value=1>Tues</option>
<option value=2>Wed</option>
<option value=3>Thurs</option>
<option value=4>Fri</option>
<option value=5>Sat</option>
<option value=6>Sun</option>
</select>
"""
fv.tableCell(cell, 'class="'+status+'" align="center" colspan="1"')
cell = '\n<select name="mod" selected="%s">\n' % fav.mod
cell += """
<option value=ANY>ANY TIME</option>
<option value="0">12:00 AM</option>
<option value="30">12:30 AM</option>
<option value="60">1:00 AM</option>
<option value="90">1:30 AM</option>
<option value="120">2:00 AM</option>
<option value="150">2:30 AM</option>
<option value="180">3:00 AM</option>
<option value="210">3:30 AM</option>
<option value="240">4:00 AM</option>
<option value="270">4:30 AM</option>
<option value="300">5:00 AM</option>
<option value="330">5:30 AM</option>
<option value="360">6:00 AM</option>
<option value="390">6:30 AM</option>
<option value="420">7:00 AM</option>
<option value="450">7:30 AM</option>
<option value="480">8:00 AM</option>
<option value="510">8:30 AM</option>
<option value="540">9:00 AM</option>
<option value="570">9:30 AM</option>
<option value="600">10:00 AM</option>
<option value="630">10:30 AM</option>
<option value="660">11:00 AM</option>
<option value="690">11:30 AM</option>
<option value="720">12:00 PM</option>
<option value="750">12:30 PM</option>
<option value="780">1:00 PM</option>
<option value="810">1:30 PM</option>
<option value="840">2:00 PM</option>
<option value="870">2:30 PM</option>
<option value="900">3:00 PM</option>
<option value="930">3:30 PM</option>
<option value="960">4:00 PM</option>
<option value="990">4:30 PM</option>
<option value="1020">5:00 PM</option>
<option value="1050">5:30 PM</option>
<option value="1080">6:00 PM</option>
<option value="1110">6:30 PM</option>
<option value="1140">7:00 PM</option>
<option value="1170">7:30 PM</option>
<option value="1200">8:00 PM</option>
<option value="1230">8:30 PM</option>
<option value="1260">9:00 PM</option>
<option value="1290">9:30 PM</option>
<option value="1320">10:00 PM</option>
<option value="1350">10:30 PM</option>
<option value="1380">11:00 PM</option>
<option value="1410">11:30 PM</option>
</select>
"""
fv.tableCell(cell, 'class="'+status+'" align="center" colspan="1"')
# cell = '\n<select name="priority" selected="%s">\n' % fav.priority
# for i in range(num_favorites+1):
# cell += ' <option value="%s">%s</option>\n' % (i+1, i+1)
# cell += '</select>\n'
# fv.tableCell(cell, 'class="'+status+'" align="center" colspan="1"')
cell = '<input type="hidden" name="priority" value="%s">' % fav.priority
cell += '<input type="hidden" name="action" value="%s">' % action
cell += '<input type="submit" value="Save">'
fv.tableCell(cell, 'class="'+status+'" align="center" colspan="1"')
fv.tableRowClose()
fv.tableClose()
print '</form>'
print '<script language="JavaScript">'
if fav.channel_id == 'ANY':
print 'document.editfavorite.chan.options[0].selected=true'
else:
print 'document.editfavorite.chan.options[%s].selected=true' % chan_index
if fav.dow == 'ANY':
print 'document.editfavorite.dow.options[0].selected=true'
else:
print 'document.editfavorite.dow.options[(1+%s)].selected=true' % fav.dow
if fav.mod == 'ANY':
print 'document.editfavorite.mod.options[0].selected=true'
else:
mod_index = int(fav.mod)/30 + 1
print 'document.editfavorite.mod.options[%s].selected=true' % mod_index
print '</script>'
fv.printSearchForm()
fv.printLinks()
fv.printFooter()
--- NEW FILE: favorites.py ---
#!/usr/bin/python
#if 0 /*
# -----------------------------------------------------------------------
# favorites.cgi - Web interface to display your favorite programs.
# -----------------------------------------------------------------------
# $Id: favorites.py,v 1.1 2003/02/28 17:51:54 krister Exp $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# $Log: favorites.py,v $
# Revision 1.1 2003/02/28 17:51:54 krister
# Test of the new internal python webserver.
#
# Revision 1.2 2003/02/11 06:40:57 krister
# Applied Robs patch for std fileheaders.
#
#
# -----------------------------------------------------------------------
# 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
#
# ----------------------------------------------------------------------- */
#endif
import sys, cgi, time
import html_util as fv
import rec_interface as ri
import rec_favorites as rf
TRUE = 1
FALSE = 0
def run_cgi():
form = cgi.FieldStorage()
action = fv.formValue(form, 'action')
oldname = fv.formValue(form, 'oldname')
name = fv.formValue(form, 'name')
title = fv.formValue(form, 'title')
chan = fv.formValue(form, 'chan')
dow = fv.formValue(form, 'dow')
mod = fv.formValue(form, 'mod')
priority = fv.formValue(form, 'priority')
if action == 'remove':
rf.removeFavorite(name)
pass
elif action == 'add':
rf.addEditedFavorite(name, title, chan, dow, mod, priority)
pass
elif action == 'edit':
rf.removeFavorite(oldname)
rf.addEditedFavorite(name, title, chan, dow, mod, priority)
elif action == 'bump':
rf.adjustPriority(name, priority)
else:
pass
favorites = rf.getFavorites()
days = {
'0' : 'Monday',
'1' : 'Tuesday',
'2' : 'Wednesday',
'3' : 'Thursday',
'4' : 'Friday',
'5' : 'Saturday',
'6' : 'Sunday'
}
fv.printContentType()
fv.printHeader('Favorites', 'styles/main.css')
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('<img src="images/logo_200x100.png">', 'align=left')
fv.tableCell('Favorites', 'class="heading" align="left"')
fv.tableRowClose()
fv.tableClose()
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('Favorite Name', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Program', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Channel', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Day of week', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Time of day', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Actions', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Priority', 'class="guidehead" align="center" colspan="1"')
fv.tableRowClose()
f = lambda a, b: cmp(a.priority, b.priority)
favs = favorites.values()
favs.sort(f)
for fav in favs:
status = 'favorite'
fv.tableRowOpen('class="chanrow"')
fv.tableCell(fav.name, 'class="'+status+'" align="left" colspan="1"')
fv.tableCell(fav.title, 'class="'+status+'" align="left" colspan="1"')
fv.tableCell(fav.channel_id, 'class="'+status+'" align="left" colspan="1"')
if fav.dow != 'ANY':
# cell = time.strftime('%b %d %H:%M', time.localtime(fav.start))
cell = '%s' % days[fav.dow]
else:
cell = 'ANY'
fv.tableCell(cell, 'class="'+status+'" align="left" colspan="1"')
if fav.mod != 'ANY':
# cell = time.strftime('%b %d %H:%M', time.localtime(fav.start))
cell = '%s' % ri.minToTOD(fav.mod)
else:
cell = 'ANY'
fv.tableCell(cell, 'class="'+status+'" align="left" colspan="1"')
# cell = '<input type="hidden" name="action" value="%s">' % action
cell = '<a href="edit_favorite.cgi?action=edit&name=%s">Edit</a>, ' % fav.name
cell += '<a href="favorites.cgi?action=remove&name=%s">Remove</a>' % fav.name
fv.tableCell(cell, 'class="'+status+'" align="left" colspan="1"')
cell = ''
if favs.index(fav) != 0:
tmp_prio = int(fav.priority) - 1
cell += '<a
href="favorites.cgi?action=bump&name=%s&priority=-1">Higher</a>' % fav.name
if favs.index(fav) != 0 and favs.index(fav) != len(favs)-1:
cell += ' | '
if favs.index(fav) != len(favs)-1:
tmp_prio = int(fav.priority) + 1
cell += '<a href="favorites.cgi?action=bump&name=%s&priority=1">Lower</a>'
% fav.name
fv.tableCell(cell, 'class="'+status+'" align="left" colspan="1"')
fv.tableRowClose()
fv.tableClose()
fv.printSearchForm()
fv.printLinks()
fv.printFooter()
--- NEW FILE: guide.py ---
#!/home/krister/proj/freevo/freevo/freevo execute
#if 0 /*
# -----------------------------------------------------------------------
# guide.cgi - Web interface to the Freevo EPG.
# -----------------------------------------------------------------------
# $Id: guide.py,v 1.1 2003/02/28 17:51:54 krister Exp $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# $Log: guide.py,v $
# Revision 1.1 2003/02/28 17:51:54 krister
# Test of the new internal python webserver.
#
# Revision 1.2 2003/02/11 06:40:57 krister
# Applied Robs patch for std fileheaders.
#
#
# -----------------------------------------------------------------------
# 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
#
# ----------------------------------------------------------------------- */
#endif
import sys
import time
import html_util as fv
import web
import config
import xmltv
import epg_xmltv
import rec_interface as ri
import rec_favorites as rf
# Set to 1 for debug output
DEBUG = 0
TRUE = 1
FALSE = 0
def run_cgi():
INTERVAL = web.INTERVAL
n_cols = web.n_cols
guide = epg_xmltv.get_guide()
schedule = ri.getScheduledRecordings().getProgramList()
favs = rf.getFavorites()
fv.printContentType()
fv.printHeader('Freevo TV Guide', web.STYLESHEET, web.JAVASCRIPT)
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('<img src="images/logo_200x100.png">', 'align=left')
fv.tableCell('TV Guide', 'class="heading" align="left"')
fv.tableRowClose()
fv.tableClose()
print('<HR>\n')
pops = ''
desc = ''
fv.tableOpen('border=0 cellpadding=4 cellspacing=1')
fv.tableRowOpen('class="chanrow"')
fv.tableCell(time.strftime('%b %d'), 'class="guidehead"')
now = int(time.time() / INTERVAL) * INTERVAL
for i in range(n_cols):
fv.tableCell(time.strftime('%H:%M', time.localtime(now)), 'class="guidehead"')
now += INTERVAL
fv.tableRowClose()
for chan in guide.chan_list:
now = time.time()
fv.tableRowOpen('class="chanrow"')
fv.tableCell(chan.displayname, 'class="channel"')
c_left = n_cols
if not chan.programs:
fv.tableCell('<< NO DATA >>', 'class="program" colspan=%s' % n_cols)
for prog in chan.programs:
if c_left > 0:
status = 'program'
if ri.isProgScheduled(prog, schedule):
status = 'scheduled'
really_now = time.time()
if prog.start <= really_now and prog.stop >= really_now:
# in the future we should REALLY see if it is
# recording instead of just guessing
status = 'recording'
if prog.start <= now and prog.stop >= now:
cell = ""
if prog.start <= now - INTERVAL:
# show started earlier than the guide start,
# insert left arrows
cell += '<< '
showtime_left = int(prog.stop - now)
intervals = showtime_left / INTERVAL
colspan = intervals + 1
cell += '%s' % prog.title
if colspan > c_left:
# show extends past visible range,
# insert right arrows
cell += ' >>'
colspan = c_left
popid = '%s:%s' % (prog.channel_id, prog.start)
pops += '<div id="%s" class="proginfo" >\n' % popid
pops += ' <div class="move" onmouseover="focusPop(\'%s\');"
onmouseout="unfocusPop(\'%s\');" style="cursor:move">%s</div>\n' % (popid, popid,
prog.title)
if prog.desc == '':
desc = 'Sorry, the program description for "%s" is
unavailable.' % prog.title
else:
desc = prog.desc
pops += ' <div class="progdesc"><br><font
color=black>%s</font><br><br></div>\n' % desc
pops += ' <div class="poplinks" style="cursor:hand">\n'
pops += ' <table width="100%" border=0 cellpadding=4
cellspacing=0>\n'
pops += ' <tr>\n'
pops += ' <td class="popbottom" '
pops +=
'onClick="document.location=\'record.cgi?chan=%s&start=%s\'">Record</td>\n' %
(prog.channel_id, prog.start)
pops += ' <td class="popbottom" '
pops +=
'onClick="document.location=\'edit_favorite.cgi?chan=%s&start=%s&action=add\'">Add to
Favorites</td>\n' % (prog.channel_id, prog.start)
pops += ' <td class="popbottom" '
pops += 'onClick="javascript:closePop(\'%s\');">Close
Window</td>\n' % popid
pops += ' </tr>\n'
pops += ' </table>\n'
pops += ' </div>\n'
pops += '</div>\n'
fv.tableCell(cell, 'class="'+status+'" onclick="showPop(\'%s\',
this)" colspan=%s' % (popid, colspan))
now += INTERVAL*colspan
c_left -= colspan
fv.tableRowClose()
fv.tableClose()
print pops
fv.printSearchForm()
fv.printLinks()
fv.printFooter()
--- NEW FILE: library.py ---
#!/usr/bin/python
#if 0 /*
# -----------------------------------------------------------------------
# library.cgi - a script to display and modify your video library
# -----------------------------------------------------------------------
# $Id: library.py,v 1.1 2003/02/28 17:51:54 krister Exp $
#
# Notes:
# Todo:
# figure a way to know whether DIR_RECORD has a trailing slash and only
# add if required when replacing.
# human readable size rather than bytes from os
# -----------------------------------------------------------------------
# $Log: library.py,v $
# Revision 1.1 2003/02/28 17:51:54 krister
# Test of the new internal python webserver.
#
# Revision 1.3 2003/02/20 22:36:04 rshortt
# Fixed a crash where newfile was null.
#
# Revision 1.2 2003/02/20 22:12:26 rshortt
# Added a check in case the user doesn't input anything or clicks cancel.
#
# Revision 1.1 2003/02/20 21:48:13 rshortt
# New cgi contributed by Mike Ruelle. This lets you view files inside
# config.DIR_RECORD and let you rename or delete them.
#
#
# -----------------------------------------------------------------------
# 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
#
# ----------------------------------------------------------------------- */
#endif
import sys, cgi, os, string, urllib
import html_util as fv
import config
import util
TRUE = 1
FALSE = 0
def run_cgi():
form = cgi.FieldStorage()
action = fv.formValue(form, 'action')
action_file = fv.formValue(form, 'file')
action_newfile = fv.formValue(form, 'newfile')
#check to make sure no bad chars in action_file
fs_result = 0
bs_result = 0
if action_file:
fs_result = string.find(action_file, '/')
bs_result = string.find(action_file, '\\')
#do actions here
if bs_result == -1 and fs_result == -1:
file_loc = os.path.join(config.DIR_RECORD, action_file)
if os.path.isfile(file_loc):
if action == 'rename':
if action_newfile:
newfile_loc = os.path.join(config.DIR_RECORD, action_newfile)
if os.path.isfile(newfile_loc):
print '%s already exists file not renamed.' % newfile_loc
else:
print 'rename %s to %s' % (file_loc, newfile_loc)
os.rename(file_loc, newfile_loc)
else:
print 'Error: no newfile specified.'
elif action == 'delete':
print 'delete %s' % file_loc
os.unlink(file_loc)
else:
print '%s does not exist. no action taken.' % file_loc
else:
print 'I do not process names(%s) with slashes for security reasons.' %
action_file
# ok let's write the page
fv.printContentType()
fv.printHeader('Video Library', 'styles/main.css')
print '<script language="JavaScript"><!--'
print 'function renameFile(file) {'
print ' newfile=window.prompt("New name please.");'
print ' if(newfile == "" || newfile == null) return;'
print ' document.location="library.cgi?action=rename&file=" + escape(file) +
"&newfile=" + escape(newfile);'
print '}'
print '//--></script>'
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('<img src="images/logo_200x100.png">', 'align=left')
fv.tableCell('Video Library', 'class="heading" align="left"')
fv.tableRowClose()
fv.tableClose()
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('Name', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Size', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Actions', 'class="guidehead" align="center" colspan="1"')
fv.tableRowClose()
# loop over directory here
items = util.match_files(config.DIR_RECORD, config.SUFFIX_VIDEO_FILES)
for file in items:
#find size
len_file = os.stat(file)[6]
#chop dir from in front of file
file = string.replace(file, config.DIR_RECORD + '/', '')
fv.tableRowOpen('class="chanrow"')
fv.tableCell(file, 'class="basic" align="left" colspan="1"')
fv.tableCell(str(len_file), 'class="basic" align="left" colspan="1"')
file_esc = urllib.quote(file)
rename = '<a href="javascript:renameFile(\'%s\')">Rename</a>' % file_esc
delete = '<a href="library.cgi?action=delete&file=%s">Delete</a>' % file_esc
fv.tableCell(rename + ' ' + delete, 'class="basic" align="center"
colspan="1"')
fv.tableRowClose()
fv.tableClose()
fv.printSearchForm()
fv.printLinks()
fv.printFooter()
--- NEW FILE: manualrecord.py ---
#!/usr/bin/python
#if 0 /*
# -----------------------------------------------------------------------
# manualrecord.cgi - Web interface to manually schedule recordings.
# -----------------------------------------------------------------------
# $Id: manualrecord.py,v 1.1 2003/02/28 17:51:55 krister Exp $
#
# 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
#
# ----------------------------------------------------------------------- */
#endif
import sys, cgi, time
import html_util as fv
import epg_xmltv
import epg_types
import rec_interface as ri
TRUE = 1
FALSE = 0
# maxinum number of days we can record
MAXDAYS = 7
# minimum amount of time it would take cron to pick us up in seconds
# by default it is one minute plus a few seconds since the cron job
# runs every minute and to allow for processing time.
MINCRONPICKUP = 70
def run_cgi():
form = cgi.FieldStorage()
curtime_epoch = time.time()
curtime = time.localtime(curtime_epoch)
chan = fv.formValue(form, 'chan')
startmonth = fv.formValue(form, 'startmonth')
startday = fv.formValue(form, 'startday')
starthour = fv.formValue(form, 'starthour')
startminute = fv.formValue(form, 'startminute')
startyear = curtime[0]
stopmonth = fv.formValue(form, 'stopmonth')
stopday = fv.formValue(form, 'stopday')
stophour = fv.formValue(form, 'stophour')
stopminute = fv.formValue(form, 'stopminute')
stopyear = curtime[0]
currentmonth = curtime[1]
desc = fv.formValue(form, 'desc')
title = fv.formValue(form, 'title')
action = fv.formValue(form, 'action')
errormsg = ''
# look for action to do an add
if action:
if action == "add":
# handle the year wraparound
if int(stopmonth) < currentmonth:
stopyear = str(int(stopyear) + 1)
if int(startmonth) < currentmonth:
startyear = str(int(startyear) + 1)
# create utc second start time
starttime = time.mktime(time.strptime(str(startmonth)+" "+str(startday)+"
"+str(startyear)+" "+str(starthour)+":"+str(startminute)+":00",'%m %d %Y %H:%M:%S'))
# create utc stop time
stoptime = time.mktime(time.strptime(str(stopmonth)+" "+str(stopday)+"
"+str(stopyear)+" "+str(stophour)+":"+str(stopminute)+":00",'%m %d %Y %H:%M:%S'))
# so we don't record for more then maxdays (maxdays day * 24hr/day * 60
min/hr * 60 sec/min)
if abs(stoptime - starttime) < (MAXDAYS * 86400):
if starttime < stoptime:
if stoptime < curtime_epoch + MINCRONPICKUP:
errormsg = "Sorry, the stop time does not give enough time for
cron to pickup the change. Please set it to record for a few minutes longer."
else:
# assign attributes to object
prog = epg_types.TvProgram()
prog.channel_id = chan
if title:
prog.title = title
else:
prog.title = "Manual Recorded"
if desc:
prog.desc = desc
prog.start = starttime
prog.stop = stoptime
# use ri to add to schedule
ri.scheduleRecording(prog)
# redirect to record.cgi to show new program in schedule
print "Location: record.cgi\n\n"
else:
errormsg = "start time is not before stop time."
else:
errormsg = "Program would record for more than " + str(MAXDAYS) + "
day(s)!"
if errormsg or not action:
guide = epg_xmltv.get_guide()
channelselect = '<select name="chan">'
for ch in guide.chan_list:
channelselect = channelselect + '<option
value="'+ch.id+'">'+ch.tunerid+"\n"
channelselect = channelselect + "</select>\n"
#build some reusable date inputs
#month
monthselect = '<select name="%s" %s >'
months = [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep',
'Oct', 'Nov', 'Dec' ]
iter=1
for m in months:
if curtime[1] == iter:
monthselect = monthselect + '<option selected
value="'+str(iter)+'">'+m+"\n"
else:
monthselect = monthselect + '<option value="'+str(iter)+'">'+m+"\n"
iter = iter + 1
monthselect = monthselect + "</select>\n"
#day
dayselect = '<select name="%s" %s >'
iter=1
while iter < 31:
if curtime[2] == iter:
dayselect = dayselect + '<option selected
value="'+str(iter)+'">'+str(iter)+"\n"
else:
dayselect = dayselect + '<option value="'+str(iter)+'">'+str(iter)+"\n"
iter = iter + 1
dayselect = dayselect + "</select>\n"
#hour
hourselect = '<select name="%s" %s >'
iter=0
while iter < 24:
if curtime[3] == iter:
hourselect = hourselect + '<option selected
value="'+str(iter)+'">'+str(iter)+"\n"
else:
hourselect = hourselect + '<option
value="'+str(iter)+'">'+str(iter)+"\n"
iter = iter + 1
hourselect = hourselect + "</select>\n"
#minute
minuteselect = '<select name="%s" %s >'
iter=0
while iter < 60:
if (curtime[4] - (curtime[4] % 5)) == iter:
minuteselect = minuteselect + '<option selected
value="'+str(iter)+'">'+str(iter)+"\n"
else:
minuteselect = minuteselect + '<option
value="'+str(iter)+'">'+str(iter)+"\n"
iter = iter + 5
minuteselect = minuteselect + "</select>\n"
startcell = monthselect % ("startmonth",
'onChange="document.manrec.stopmonth.selectedIndex=document.manrec.startmonth.selectedIndex"')
startcell = startcell + dayselect % ("startday",
'onChange="document.manrec.stopday.selectedIndex=document.manrec.startday.selectedIndex"')
startcell = startcell + '@'
startcell = startcell + hourselect % ("starthour",
'onChange="document.manrec.stophour.selectedIndex=document.manrec.starthour.selectedIndex"')
startcell = startcell + ':'
startcell = startcell + minuteselect % ("startminute",
'onChange="document.manrec.stopminute.selectedIndex=document.manrec.startminute.selectedIndex"')
stopcell = monthselect % ("stopmonth", " ")
stopcell = stopcell + dayselect % ("stopday", " ")
stopcell = stopcell + '@'
stopcell = stopcell + hourselect % ("stophour", " ")
stopcell = stopcell + ':'
stopcell = stopcell + minuteselect % ("stopminute", " ")
#ok turn back on stdout now that we are ready to display page
fv.printContentType()
fv.printHeader('Manual Record', 'styles/main.css')
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('<img src="images/logo_200x100.png">', 'align=left')
fv.tableCell('Manual Record', 'class="heading" align="left"')
fv.tableRowClose()
fv.tableClose()
if errormsg:
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('Error Message', 'class="guidehead" align="center"
colspan="1"')
fv.tableRowClose()
fv.tableRowOpen('class="chanrow"')
fv.tableCell(errormsg, 'class="basic" align="center" colspan="1"')
fv.tableRowClose()
fv.tableClose()
print '<form name="manrec">'
print '<center>'
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('Channel', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Start Time', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Stop Time', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Title', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Program Description', 'class="guidehead" align="center"
colspan="1"')
fv.tableRowClose()
fv.tableRowOpen('class="chanrow"')
fv.tableCell(channelselect, 'class="basic" align="left" colspan="1"')
fv.tableCell(startcell, 'class="basic" align="left" colspan="1" nowrap')
fv.tableCell(stopcell, 'class="basic" align="left" colspan="1" nowrap')
fv.tableCell('<input name="title" size="20">', 'class="basic" align="left"
colspan="1"')
fv.tableCell('<textarea name="desc" rows="1" cols="20"
wrap="soft"></textarea>', 'class="basic" align="left" colspan="1"')
fv.tableRowClose()
fv.tableRowOpen('class="chanrow"')
fv.tableCell('<center><input type="hidden" name="action" value="add"><input
type="submit" value="Add to Recording Schedule"></center>', 'class="basic"
align="center" colspan="5"')
fv.tableRowClose()
fv.tableClose()
print '</center>'
print '</form>'
fv.printSearchForm()
fv.printLinks()
fv.printFooter()
--- NEW FILE: record.py ---
#!/usr/bin/python
#if 0 /*
# -----------------------------------------------------------------------
# record.cgi - Web interface to your scheduled recordings.
# -----------------------------------------------------------------------
# $Id: record.py,v 1.1 2003/02/28 17:51:55 krister Exp $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# $Log: record.py,v $
# Revision 1.1 2003/02/28 17:51:55 krister
# Test of the new internal python webserver.
#
# Revision 1.3 2003/02/26 01:08:04 rshortt
# Fixed a bug where it was often impossible to remove a manually scheduled recording.
#
# Revision 1.2 2003/02/11 06:40:57 krister
# Applied Robs patch for std fileheaders.
#
#
# -----------------------------------------------------------------------
# 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
#
# ----------------------------------------------------------------------- */
#endif
import sys, cgi, time
import html_util as fv
import rec_interface as ri
import rec_favorites as rf
TRUE = 1
FALSE = 0
def run_cgi():
form = cgi.FieldStorage()
chan = fv.formValue(form, 'chan')
start = fv.formValue(form, 'start')
action = fv.formValue(form, 'action')
if action == 'remove':
recordings = ri.getScheduledRecordings()
progs = recordings.getProgramList()
for what in progs.values():
if start == '%s' % what.start and chan == '%s' % what.channel_id:
prog = what
print 'want to remove prog: %s' % prog
ri.removeScheduledRecording(prog)
else:
prog = ri.findProg(chan, start)
ri.scheduleRecording(prog)
recordings = ri.getScheduledRecordings()
progs = recordings.getProgramList()
favs = rf.getFavorites()
fv.printContentType()
fv.printHeader('Scheduled Recordings', 'styles/main.css')
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('<img src="images/logo_200x100.png">', 'align=left')
fv.tableCell('Scheduled Recordings', 'class="heading" align="left"')
fv.tableRowClose()
fv.tableClose()
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('Start Time', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Stop Time', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Channel', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Title', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Program Description', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Actions', 'class="guidehead" align="center" colspan="1"')
fv.tableRowClose()
f = lambda a, b: cmp(a.start, b.start)
progl = progs.values()
progl.sort(f)
for prog in progl:
status = 'basic'
if rf.isProgAFavorite(prog, favs):
status = 'favorite'
try:
if prog.isRecording == TRUE:
status = 'recording'
except:
# sorry, have to pass without doing anything.
pass
fv.tableRowOpen('class="chanrow"')
fv.tableCell(time.strftime('%b %d %H:%M', time.localtime(prog.start)),
'class="'+status+'" align="left" colspan="1"')
fv.tableCell(time.strftime('%b %d %H:%M', time.localtime(prog.stop)),
'class="'+status+'" align="left" colspan="1"')
fv.tableCell(prog.channel_id, 'class="'+status+'" align="left" colspan="1"')
fv.tableCell(prog.title, 'class="'+status+'" align="left" colspan="1"')
if prog.desc == '':
cell = 'Sorry, the program description for "%s" is unavailable.' %
prog.title
else:
cell = prog.desc
fv.tableCell(cell, 'class="'+status+'" align="left" colspan="1"')
cell = '<a href="record.cgi?chan=%s&start=%s&action=remove">Remove</a>' %
(prog.channel_id, prog.start)
fv.tableCell(cell, 'class="'+status+'" align="left" colspan="1"')
fv.tableRowClose()
fv.tableClose()
fv.printSearchForm()
fv.printLinks()
fv.printFooter()
--- NEW FILE: search.py ---
#!/usr/bin/python
#if 0 /*
# -----------------------------------------------------------------------
# search.cgi - Web interface to search the Freevo EPG.
# -----------------------------------------------------------------------
# $Id: search.py,v 1.1 2003/02/28 17:51:55 krister Exp $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# $Log: search.py,v $
# Revision 1.1 2003/02/28 17:51:55 krister
# Test of the new internal python webserver.
#
# Revision 1.2 2003/02/11 06:40:57 krister
# Applied Robs patch for std fileheaders.
#
#
# -----------------------------------------------------------------------
# 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
#
# ----------------------------------------------------------------------- */
#endif
import sys, cgi, time
import html_util as fv
import rec_interface as ri
import rec_favorites as rf
TRUE = 1
FALSE = 0
def run_cgi():
form = cgi.FieldStorage()
find = fv.formValue(form, 'find')
progs = ri.findMatches(find)
favs = rf.getFavorites()
recordings = ri.getScheduledRecordings()
rec_progs = recordings.getProgramList()
fv.printContentType()
fv.printHeader('Search Results', 'styles/main.css')
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('<img src="images/logo_200x100.png">', 'align=left')
fv.tableCell('Search Results', 'class="heading" align="left"')
fv.tableRowClose()
fv.tableClose()
fv.tableOpen('border=0 cellpadding=4 cellspacing=1 width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('Start Time', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Stop Time', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Channel', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Title', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Program Description', 'class="guidehead" align="center" colspan="1"')
fv.tableCell('Actions', 'class="guidehead" align="center" colspan="1"')
fv.tableRowClose()
for prog in progs:
status = 'basic'
for rp in rec_progs.values():
if rp.start == prog.start and rp.channel_id == prog.channel_id:
status = 'scheduled'
try:
if rp.isRecording == TRUE:
status = 'recording'
except:
sys.stderr.write('isRecording not set')
if rf.isProgAFavorite(prog, favs):
status = 'favorite'
fv.tableRowOpen('class="chanrow"')
fv.tableCell(time.strftime('%b %d %H:%M', time.localtime(prog.start)),
'class="'+status+'" align="left" colspan="1"')
fv.tableCell(time.strftime('%b %d %H:%M', time.localtime(prog.stop)),
'class="'+status+'" align="left" colspan="1"')
fv.tableCell(prog.channel_id, 'class="'+status+'" align="left" colspan="1"')
fv.tableCell(prog.title, 'class="'+status+'" align="left" colspan="1"')
if prog.desc == '':
cell = 'Sorry, the program description for "%s" is unavailable.' %
prog.title
else:
cell = prog.desc
fv.tableCell(cell, 'class="'+status+'" align="left" colspan="1"')
if status == 'scheduled':
cell = '<a href="record.cgi?chan=%s&start=%s&action=remove">Remove</a>' %
(prog.channel_id, prog.start)
elif status == 'recording':
cell = '<a href="record.cgi?chan=%s&start=%s">Record</a>' %
(prog.channel_id, prog.start)
else:
cell = '<a href="record.cgi?chan=%s&start=%s">Record</a>' %
(prog.channel_id, prog.start)
cell += ' | <a href="edit_favorite.cgi?chan=%s&start=%s&action=add">New
favorite</a>' % (prog.channel_id, prog.start)
fv.tableCell(cell, 'class="'+status+'" align="left" colspan="1"')
fv.tableRowClose()
fv.tableClose()
fv.printSearchForm()
fv.printLinks()
fv.printFooter()
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog