Author: rshortt
Date: Mon Mar 13 19:51:15 2006
New Revision: 8086

Modified:
   trunk/webserver/src/base.py
   trunk/webserver/src/pages/guide.py
   trunk/webserver/src/pages/proginfo.py
   trunk/webserver/src/pages/recordings.py
   trunk/webserver/src/pages/search.py

Log:
kaa.epg2 changes


Modified: trunk/webserver/src/base.py
==============================================================================
--- trunk/webserver/src/base.py (original)
+++ trunk/webserver/src/base.py Mon Mar 13 19:51:15 2006
@@ -155,7 +155,7 @@
         self.res += '</body>\n</html>\n'
 
 
-    def printSearchForm(self):
+    def printSearchForm(self, form=None):
         self.res += """
     <form id="SearchForm" action="search" method="get">
     <div class="searchform"><b>"""+_('Search')+""":</b>
@@ -166,26 +166,48 @@
     </form>
     """
 
-    def printAdvancedSearchForm(self):
+    def printAdvancedSearchForm(self, form=None):
+        from freevo.ipc.epg import connect as guide, cmp_channel
+        chan = searchstr = ''
+        bychan = False
+
+        if form:
+            searchstr = form.get('find')
+            chan = form.get('channel')
+            bychan = form.get('search_channel')        
+
         self.res += """
         <div class="searchform">
         <form id="SearchForm" action="search" method="get">
         <table border="0">
-          <tr><td align="left"><b>"""+ _('Search')+ """:</b>
-          <input type="text" name="find" size="20" /></td></tr>
-          <tr><td align="left">
-            <input type="checkbox" checked=1 name="search_title" />
-            """+ _('Search title') +"""
-          </td></tr>
-          <tr><td align="left">
-            <input type="checkbox" checked=1 name="search_subtitle" />
-            """+ _('Search subtitle') +"""
-          </td></tr>
-          <tr><td align="left">
-            <input type="checkbox" checked=1 name="search_description" />
-            """+ _('Search description') +"""
+          <tr><td align="center"><b>"""+ _('Search')+ """:</b>
+          <input type="text" name="find" size="20" value=\""""+ searchstr + \
+          """\" /><input type="checkbox" """
+        if bychan:
+            self.res += "checked"
+
+        self.res += """ name="search_channel" />"""+ \
+        _('Search by channel:') + """ <select name="channel">
+        """
+         
+        channels = guide().get_channels()
+        channels.sort(lambda a, b: cmp(a.name, b.name))
+        channels.sort(lambda a, b: cmp_channel(a, b))
+
+        for ch in channels:
+            self.res += '<option value="%s" ' % ch.name 
+            if ch.name == Unicode(chan):
+                self.res += 'selected '
+
+            if ch.tuner_id:
+                self.res += '>%s %s</option>\n' % (ch.tuner_id[0], ch.name)
+            else:
+                self.res += '>%s</option>\n' % ch.name
+
+        self.res += """
+           </select>
           </td></tr>
-          <tr><td align="left">
+          <tr><td align="center">
             <input type="submit" value=" """+ _('Go!') +""" " />
           </td></tr>
         </table>

Modified: trunk/webserver/src/pages/guide.py
==============================================================================
--- trunk/webserver/src/pages/guide.py  (original)
+++ trunk/webserver/src/pages/guide.py  Mon Mar 13 19:51:15 2006
@@ -40,6 +40,7 @@
 
 # freevo core imports
 import freevo.ipc
+from freevo.ipc.epg import connect as guide, cmp_channel
 
 # webserver includes
 from freevo.webserver import *
@@ -50,6 +51,8 @@
 # get tvserver interface
 tvserver = freevo.ipc.Instance().tvserver
 
+
+
 class Resource(HTMLResource):
 
     def makecategorybox(self):
@@ -165,9 +168,16 @@
         self.tableOpen('id="guide" cols=\"%d\"' % \
                      ( n_cols*cpb + 1 ) )
         showheader = 0
-        # for chan in get_channels().get_all():
-        for chan in kaa.epg.channels:
-            #chan = chan.epg
+
+        channels = guide().get_channels()
+       
+        # TODO: use config to determine sort order
+        # for now sort by name first, then tuner_id because tuner_id
+        # may be None.
+        channels.sort(lambda a, b: cmp(a.name, b.name))
+        channels.sort(lambda a, b: cmp_channel(a, b))
+
+        for chan in channels:
             #put guidehead every X rows
             if showheader % 15 == 0:
                 self.tableRowOpen('class="chanrow"')
@@ -196,10 +206,18 @@
             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)
+
+            # TODO: use channel displayformat from config
+            if chan.tuner_id:
+                rowdata.append(u'<td class="channel">%s %s</td>' % \
+                               (chan.tuner_id[0], chan.name))
+            else:
+                rowdata.append(u'<td class="channel">%s</td>' % chan.name)
+
             c_left = n_cols * cpb
 
-            progs = chan[mfrguidestart:mfrnextguide]
+            progs = guide().search(channel = guide().get_channel(chan.name),
+                                   time = (mfrguidestart, mfrnextguide))
             if not len(progs):
                 rowdata.append(u'<td class="programnodata" 
colspan="%s">&laquo; ' % (n_cols*cpb) + _('This channel has no data loaded') + 
' &raquo;' )
 
@@ -211,9 +229,12 @@
                     status = u'program'
 
                     if got_schedule:
+                        # TODO: need a way to determine if program is scheduled
+                        #       for recording.
                         # (result, message) = ri.isProgScheduled(prog, 
schedule)
                         result = False
                         message = 'no message'
+
                         if result:
                             status = u'scheduled'
                             really_now = time.time()
@@ -239,7 +260,7 @@
                             # insert right arrows
                             cell += u'   &raquo;'
                             colspan = c_left
-                        popid = u'%s:%s' % (chan.id, prog.start)
+                        popid = u'%s:%s' % (chan.name, prog.start)
 
                         style = u''
                         if colspan == n_cols * cpb:

Modified: trunk/webserver/src/pages/proginfo.py
==============================================================================
--- trunk/webserver/src/pages/proginfo.py       (original)
+++ trunk/webserver/src/pages/proginfo.py       Mon Mar 13 19:51:15 2006
@@ -31,13 +31,17 @@
 
 # python imports
 import time
+import logging
 
-# kaa imports
-import kaa.epg
+# freevo imports
+from freevo.ipc.epg import connect as guide
 
 # webserver imports
 from freevo.webserver import *
 
+log = logging.getLogger('www')
+log.setLevel(logging.DEBUG)
+
 MAX_DESCRIPTION_CHAR = 1000
 
 class Resource(HTMLResource):
@@ -45,17 +49,20 @@
     def render(self):
         form = self.request.query
         id = form.get('id')
+        log.debug('id: %s', id)
+
         chanid = id[:id.find(":")]
         starttime = int( id[id.find(":")+1:] )
 
-        chan = kaa.epg.guide.channel_dict.get(chanid)
+        chan = guide().get_channel(chanid)
         if not chan:
             self.add(u'no such channel %s' % chanid)
             return True
 
-        prog = chan[starttime]
+        prog = guide().search(channel = chan, time = starttime)[0]
+        log.debug('program: %s', prog.title)
 
-        if prog.description == '':
+        if prog.description == u'':
             desc = (_('Sorry, the program description for ' \
                       '%s is unavailable.')) % ('<b>'+prog.title+'</b>')
         else:
@@ -65,8 +72,9 @@
         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)
+        # TODO: add subtitle to kaa.epg2
+        #if prog.subtitle:
+        #    desc = '"%s"<br/>%s' % (prog.subtitle, desc)
 
         self.add(
             u"<script>\n" \

Modified: trunk/webserver/src/pages/recordings.py
==============================================================================
--- trunk/webserver/src/pages/recordings.py     (original)
+++ trunk/webserver/src/pages/recordings.py     Mon Mar 13 19:51:15 2006
@@ -34,11 +34,9 @@
 import traceback
 import logging
 
-# epg support
-import kaa.epg
-
 # freevo core imports
 import freevo.ipc
+from freevo.ipc.epg import connect as guide
 
 # webserver includes
 from freevo.webserver import *
@@ -80,7 +78,7 @@
             prog = None
             for p in progs:
                 if Unicode(chan) == \
-                       kaa.epg.get_channel_by_id(p.channel).id \
+                       guide().get_channel(p.channel).name \
                    and int(start) == p.start:
                     prog = p
 
@@ -91,7 +89,8 @@
 
         elif action == 'add':
             try:
-                prog = kaa.epg.get_channel(chan)[int(start)]
+                prog = guide().search(channel=guide().get_channel(chan),
+                                      time=int(start))[0]
             except:
                 self.printHeader('Scheduled Recordings', 'styles/main.css')
                 self.printMessages(
@@ -146,7 +145,7 @@
             status  = 'basic'
             colspan = 'class="' + status + '" colspan="1"'
 
-            channel = kaa.epg.get_channel_by_id(prog.channel).title
+            channel = prog.channel
 
             self.tableRowOpen('class="chanrow"')
             t = time.strftime('%b %d ' + config.style.timeformat, 
time.localtime(prog.start))

Modified: trunk/webserver/src/pages/search.py
==============================================================================
--- trunk/webserver/src/pages/search.py (original)
+++ trunk/webserver/src/pages/search.py Mon Mar 13 19:51:15 2006
@@ -33,11 +33,9 @@
 import time
 import logging
 
-# kaa imports
-import kaa.epg
-
 # freevo core imports
 import freevo.ipc
+from freevo.ipc.epg import connect as guide
 
 # webserver includes
 from freevo.webserver import *
@@ -54,18 +52,27 @@
         form = self.request.query
         by_chan = None
 
-        searchstr = form.get('find')
+        searchstr  = form.get('find')
+        by_channel = form.get('search_channel')
+        channel    = form.get('channel')
+
+        if by_channel: 
+            channel = guide().get_channel(channel)
+        else:
+            channel = None
 
         self.printHeader(_('Search'), 'styles/main.css', selected=_('Search'))
+        self.printAdvancedSearchForm(form)
 
         if not searchstr:
             programs = []
         else:
-            programs = kaa.epg.search(Unicode(searchstr),
-                                    by_chan,
-                                    form.get('search_title'),
-                                    form.get('search_subtitle'),
-                                    form.get('search_description'))
+            if channel:
+                programs = guide().search(channel = channel, 
+                                          keywords = searchstr, 
+                                          limit = 100)
+            else:
+                programs = guide().search(keywords = searchstr, limit = 100)
 
         if len(programs) < 1:
             if searchstr:
@@ -78,7 +85,7 @@
             self.tableCell(_('Stop Time'), 'class="guidehead" colspan="1"')
             self.tableCell(_('Channel'), 'class="guidehead" colspan="1"')
             self.tableCell(_('Title'), 'class="guidehead" colspan="1"')
-            self.tableCell(_('Episode'),'class="guidehead" colspan="1"')
+            # self.tableCell(_('Episode'),'class="guidehead" colspan="1"')
             self.tableCell(_('Program Description'), 'class="guidehead" 
colspan="1"')
             self.tableCell(_('Actions'), 'class="guidehead" colspan="1"')
             self.tableRowClose()
@@ -89,7 +96,7 @@
                 status = 'basic'
 
                 for rp in rec_progs:
-                    if p.channel.id == rp.channel and rp.start == p.start:
+                    if p.channel.name == rp.channel and rp.start == p.start:
                         if rp.status == u'recording':
                            status = 'recording'
                         elif rp.status == u'conflict':
@@ -114,32 +121,32 @@
                                            time.localtime(p.stop)),
                              'class="'+status+'" colspan="1"')
 
-                self.tableCell(Unicode(p.channel.title), 'class="'+status+'" 
colspan="1"')
+                self.tableCell(Unicode(p.channel.name), 'class="'+status+'" 
colspan="1"')
                 self.tableCell(Unicode(p.title), 'class="'+status+'" 
colspan="1"')
-                self.tableCell(Unicode(p.subtitle), 'class="'+status+'" 
colspan="1"')
+                # self.tableCell(Unicode(p.subtitle), 'class="'+status+'" 
colspan="1"')
 
-                if Unicode(p.description) == u'':
+                if p.description == u'':
                     cell = \
                      _('Sorry, the program description for %s is 
unavailable.')\
                      % ('<b>'+p.title+'</b>')
                 else:
-                    cell = Unicode(p.description)
+                    cell = p.description
 
                 self.tableCell(cell, 'class="'+status+'" colspan="1"')
 
                 if status == 'scheduled':
                     cell = ('<a 
href="recordings?chan=%s&start=%s&action=remove">'+
-                            _('Remove')+'</a>') % (p.channel.id, p.start)
+                            _('Remove')+'</a>') % (p.channel.name, p.start)
                 elif status == 'recording':
                     cell = ('<a 
href="recordings?chan=%s&start=%s&action=remove">'+
-                           _('Record')+'</a>') % (p.channel.id, p.start)
+                           _('Record')+'</a>') % (p.channel.name, p.start)
                 else:
                     cell = ('<a 
href="recordings?chan=%s&start=%s&action=add">'+
-                           _('Record')+'</a>') % (p.channel.id, p.start)
+                           _('Record')+'</a>') % (p.channel.name, p.start)
 
                 cell += \
                      (' | <a 
href="edit_favorite?chan=%s&start=%s&action=add">'+
-                     _('New favorite')+'</a>') % (p.channel.id, p.start)
+                     _('New favorite')+'</a>') % (p.channel.name, p.start)
 
                 self.tableCell(cell, 'class="'+status+'" colspan="1"')
 
@@ -149,7 +156,6 @@
 
             self.add('</div>')
 
-        self.printAdvancedSearchForm()
         self.printFooter()
 
         return True


-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to