/usr/share/freevo/htdocs/genre.rpy is in freevo 1.9.2b2-4.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | # -*- coding: iso-8859-1 -*-
# vim:autoindent:tabstop=4:softtabstop=4:shiftwidth=4:expandtab:filetype=python:
# -----------------------------------------------------------------------
# Show what is on for today for a particular category
# -----------------------------------------------------------------------
# $Id: genre.rpy 11322 2009-02-19 17:59:44Z duncan $
#
# 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, string
import config
import util
from www.web_types import HTMLResource, FreevoResource, RecordClientResource
import tv.epg_xmltv
TRUE = 1
FALSE = 0
class GenreResource(FreevoResource):
def __init__(self):
self.recordclient = RecordClientResource()
# need sub to get list of possible categories
def makecategorybox(self, categories, category):
retval = u'<select name="category">\n'
category = Unicode( category )
for cat in categories:
cat = Unicode( cat )
retval += u'<option value="%s" ' % cat
if cat == category:
retval += u'selected="selected"'
retval += u'>%s</option>\n' % cat
retval += u'</select>\n'
return retval
def _render(self, request):
fv = HTMLResource()
form = request.args
server_available = self.recordclient().pingNow()
if not server_available:
fv.printHeader(_('TV Genre for %s') % time.strftime('%a %b %d', time.localtime(mfrguidestart)), \
config.WWW_STYLESHEET, config.WWW_JAVASCRIPT)
fv.printMessagesFinish(['<b>'+_('ERROR')+'</b>: '+self.recordclient().recordserverdown])
return String(fv.res)
mfrguidestart = time.time()
mfrguideinput = fv.formValue(form, 'stime')
if mfrguideinput:
mfrguidestart = int(mfrguideinput)
# a little before midnight the day of mfrguidestart
myt_t=time.localtime(mfrguidestart)
mfrnextguide=time.mktime((myt_t[0], myt_t[1], myt_t[2], 23, 59, 5, myt_t[6], myt_t[7], -1))
# a little after midnight the day before mfrguidestart
mfrprevguide=time.mktime((myt_t[0], myt_t[1], myt_t[2]-1, 0, 0, 5, myt_t[6], myt_t[7], -1))
# kill mfrprevguide to zero if it is less than now
if mfrprevguide < time.time():
now_t = time.localtime(time.time())
newmyt2 = myt_t[2]-1
if (myt_t[0] == now_t[0] and myt_t[1] == now_t[1] and newmyt2 == now_t[2]):
mfrprevguide = time.time()
else:
mfrprevguide = 0
category = fv.formValue(form, 'category')
guide = tv.epg_xmltv.get_guide()
(status, schedule) = self.recordclient().getScheduledRecordingsNow()
if not status:
fv.printMessagesFinish(['<b>'+_('ERROR')+'</b>: '+_('No program schedule')])
return String(fv.res)
allcategories = []
for chan in guide.chan_list:
for prog in chan.programs:
if prog.categories:
allcategories.extend(prog.categories)
if allcategories:
allcategories=util.unique(allcategories)
allcategories.sort()
stime=''
if mfrguideinput:
stime='<input name="stime" type="hidden" value="%i"/>' % int(mfrguideinput)
keepcat = ''
if category:
keepcat = '&category=%s' % category
bforcell=''
acelltime=mfrnextguide + 60
aftercell=(' <a href="genre.rpy?stime=%i%s">'
+'<img src="images/RightArrow.png" alt="right" border="0"/></a>') \
% (acelltime, keepcat)
if mfrprevguide > 0:
bforcell=('<a href="genre.rpy?stime=%i%s">'
+'<img src="images/LeftArrow.png" alt="left" border="0"/></a> ') \
% (mfrprevguide, keepcat)
fv.tableOpen('border="0" cellpadding="4" cellspacing="1" width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('<form action="">'+bforcell+_('Show')+' '+_('Category')+': '\
+self.makecategorybox(allcategories, category)+stime+'<input type="submit" value="'+_('Change')+'"/>'\
+aftercell+'</form>', 'class="guidehead"')
fv.tableRowClose()
fv.tableClose()
if not category:
fv.printSearchForm()
fv.printLinks()
fv.printFooter()
return String(fv.res)
fv.tableOpen('border="0" cellpadding="4" cellspacing="1" width="100%"')
fv.tableRowOpen('class="chanrow"')
fv.tableCell('Channel', 'class="guidehead"')
fv.tableCell('Program', 'class="guidehead"')
fv.tableCell('Start', 'class="guidehead"')
fv.tableCell('Stop', 'class="guidehead"')
fv.tableRowClose()
desc = ''
gotdata = 0
for chan in guide.chan_list:
for prog in chan.programs:
if prog.stop > mfrguidestart and prog.start < mfrnextguide:
status = 'program'
# match the category
if category not in prog.categories:
continue
# figure out if in progress
# use counter to see if we have data
gotdata += 1
(result, reason) = self.recordclient().isProgScheduledNow(prog, schedule)
if result:
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'
fv.tableRowOpen('class="chanrow"')
fv.tableCell(chan.displayname, 'class="channel"')
popid = '%s:%s' % (prog.channel_id, prog.start)
fv.tableCell(prog.title+' - '+prog.desc, 'class="'+status+'" \
onclick="guide_click(this, event)" id="%s" width="80%%"' % popid )
fv.tableCell(time.strftime('%H:%M', time.localtime(prog.start)), 'class="channel"')
fv.tableCell(time.strftime('%H:%M', time.localtime(prog.stop)), 'class="channel"')
fv.tableRowClose()
if gotdata == 0:
fv.tableRowOpen('class="chanrow"')
fv.tableCell('<center>'+_('NO SHOWS MATCHING CATEGORY')+'</center>', 'class="utilhead" colspan="4"')
fv.tableRowClose()
fv.tableClose()
fv.printSearchForm()
fv.printLinks()
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" </tr>\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 = GenreResource()
|