Hello,

It's been some time since I last had time for freevo2,
but today I found the time to finish the "search for more of this program"
action for ProgramItems.

At the moment it just returns exact matches with the same title.
This is why I changed the description of the menu item from
"Search for similar" to "Search for more of this".
(Maybe one can think of a more elaborate search for the future.)

It only shows programs that have not finished yet, because I think,
there is not much use in finding old programs.
This can of course easily be changed when wished.

In doing this changes, I found some problems with the menus and
scheduling/unscheduling of programs.
After scheduling a program, the submenu keeps saying:
"Schedule for recording" instead of changing this to "Remove from schedule".
Back to the TVGuide the program did not change its color to indicate that it
is now in the schedule.
What is missing here is a kind of update of the TVGuide data when returning 
from a submenu.
How does one achieve this? menu.refresh seems not to be the solution...

Moreover I have another little patch for the genre plugin.
With the patch it also shows only the coming programs and not the ones that are 
already finished.

Regards
Tanja
Index: ui/src/tv/plugins/genre.py
===================================================================
--- ui/src/tv/plugins/genre.py	(Revision 9575)
+++ ui/src/tv/plugins/genre.py	(Arbeitskopie)
@@ -34,6 +34,7 @@
 
 # python imports
 import logging
+import time
 
 # kaa imports
 import kaa.notifier
@@ -87,7 +88,9 @@
         # fetch epg data from InProgress object
         query_data = query_data()
         for prg in query_data:
-            items.append(ProgramItem(prg, self))
+            if prg.stop > time.time():
+                # only add this to the list, if it has not already finished
+                items.append(ProgramItem(prg, self))
         # create menu for programs
         menu = Menu(self.name, items, type='tv program menu')
         self.get_menustack().pushmenu(menu)
Index: ui/src/tv/program.py
===================================================================
--- ui/src/tv/program.py	(Revision 9577)
+++ ui/src/tv/program.py	(Arbeitskopie)
@@ -142,35 +142,55 @@
     def submenu(self, additional_items=False):
         """
         show a submenu for this item
+        
+        There are some items, that are only created if 'additional_items'
+        is set to TRUE, this items are useful in the TVGuide.
         """
+        
+        # empty item list
         items = []
-        if self.scheduled and not self.scheduled.status in \
-           ('deleted', 'missed'):
-            if self.start < time.time() + 10 and \
-                   self.scheduled.status in ('recording', 'saved'):
-                items.append(ActionItem(_('Watch recording'), self,
-                                        self.watch_recording))
-            if self.stop > time.time():
-                if self.start < time.time():
-                    items.append(ActionItem(_('Stop recording'), self,
-                                            self.remove))
-                else:
-                    items.append(ActionItem(_('Remove recording'), self,
-                                            self.remove))
+        
+        # scheduled for recording
+        if self.scheduled and not self.scheduled.status in ('deleted','missed'):
+                if self.start < time.time() + 10  \
+                and self.scheduled.status in ('recording', 'saved'):
+                    # start watching the recorded stream from disk
+                    txt = _('Watch recording')
+                    items.append(ActionItem(txt, self, self.watch_recording))
+                if self.stop > time.time():
+                    # not yet finished
+                    if self.start < time.time():
+                        # but already running
+                        txt = _('Stop recording')
+                        items.append(ActionItem(txt, self, self.remove))
+                    else:
+                        # still in the future
+                        txt =  _('Remove recording')   
+                        items.append(ActionItem(txt, self, self.remove))
+                    
+        # not scheduled for recording
         elif self.stop > time.time():
-            items.append(ActionItem(_('Schedule for recording'), self,
-                                    self.schedule))
+            # not in the past, can still be scheduled
+            txt = _('Schedule for recording')
+            items.append(ActionItem(txt, self, self.schedule))
+        
+        
+        # this items are only shown from inside the TVGuide:
         if additional_items:
-            items.append(ActionItem(_('Show complete listing for %s') % \
-                                    self.channel.name, self,
-                                    self.channel_details))
-            items.append(ActionItem(_('Watch %s') % self.channel.name, self,
-                                    self.watch_channel))
-            txt = _('Search for programs with a similar name')
+            # Show all programm on this channel
+            txt = ('Show complete listing for %s') % self.channel.name
+            items.append(ActionItem(txt, self, self.channel_details))
+            # Start watching this channel
+            txt = _('Watch %s') % self.channel.name
+            items.append(ActionItem(txt, self, self.watch_channel))
+            # Search for more of this program
+            txt = _('Search for more of this program')
             items.append(ActionItem(txt, self, self.search_similar))
+        
+        # Add the menu for handling favorites
+        txt = _('Favorite...')
+        items.append(ActionItem(txt, self, self.create_favorite))
 
-        items.append(ActionItem(_('Favorite...'), self, self.create_favorite))
-
         s = Menu(self, items, type = 'tv program menu')
         s.submenu = True
         s.infoitem = self
@@ -179,6 +199,9 @@
 
     @kaa.notifier.yield_execution()
     def schedule(self):
+        """
+        schedule this item for recording
+        """
         result = tvserver.recordings.schedule(self)
         if isinstance(result, kaa.notifier.InProgress):
             yield result
@@ -189,10 +212,13 @@
             msg = _('Scheduling failed: %s') % result
         MessageWindow(msg).show()
         self.get_menustack().delete_submenu()
-
-
+                       
+        
     @kaa.notifier.yield_execution()
     def remove(self):
+        """
+        remove this item from schedule
+        """
         result = tvserver.recordings.remove(self.scheduled.id)
         if isinstance(result, kaa.notifier.InProgress):
             yield result
@@ -231,11 +257,34 @@
     def watch_recording(self):
         MessageWindow('Not implemented yet').show()
 
-
+    
+    @kaa.notifier.yield_execution()
     def search_similar(self):
-        MessageWindow('Not implemented yet').show()
+        """
+        Search the database for more of this program
+        """
+        if not kaa.epg.is_connected():
+            # we need the tvserver for this
+            MessageWindow(_('TVServer not running')).show()
+            return
+        # create an empty list for ProgramItems    
+        items = []
+        # query the epg database in background
+        query_data = kaa.epg.search(title=self.title)
+        yield query_data
+        # get data from InProgress object
+        query_data = query_data()
+        # and sort is concerning its start times
+        query_data.sort(lambda a,b:cmp(a.start,b.start))
+        for prog in query_data:
+            if prog.stop >time.time():
+                # only show programs that are not finished already
+                items.append(ProgramItem(prog, self))
+        # create the submenu from this        
+        resmenu = Menu(self.title, items, type = 'tv program menu')
+        self.get_menustack().pushmenu(resmenu)   
+                
 
-
     def create_favorite(self):
         favorite.FavoriteItem(self, self.program).submenu()
 
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to