Update of /cvsroot/freevo/freevo/src/www
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9973
Modified Files:
base.py server.py
Added Files:
guide.py proginfo.py rec.py
Log Message:
Reactivating web guide and scheduling recordings, this is still a major work
in progress and there are still missing pieces.
Index: base.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/www/base.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** base.py 18 Dec 2004 18:18:39 -0000 1.2
--- base.py 28 Dec 2004 00:38:45 -0000 1.3
***************
*** 10,13 ****
--- 10,17 ----
# -----------------------------------------------------------------------
# $Log$
+ # Revision 1.3 2004/12/28 00:38:45 rshortt
+ # Reactivating web guide and scheduling recordings, this is still a major work
+ # in progress and there are still missing pieces.
+ #
# Revision 1.2 2004/12/18 18:18:39 dischi
# small update, still not working
***************
*** 133,138 ****
items = [(_('Home'),_('Home'),'%sindex' % str(strprefix)),
! # (_('TV Guide'),_('View TV Listings'),'%sguide.rpy' %
str(strprefix)),
! # (_('Scheduled Recordings'),_('View Scheduled
Recordings'),'%srecord.rpy' % str(strprefix)),
# (_('Favorites'),_('View Favorites'),'%sfavorites.rpy' %
str(strprefix)),
# (_('Media Library'),_('View Media
Library'),'%slibrary.rpy' % str(strprefix)),
--- 137,142 ----
items = [(_('Home'),_('Home'),'%sindex' % str(strprefix)),
! (_('TV Guide'),_('View TV Listings'),'%sguide' %
str(strprefix)),
! (_('Scheduled Recordings'),_('View Scheduled
Recordings'),'%srec' % str(strprefix)),
# (_('Favorites'),_('View Favorites'),'%sfavorites.rpy' %
str(strprefix)),
# (_('Media Library'),_('View Media
Library'),'%slibrary.rpy' % str(strprefix)),
--- NEW FILE: guide.py ---
#!/usr/bin/python
#if 0 /*
# -----------------------------------------------------------------------
# guide.rpy - Web interface to the Freevo EPG.
# -----------------------------------------------------------------------
# $Id: guide.py,v 1.1 2004/12/28 00:38:45 rshortt Exp $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# $Log: guide.py,v $
# Revision 1.1 2004/12/28 00:38:45 rshortt
# Reactivating web guide and scheduling recordings, this is still a major work
# in progress and there are still missing pieces.
#
# Revision 1.30 2004/08/14 01:30:21 rshortt
# Change guide access a bit.
#
# Revision 1.29 2004/08/14 01:23:30 rshortt
# Use the chanlist/epg from cache.
#
# Revision 1.28 2004/08/10 16:02:39 rshortt
# Remove comma from between tag attributes.
#
# Revision 1.27 2004/08/10 12:54:22 outlyer
# An impressive update to the guide code from Jason Tackaberry that
# dramatically speeds up rendering and navigation of the guide. I will be
# applying this patch to future 1.5.x Debian packages, but I'm not applying
# it to 1.5 branch of CVS unless people really want it.
#
# Revision 1.26 2004/08/08 19:07:55 rshortt
# Use tv_util to cache the guide.
#
# Revision 1.25 2004/03/12 03:05:50 outlyer
# Use the episode title where available.
#
# Revision 1.24 2004/02/23 08:33:21 gsbarbieri
# i18n: help translators job.
#
# Revision 1.23 2004/02/22 06:25:15 gsbarbieri
# Fix bugs introduced by i18n changes.
#
# Revision 1.22 2004/02/19 04:57:59 gsbarbieri
# Support Web Interface i18n.
# To use this, I need to get the gettext() translations in unicode, so some
changes are required to files that use "print _('string')", need to make them
"print String(_('string'))".
#
# Revision 1.21 2004/02/09 21:37:43 outlyer
# Removed the rounded edges I was trying for the guide; they don't work
# consistently and look very ugly in some browsers. I'll have to rethink
# them.
#
# Revision 1.20 2004/02/09 21:23:42 outlyer
# New web interface...
#
# * Removed as much of the embedded design as possible, 99% is in CSS now
# * Converted most tags to XHTML 1.0 standard
# * Changed layout tables into CSS; content tables are still there
# * Respect the user configuration on time display
# * Added lots of "placeholder" tags so the design can be altered pretty
# substantially without touching the code. (This means using
# span/div/etc. where possible and using 'display: none' if it's not in
# _my_ design, but might be used by someone else.
# * Converted graphical arrows into HTML arrows
# * Many minor cosmetic changes
#
# Revision 1.19 2003/10/20 02:24:17 rshortt
# more tv_util fixes
#
# Revision 1.18 2003/09/07 18:50:56 dischi
# make description shorter if it's too long
#
# Revision 1.17 2003/09/07 01:02:13 gsbarbieri
# Fixed a bug in guide that appeared with the new PRECISION thing.
#
# Revision 1.16 2003/09/06 22:58:13 mikeruelle
# fix something i don't think sould have a gap
#
# -----------------------------------------------------------------------
# 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, string
import time
import config
import logging
from www.base import HTMLResource, FreevoResource
import util.tv_util as tv_util
import util
import config
import record.client
import pyepg
# get logging object
log = logging.getLogger('www')
class GuideResource(FreevoResource):
def makecategorybox(self, chanlist):
allcategories = []
for chan in chanlist:
for prog in chan.epg.programs:
if prog.categories:
allcategories.extend(prog.categories)
if allcategories:
allcategories=util.unique(allcategories)
allcategories.sort()
else:
return ''
retval = '<select name="category">' + "\n"
for cat in allcategories:
retval += '<option value="%s" ' % cat
retval += '>%s' % cat
retval += "\n"
retval += '</select>' + "\n"
return retval
def maketimejumpboxday(self, gstart):
retval='<select name="day">\n'
myt = time.time()
myt_t = time.localtime(myt)
gstart_t = time.localtime(gstart)
myt = time.mktime((myt_t[0], myt_t[1], myt_t[2], 0, 0, 5,
myt_t[6], myt_t[7], -1))
# listh = tv_util.when_listings_expire()
listh = 0
if listh == 0:
return retval + '</select>\n'
listd = int((listh/24)+2)
for i in range(1, listd):
retval += '<option value="' + str(myt) + '"'
myt_t = time.localtime(myt)
if (myt_t[0] == gstart_t[0] and \
myt_t[1] == gstart_t[1] and \
myt_t[2] == gstart_t[2]):
retval += ' SELECTED '
retval += '>' + time.strftime('%a %b %d', myt_t) + '\n'
myt += 60*60*24
retval += '</select>\n'
return retval
def maketimejumpboxoffset(self, gstart):
retval = '<select name="offset">\n'
myt = gstart
myt_t = time.localtime(myt)
hrstart = time.mktime((myt_t[0], myt_t[1], myt_t[2], 0, 0, 5,
myt_t[6], myt_t[7], -1))
hrinc = hrstart
hrstop = hrstart + (60*60*24)
while (hrinc < hrstop):
myoff = hrinc - hrstart
retval += '<option value="' + str(myoff) + '"'
if (abs(gstart - hrinc) < 60):
retval += ' SELECTED '
retval += '>' + time.strftime(config.TV_TIMEFORMAT,
time.localtime(hrinc)) + '\n'
hrinc += config.WWW_GUIDE_INTERVAL * 60
retval += '</select>\n'
return retval
def _render(self, request):
fv = HTMLResource()
log.debug(dir(request))
form = request.query
INTERVAL = config.WWW_GUIDE_INTERVAL * 60
PRECISION = config.WWW_GUIDE_PRECISION * 60
cpb = INTERVAL / PRECISION # cols per block/interval
n_cols = config.WWW_GUIDE_COLS
mfrguidestart = time.time()
mfrguideinput = form.get('stime')
mfrguideinputday = form.get('day')
mfrguideinputoff = form.get('offset')
if mfrguideinput:
mfrguidestart = int(mfrguideinput)
elif mfrguideinputday and mfrguideinputoff:
mfrguidestart = float(mfrguideinputday) + float(mfrguideinputoff)
now = int(mfrguidestart / INTERVAL) * INTERVAL
now2 = int(time.time() / INTERVAL) * INTERVAL
mfrnextguide = now + INTERVAL * n_cols
mfrnextguide += 10
mfrprevguide = now - INTERVAL * n_cols
mfrprevguide += 10
if mfrprevguide < now2:
mfrprevguide = 0
# (got_schedule, schedule) = ri.getScheduledRecordings()
got_schedule = False
schedule = 'no schedule'
if got_schedule:
schedule = schedule.getProgramList()
fv.printHeader(_('TV Guide'), config.WWW_STYLESHEET,
config.WWW_JAVASCRIPT, selected=_('TV Guide'))
fv.res += '<div id="content">\n';
fv.res += ' <br/>\n'
if not got_schedule:
fv.printMessages(
[ '<b>'+_('ERROR')+'</b>: '+_('Recording server is
unavailable.') ]
)
desc = ''
fv.tableOpen()
fv.tableRowOpen('class="chanrow"')
fv.tableCell('<form>'+_('Time')+': ' +
self.maketimejumpboxday(now) + self.maketimejumpboxoffset(now) + '<input
type=submit value="'+_('View')+'"></form>', 'class="utilhead"')
# categorybox = self.makecategorybox(get_channels().get_all())
categorybox = 0
if categorybox:
fv.tableCell('<form
action="genre">'+_('Show')+' '+_('Category')+': '+categorybox+'<input
type=submit value="'+_('Change')+'"></form>', 'class="utilhead"')
fv.tableRowClose()
fv.tableClose()
fv.tableOpen('id="guide" cols=\"%d\"' % \
( n_cols*cpb + 1 ) )
showheader = 0
# for chan in get_channels().get_all():
for chan in pyepg.channels:
#chan = chan.epg
#put guidehead every X rows
if showheader % 15 == 0:
fv.tableRowOpen('class="chanrow"')
headerstart = int(mfrguidestart / INTERVAL) * INTERVAL
fv.tableCell(time.strftime('%b %d',
time.localtime(headerstart)), 'class="guidehead"')
for i in range(n_cols):
if i == n_cols-1 or i == 0:
dacell = ''
datime = time.strftime(config.TV_TIMEFORMAT,
time.localtime(headerstart))
if i == n_cols-1:
dacell = datime + ' <a
href="guide?stime=%i">»</a>' % mfrnextguide
else:
if mfrprevguide > 0:
dacell = '<a
href="guide?stime=%i">«</a> ' % mfrprevguide + datime
else:
dacell = datime
fv.tableCell(dacell, 'class="guidehead" colspan="%d"'
% cpb)
else:
fv.tableCell(time.strftime(config.TV_TIMEFORMAT,
time.localtime(headerstart)),
'class="guidehead" colspan="%d"' % cpb)
headerstart += INTERVAL
fv.tableRowClose()
showheader+= 1
rowdata = []
now = mfrguidestart
# chan.displayname = string.replace(chan.displayname, "&", "SUB")
rowdata.append(u'<tr class="chanrow">')
rowdata.append(u'<td class="channel">%s</td>' % chan.title)
c_left = n_cols * cpb
progs = chan[mfrguidestart:mfrnextguide]
if not len(progs):
rowdata.append(u'<td class="programnodata" colspan="%s">«
' % (n_cols*cpb) + _('This channel has no data loaded') + ' »' )
for prog in progs:
if prog.stop > mfrguidestart and \
prog.start < mfrnextguide and \
c_left > 0:
status = u'program'
if got_schedule:
# (result, message) = ri.isProgScheduled(prog, schedule)
result = False
message = 'no message'
if result:
status = u'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 = u'recording'
if prog.start <= now and prog.stop >= now:
cell = u''
if prog.start <= now - INTERVAL:
# show started earlier than the guide start,
# insert left arrows
cell += u'« '
showtime_left = int(prog.stop - now + ( now % INTERVAL
) )
intervals = showtime_left / PRECISION
colspan = intervals
# prog.title = string.replace(prog.title, "&", "SUB")
# prog.desc = string.replace(prog.desc, "&", "SUB")
cell += u'%s' % Unicode(prog.title)
if colspan > c_left:
# show extends past visible range,
# insert right arrows
cell += u' »'
colspan = c_left
popid = u'%s:%s' % (chan.id, prog.start)
style = u''
if colspan == n_cols * cpb:
style += u'text-align: center; '
rowdata.append(u'<td class="%s"
onclick="guide_click(this, event)" id="%s" colspan="%s" style="%s">%s</td>' %
(status, popid, colspan, style, cell))
now += colspan * PRECISION
c_left -= colspan
rowdata.append(u"</tr>")
fv.res += string.join(rowdata, u"\n")
fv.tableClose()
fv.printSearchForm()
fv.printLinks()
fv.res += '</div>'
fv.res += (
u"<div id=\"popup\" class=\"proginfo\" style=\"display:none\">\n"\
u"<div id=\"program-waiting\" style=\"background-color: #0B1C52;
position: absolute\">\n"\
u" <br /><b>Fetching program information ...</b>\n"\
u"</div>\n"\
u" <table id=\"program-info\" class=\"popup\">\n"\
u" <thead>\n"\
u" <tr>\n"\
u" <td id=\"program-title\">\n"\
u" </td>\n"\
u" </tr>\n"\
u" </thead>\n"\
u" <tbody>\n"\
u" <tr>\n"\
u" <td class=\"progdesc\" id=\"program-desc\">\n"\
u" </td>\n"\
u" </tr>\n"\
u" <tr>\n"\
u" <td class=\"progtime\">\n"\
u" <b>"+_('Start')+u":</b> <span
id=\"program-start\"></span>, \n"\
u" <b>"+_('Stop')+u":</b> <span
id=\"program-end\"></span>, \n"\
u" <b>"+_('Runtime')+u":</b> <span
id=\"program-runtime\"></span> min\n"\
u" </td>\n"\
u" </td>\n"\
u" </tbody>\n"\
u" <tfoot>\n"\
u" <tr>\n"\
u" <td>\n"\
u" <table class=\"popupbuttons\">\n"\
u" <tbody>\n"\
u" <tr>\n"\
u" <td id=\"program-record-button\">\n"\
u" "+_('Record')+u"\n"\
u" </td>\n"\
u" <td id=\"program-favorites-button\">\n"\
u" "+_('Add to Favorites')+u"\n"\
u" </td>\n"\
u" <td
onclick=\"program_popup_close();\">\n"\
u" "+_('Close Window')+u"\n"\
u" </td>\n"\
u" </tr>\n"\
u" </tbody>\n"\
u" </table>\n"\
u" </td>\n"\
u" </tr>\n"\
u" </tfoot>\n"\
u" </table>\n"\
u"</div>\n" )
fv.res += "<iframe id='hidden' style='visibility: hidden; width: 1px;
height: 1px'></iframe>\n"
fv.printFooter()
return String( fv.res )
resource = GuideResource()
--- NEW FILE: proginfo.py ---
#!/usr/bin/python
#if 0 /*
# -----------------------------------------------------------------------
# proginfo.rpy - Dynamically update program info popup box.
# -----------------------------------------------------------------------
# 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, string
import time
from www.base import HTMLResource, FreevoResource
import util
import config
import pyepg
MAX_DESCRIPTION_CHAR = 1000
class ProgInfoResource(FreevoResource):
def _render(self, request):
fv = HTMLResource()
form = request.query
id = form.get('id')
chanid = id[:id.find(":")]
starttime = int( id[id.find(":")+1:] )
chan = pyepg.guide.channel_dict.get(chanid)
if not chan:
fv.res += u'no such channel %s' % chanid
return String(fv.res)
prog = chan[starttime]
if prog.description == '':
desc = (_('Sorry, the program description for ' \
'%s is unavailable.')) % ('<b>'+prog.title+'</b>')
else:
desc = prog.description
desc = desc.lstrip()
if MAX_DESCRIPTION_CHAR and len(desc) > MAX_DESCRIPTION_CHAR:
desc=desc[:desc[:MAX_DESCRIPTION_CHAR].rfind('.')] + '. [...]'
if prog.subtitle:
desc = '"%s"<br/>%s' % (prog.subtitle, desc)
fv.res += (
u"<script>\n" \
u"var doc = parent.top.document;\n" \
u"doc.getElementById('program-title').innerHTML = '%s';\n"\
u"doc.getElementById('program-desc').innerHTML = '%s';\n"\
u"doc.getElementById('program-start').innerHTML = '%s';\n"
u"doc.getElementById('program-end').innerHTML = '%s';\n"\
u"doc.getElementById('program-runtime').innerHTML = '%s';\n"\
u"doc.getElementById('program-record-button').onclick = %s;\n"\
u"doc.getElementById('program-favorites-button').onclick = %s;\n"\
u"doc.getElementById('program-waiting').style.display = 'none';\n" \
u"doc.getElementById('program-info').style.visibility =
'visible';\n" \
u"</script>\n"
) % ( prog.title.replace("'", "\\'") , desc.replace("'", "\\'"),
time.strftime(config.TV_TIMEFORMAT,
time.localtime( prog.start ) ),
time.strftime(config.TV_TIMEFORMAT,
time.localtime( prog.stop ) ),
int( ( prog.stop - prog.start ) / 60 ),
"function() { doc.location=\"rec?chan=%s&start=%s&action=add\";
}" % (chanid, starttime),
"function() {
doc.location=\"edit_favorite?chan=%s&start=%s&action=add\"; }" % (chanid,
starttime),
)
return String( fv.res )
resource = ProgInfoResource()
Index: server.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/www/server.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** server.py 18 Dec 2004 20:07:07 -0000 1.6
--- server.py 28 Dec 2004 00:38:45 -0000 1.7
***************
*** 45,48 ****
--- 45,49 ----
import logging
+ import config
import notifier
import util.fsocket as fsocket
***************
*** 230,233 ****
--- 231,235 ----
self.socket.listen(5)
notifier.addSocket( self.socket, self.accept )
+ config.detect('channels')
--- NEW FILE: rec.py ---
#!/usr/bin/python
#if 0 /*
# -----------------------------------------------------------------------
# record.rpy - Web interface to your scheduled recordings.
# -----------------------------------------------------------------------
# $Id: rec.py,v 1.1 2004/12/28 00:38:45 rshortt Exp $
#
# Notes:
# Todo:
#
# -----------------------------------------------------------------------
# $Log: rec.py,v $
# Revision 1.1 2004/12/28 00:38:45 rshortt
# Reactivating web guide and scheduling recordings, this is still a major work
# in progress and there are still missing pieces.
#
# Revision 1.19 2004/08/23 00:15:29 rshortt
# Prevent crash if removing a program that has already ended.
#
# Revision 1.18 2004/08/04 13:26:46 outlyer
# Add "Search" to actions for scheduled recordings to find alternate airings
# of the program.
#
# Revision 1.17 2004/07/12 14:43:29 outlyer
# Remove some debugging information.
#
# Revision 1.16 2004/04/11 06:51:17 dischi
# unicode patch
#
# Revision 1.15 2004/03/12 03:05:50 outlyer
# Use the episode title where available.
#
# Revision 1.14 2004/03/04 15:23:36 rshortt
# I am pretty sure we should have %b %d in here, the configurable timestamp
doesn't really fit in here.
#
# Revision 1.13 2004/02/23 08:33:21 gsbarbieri
# i18n: help translators job.
#
# Revision 1.12 2004/02/22 23:36:49 gsbarbieri
# Now support listing of non-ascii names/descriptions.
# So far you can have manual recordings with non-ascii names, but no programs
# from the guide, since findProg() has problems with marmelade (twisted).
#
# Revision 1.11 2004/02/19 04:57:59 gsbarbieri
# Support Web Interface i18n.
# To use this, I need to get the gettext() translations in unicode, so some
changes are required to files that use "print _('string')", need to make them
"print String(_('string'))".
#
# Revision 1.10 2004/02/09 21:23:42 outlyer
# New web interface...
#
# * Removed as much of the embedded design as possible, 99% is in CSS now
# * Converted most tags to XHTML 1.0 standard
# * Changed layout tables into CSS; content tables are still there
# * Respect the user configuration on time display
# * Added lots of "placeholder" tags so the design can be altered pretty
# substantially without touching the code. (This means using
# span/div/etc. where possible and using 'display: none' if it's not in
# _my_ design, but might be used by someone else.
# * Converted graphical arrows into HTML arrows
# * Many minor cosmetic changes
#
# Revision 1.9 2003/10/20 02:24:18 rshortt
# more tv_util fixes
#
# Revision 1.8 2003/09/05 02:48:13 rshortt
# Removing src/tv and src/www from PYTHONPATH in the freevo script. Therefore
any module that was imported from src/tv/ or src/www that didn't have a leading
'tv.' or 'www.' needed it added. Also moved tv/tv.py to tv/tvmenu.py to avoid
namespace conflicts.
#
# Revision 1.7 2003/07/13 18:08:53 rshortt
# Change tv_util.get_chan_displayname() to accept channel_id instead of
# a TvProgram object and also use config.TV_CHANNELS when available, which
# is 99% of the time.
#
# Revision 1.6 2003/07/06 19:28:35 rshortt
# Now use tv_util.get_chan_displayname() to get each program's channel's
# definate display name.
#
# Revision 1.5 2003/05/22 21:33:24 outlyer
# Lots of cosmetic changes:
#
# o Moved the header/logo into web_types
# o Made the error messages all use <h4> instead of <h2> so they look the same
# o Removed most <hr> tags since they don't really mesh well with the light blue
# o Moved the title into the "status bar" under the logo
#
# Revision 1.4 2003/05/14 01:11:20 rshortt
# More error handling and notice if the record server is down.
#
# Revision 1.3 2003/05/14 00:18:56 rshortt
# Better error handling.
#
# Revision 1.2 2003/05/12 23:02:41 rshortt
# Adding HTTP BASIC Authentication. In order to use you must override WWW_USERS
# in local_conf.py. This does not work for directories yet.
#
# Revision 1.1 2003/05/11 22:48:21 rshortt
# Replacements for the cgi files to be used with the new webserver. These
# already use record_client / record_server.
#
#
#
# -----------------------------------------------------------------------
# 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 traceback
from record.client import recordings
from www.base import HTMLResource, FreevoResource
import config
import pyepg
class RecordResource(FreevoResource):
def _render(self, request):
fv = HTMLResource()
form = request.query
chan = form.get('chan')
#if isinstance( chan, str ):
# chan = Unicode( chan, 'latin-1' )
start = form.get('start')
action = form.get('action')
if not recordings.server:
fv.printHeader('Scheduled Recordings', 'styles/main.css')
fv.printMessagesFinish(
[ '<b>'+_('ERROR')+'</b>: '+_('Recording server is
unavailable.') ]
)
return String( fv.res )
if action == 'remove':
progs = recordings.list()
prog = None
for p in progs:
if start == '%s' % p.start and chan == '%s' % p.channel:
prog = what
if prog:
print 'want to remove prog: %s' % String(prog)
recordings.remove(prog.id)
elif action == 'add':
# (status, prog) = ri.findProg(chan, start)
# prog = pyepg.get_channel(chan)[start]
try:
prog = pyepg.get_channel(chan)[int(start)]
except:
fv.printHeader('Scheduled Recordings', 'styles/main.css')
fv.printMessagesFinish(
[ '<b>'+_('ERROR') + '</b>: ' + \
( _('No program found on %s at %s.')%\
( '<b>'+chan+'</b>',
'<b>'+time.strftime('%x %X',
time.localtime(int(start)))+\
'</b>'
)
)+\
( ' <i>(%s:%s)</i><br>%s' % (chan, start,
traceback.print_exc()) ) ] )
return String(fv.res)
recordings.schedule(prog)
progs = recordings.list()
# (status, favs) = ri.getFavorites()
fv.printHeader(_('Scheduled Recordings'), 'styles/main.css',
selected=_('Scheduled Recordings'))
fv.res += ' \n'
fv.tableOpen('')
fv.tableRowOpen('class="chanrow"')
fv.tableCell(_('Start Time'), 'class="guidehead" colspan="1"')
fv.tableCell(_('Stop Time'), 'class="guidehead" colspan="1"')
fv.tableCell(_('Channel'), 'class="guidehead" colspan="1"')
fv.tableCell(_('Title'), 'class="guidehead" colspan="1"')
fv.tableCell(_('Episode'),'class="guidehead" colspan="1"')
fv.tableCell(_('Program Description'), 'class="guidehead" colspan="1"')
fv.tableCell(_('Actions'), 'class="guidehead" colspan="1"')
fv.tableRowClose()
f = lambda a, b: cmp(a.start, b.start)
progs.sort(f)
for prog in progs:
p = pyepg.get_channel(prog.channel)[prog.start]
status = 'basic'
#(isFav, junk) = ri.isProgAFavorite(prog, favs)
#if isFav:
# 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 ' + config.TV_TIMEFORMAT,
time.localtime(p.start)), 'class="'+status+'" colspan="1"')
fv.tableCell(time.strftime('%b %d ' + config.TV_TIMEFORMAT,
time.localtime(p.stop)), 'class="'+status+'" colspan="1"')
chan = pyepg.get_channel(p.channel)
if not chan:
chan_name = _('UNKNOWN')
else:
chan_name = chan.name
fv.tableCell(chan_name, 'class="'+status+'" colspan="1"')
fv.tableCell(Unicode(p.title), 'class="'+status+'" colspan="1"')
#if p.sub_title == '':
# cell = ' '
#else:
# cell = Unicode(p.sub_title)
cell = ' '
fv.tableCell(cell,'class="'+status+'" colspan="1"')
# if p.desc == '':
if 1:
cell = _('Sorry, the program description for %s is
unavailable.') % ('<b>'+p.title+'</b>')
else:
cell = Unicode(p.desc)
fv.tableCell(cell, 'class="'+status+'" colspan="1"')
cell = ('<a href="rec?chan=%s&start=%s&action=remove"
title="Remove Scheduled Recording">'+_('Remove')+'</a>'+'<br/>' + '<a
href="search?find=%s" title="Search for other airings">' + _('Search') +
'</a>') % (p.channel.id, p.start, Unicode(p.title))
fv.tableCell(cell, 'class="'+status+'" colspan="1"')
fv.tableRowClose()
fv.tableClose()
fv.printSearchForm()
fv.printFooter()
return String( fv.res )
resource = RecordResource()
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog