Author: rshortt
Date: Mon Mar 13 02:19:45 2006
New Revision: 8079
Modified:
trunk/WIP/RobShortt/webserver-epg2/src/pages/guide.py
Log:
Sort channels better... seems to work ok. :)
Modified: trunk/WIP/RobShortt/webserver-epg2/src/pages/guide.py
==============================================================================
--- trunk/WIP/RobShortt/webserver-epg2/src/pages/guide.py (original)
+++ trunk/WIP/RobShortt/webserver-epg2/src/pages/guide.py Mon Mar 13
02:19:45 2006
@@ -51,6 +51,53 @@
# get tvserver interface
tvserver = freevo.ipc.Instance().tvserver
+def cmp_chan(c1, c2):
+ l1 = len(c1.tuner_id)
+ l2 = len(c2.tuner_id)
+
+ if l1 == 0:
+ if l2 == 0:
+ return 0
+ else:
+ return -1
+
+ if l2 == 0:
+ if l1 == 0:
+ return 0
+ else:
+ return 1
+
+ a = 0
+ b = 0
+
+ for t in c1.tuner_id:
+ try:
+ a = int(t)
+ break
+ except:
+ if c1.tuner_id.index(t) < l1-1:
+ # try next time
+ continue
+ else:
+ break
+
+ for t in c2.tuner_id:
+ try:
+ b = int(t)
+ break
+ except:
+ if c2.tuner_id.index(t) < l2-1:
+ # try next time
+ continue
+ else:
+ break
+
+ if a < b: return -1
+ elif a > b: return 1
+ else: return 0
+
+
+
class Resource(HTMLResource):
def makecategorybox(self):
@@ -173,7 +220,7 @@
# for now sort by name first, then tuner_id because tuner_id
# may be None.
channels.sort(lambda a, b: cmp(a.short_name, b.short_name))
- channels.sort(lambda a, b: cmp(int(a.tuner_id[0]), int(b.tuner_id[0])))
+ channels.sort(lambda a, b: cmp_chan(a, b))
for chan in channels:
#put guidehead every X rows
@@ -204,7 +251,14 @@
now = mfrguidestart
# chan.displayname = string.replace(chan.displayname, "&", "SUB")
rowdata.append(u'<tr class="chanrow">')
- rowdata.append(u'<td class="channel">%s %s</td>' %
(chan.tuner_id[0], chan.short_name))
+
+ # TODO: use channel displayformat from config
+ if chan.tuner_id:
+ rowdata.append(u'<td class="channel">%s %s</td>' % \
+ (chan.tuner_id[0], chan.short_name))
+ else:
+ rowdata.append(u'<td class="channel">%s</td>' %
chan.short_name)
+
c_left = n_cols * cpb
progs = guide().search(channel =
guide().get_channel(chan.short_name),
-------------------------------------------------------
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