Author: rshortt
Date: Tue Mar 14 13:11:06 2006
New Revision: 8087
Modified:
trunk/ui/src/gui/areas/tvlisting_area.py
trunk/ui/src/tv/program.py
trunk/ui/src/tv/tvguide.py
Log:
Work towards a working tv guide. There's still much to do. It may need to be
redesigned.
Modified: trunk/ui/src/gui/areas/tvlisting_area.py
==============================================================================
--- trunk/ui/src/gui/areas/tvlisting_area.py (original)
+++ trunk/ui/src/gui/areas/tvlisting_area.py Tue Mar 14 13:11:06 2006
@@ -40,7 +40,6 @@
import copy
import os
-import kaa.epg
import gui.imagelib
import math
import time
@@ -48,6 +47,7 @@
# freevo core imports
import freevo.ipc
+from freevo.ipc.epg import connect as guide, cmp_channel
from area import Area
from gui.widgets import Rectangle
@@ -83,6 +83,15 @@
self.last_start_time = 0
self.last_channels = None
+ # TODO: it is ugly keeping a list of channels everywhere
+ # it may be best to handle this in the guide object or
+ # in the freevo epg module (there we can use config items
+ # to determine sort order.
+ self.channels = guide().get_channels()
+ self.channels.sort(lambda a, b: cmp(a.name, b.name))
+ self.channels.sort(lambda a, b: cmp_channel(a, b))
+
+
# objects on the area
self.chan_obj = []
self.time_obj = []
@@ -247,13 +256,13 @@
channel_logo = None
- channel_logo = config.TV_LOGOS + '/' + channel.id + '.png'
+ channel_logo = config.TV_LOGOS + '/' + channel.name + '.png'
if os.path.isfile(channel_logo):
img = gui.imagelib.load(channel_logo, (None, None))
i = self.drawimage(img, (logo_geo[0], logo_geo[1]))
self.chan_obj.append(i)
else:
- self.chan_obj.append(self.drawstring(channel.title,
+ self.chan_obj.append(self.drawstring(channel.name,
label_val.font,
settings, x=tx0, y=ty0,
width=r.width+2*r.x,
@@ -379,8 +388,8 @@
# get selected program and channel list:
selected_prog = menu.selected
- start_channel = kaa.epg.channels.index(menu.channel)/num_rows*num_rows
- channel_list = kaa.epg.channels[start_channel:start_channel+num_rows]
+ start_channel = self.channels.index(menu.channel)/num_rows*num_rows
+ channel_list = self.channels[start_channel:start_channel+num_rows]
# draw the channel list
if self.last_channels != channel_list:
@@ -394,7 +403,9 @@
for channel in channel_list:
try:
- for prg in channel[start_time:stop_time]:
+ #for prg in channel[start_time:stop_time]:
+ for prg in guide().search(channel=channel,
+ time=(start_time, stop_time)):
flag_left = 0
flag_right = 0
@@ -418,7 +429,7 @@
if prg == selected_prog:
val = selected_val
else:
- rs = tvserver.recordings.get(prg.channel.id, prg.start,
+ rs = tvserver.recordings.get(prg.channel.name,
prg.start,
prg.stop)
if rs and rs.status in (tvserver.SCHEDULED,
tvserver.RECORDING,
tvserver.SAVED):
@@ -480,7 +491,7 @@
self.up_arrow.unparent()
self.up_arrow = None
- if len(kaa.epg.channels) >= start_channel+num_rows and \
+ if len(self.channels) >= start_channel+num_rows and \
settings.images['downarrow']:
if not self.down_arrow:
# down arrow needed
Modified: trunk/ui/src/tv/program.py
==============================================================================
--- trunk/ui/src/tv/program.py (original)
+++ trunk/ui/src/tv/program.py Tue Mar 14 13:11:06 2006
@@ -33,10 +33,13 @@
# python imports
import time
-import kaa.epg
+
+# kaa imports
+import kaa.epg2
# freevo core imports
import freevo.ipc
+from freevo.ipc.epg import connect as guide
# freevo imports
import config
@@ -63,17 +66,17 @@
self.stop = program.stop
self.channel = program.channel
- self.prog_id = program.id
+ self.prog_id = program.db_id
self.subtitle = program.subtitle
self.description = program.description
self.episode = program.episode
- self.scheduled = tvserver.recordings.get(program.channel.id,
+ self.scheduled = tvserver.recordings.get(program.channel.name,
program.start, program.stop)
- # TODO: add category support (from epgdb)
+ # TODO: add category support
self.categories = ''
- # TODO: add ratings support (from epgdb)
+ # TODO: add ratings support
self.ratings = ''
@@ -100,13 +103,13 @@
"""
compare function, return 0 if the objects are identical, 1 otherwise
"""
- if not isinstance(other, (ProgramItem, kaa.epg.Program)):
+ if not isinstance(other, (ProgramItem, kaa.epg2.Program)):
return 1
- return Unicode(self.title) != Unicode(other.title) or \
+ return self.title != other.title or \
self.start != other.start or \
self.stop != other.stop or \
- Unicode(self.channel) != Unicode(other.channel)
+ self.channel != other.channel
def __getitem__(self, key):
@@ -198,9 +201,8 @@
def channel_details(self):
items = []
- for prog in self.channel[time.time():]:
- if not prog.id == -1:
- items.append(ProgramItem(prog, self))
+ for prog in guide().search(channel=self.channel):
+ items.append(ProgramItem(prog, self))
cmenu = Menu(self.channel.name, items, item_types = 'tv program menu')
# FIXME: the percent values need to be calculated
# cmenu.table = (15, 15, 70)
Modified: trunk/ui/src/tv/tvguide.py
==============================================================================
--- trunk/ui/src/tv/tvguide.py (original)
+++ trunk/ui/src/tv/tvguide.py Tue Mar 14 13:11:06 2006
@@ -34,9 +34,8 @@
import time
import logging
-import kaa.epg
-
# freevo imports
+from freevo.ipc.epg import connect as guide, cmp_channel
import gui
import gui.areas
@@ -70,6 +69,39 @@
def __init__(self):
MenuApplication.__init__(self, 'tvguide', 'tvmenu', False)
self.item = None
+ self.channel_index = 0
+
+ def get_channel(self, offset=0):
+ co = self.channel_index + offset
+ channels = guide().get_channels()
+
+ # idea: make a guide().sort_channels() or something internal to the
guide
+ # so we get sorted channels when guide loads its data
+ channels.sort(lambda a, b: cmp(a.name, b.name))
+ channels.sort(lambda a, b: cmp_channel(a, b))
+
+ if co < 0:
+ co = len(channels)-1+co
+ elif co > len(channels)-1:
+ co = co-len(channels)-1
+
+ return channels[co]
+
+ def get_program(self, time=None):
+ """
+ return a program object based on time and the current channel.
+ """
+ # TODO: keep a cache of program objects for the current guide view
+ # unless this happens to be fast enough
+
+ if not time:
+ time = self.current_time
+
+ log.debug('channel: %s', self.channel)
+ p = guide().search(channel=self.channel, time=time)[0]
+ # time = (time.time(), time.time()+7200)
+ #p = guide().search(channel=self.channel)[0]
+ return p
def start(self, parent):
self.engine = gui.areas.Handler('tv', ('screen', 'title', 'subtitle',
@@ -81,10 +113,10 @@
self.current_time = int(time.time())
# current channel is the first one
- self.channel = kaa.epg.channels[0]
+ self.channel = self.get_channel()
# current program is the current running
- self.selected = ProgramItem(self.channel[self.current_time], self.item)
+ self.selected = ProgramItem(self.get_program(), self.item)
return True
@@ -93,8 +125,7 @@
"""
show the guide
"""
- self.channel = kaa.epg.get_channel()
- self.selected = ProgramItem(self.channel[self.current_time], self.item)
+ self.selected = ProgramItem(self.get_program(), self.item)
self.refresh()
MenuApplication.show(self)
@@ -114,21 +145,19 @@
return True
if event == MENU_UP:
- self.channel = kaa.epg.get_channel(self.channel, -1)
- self.selected = ProgramItem(self.channel[self.current_time],
- self.item)
+ self.channel = self.get_channel(-1)
+ self.selected = ProgramItem(self.get_program(), self.item)
self.refresh()
return True
if event == MENU_DOWN:
- self.channel = kaa.epg.get_channel(self.channel, 1)
- self.selected = ProgramItem(self.channel[self.current_time],
- self.item)
+ self.channel = self.get_channel(1)
+ self.selected = ProgramItem(self.get_program(), self.item)
self.refresh()
return True
if event == MENU_LEFT:
- epg_prog = self.channel[self.selected.program.start - 1]
+ epg_prog = self.get_program(self.selected.program.start - 1)
self.selected = ProgramItem(epg_prog, self.item)
if self.selected.start > 0:
self.current_time = self.selected.start + 1
@@ -136,7 +165,7 @@
return True
if event == MENU_RIGHT:
- epg_prog = self.channel[self.selected.program.stop+1]
+ epg_prog = self.get_program(self.selected.program.start + 1)
self.selected = ProgramItem(epg_prog, self.item)
if self.selected.start > 0:
self.current_time = self.selected.start + 1
@@ -144,16 +173,14 @@
return True
if event == MENU_PAGEUP:
- self.channel = kaa.epg.get_channel(self.channel, -9)
- self.selected = ProgramItem(self.channel[self.current_time],
- self.item)
+ self.channel = self.get_channel(-9)
+ self.selected = ProgramItem(self.get_program(), self.item)
self.refresh()
return True
if event == MENU_PAGEDOWN:
- self.channel = kaa.epg.get_channel(self.channel, 9)
- self.selected = ProgramItem(self.channel[self.current_time],
- self.item)
+ self.channel = self.get_channel(9)
+ self.selected = ProgramItem(self.get_program(), self.item)
self.refresh()
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