A Mennucc wrote:
> hi,
> 
> I am trying the latest SVN; I got backtraces when trying to record, or
> to play, TV channels; the attched patch fixed those. The backtraces were
> like:
> 
> 
> Traceback (most recent call last):
>   File "/usr/lib/python2.5/site-packages/freevo/main.py", line 307, in
> eventhandler
>     app.eventhandler(event)
>   File "/usr/share/pyshared/freevo/menu.py", line 779, in eventhandler
>     if not isinstance(menu, Menu) and menu.eventhandler(event):
>   File "/usr/share/pyshared/freevo/tv/tvguide.py", line 229, in eventhandler
>     pi.actions()[0][0](menuw=self.menuw)
>   File "/usr/share/pyshared/freevo/tv/programitem.py", line 172, in play
>     self.parent.player('tv', self.prog.channel_id)
>   File "/usr/share/pyshared/freevo/tv/tvmenu.py", line 82, in start_tv
>     p.Play(mode, tuner_id)
>   File "/usr/share/pyshared/freevo/tv/plugins/mplayer.py", line 83, in Play
>     vg = self.current_vg = self.fc.getVideoGroup(tuner_channel, True)
>   File "/usr/share/pyshared/freevo/tv/channels.py", line 125, in
> getVideoGroup
>     return config.TV_VIDEO_GROUPS[group]
> IndexError: list index out of range
> 
> adding some print statements, I saw that getVideoGroup was called with
> chan=19, and was setting group=-19


Hi Andrea,

Will you test this patch as I can't test it for numeric channels?

This should work and keep the same behaviour plus fix the '0' problem to
allow the 0 video group to be used for play-back. This assumes that
there is no TV channel 0, AFAICS TV channels always start at 1.

Thanks
Duncan
Index: src/tv/channels.py
===================================================================
--- src/tv/channels.py	(revision 11417)
+++ src/tv/channels.py	(working copy)
@@ -82,47 +82,59 @@
             plugin.init_special_plugin(config.plugin_external_tuner)
 
 
+    def _findVideoGroup(self, chan, isplayer, chan_index):
+        """
+        Find the VideoGroup number used by this Freevo channel.
+        """
+        group = 0
+        for i in range(len(config.TV_CHANNELS)):
+            chan_info = config.TV_CHANNELS[i]
+            if chan_info[chan_index] == chan:
+                try:
+                    group = int(chan_info[4])
+                except (IndexError, ValueError):
+                    pass
+                break
+        else: # Channel not found
+            #DJW this should be noticed
+            import traceback
+            traceback.print_stack()
+            
+        return group
+
+
     def getVideoGroup(self, chan, isplayer, chan_index=TUNER_ID):
         """
         Gets the VideoGroup object used by this Freevo channel.
         """
         _debug_('getVideoGroup(chan=%r, isplayer=%r, chan_index=%r)' % (chan, isplayer, chan_index), 1)
+
+        vg = config.TV_VIDEO_GROUPS[0]
+
         self.lock.acquire()
         try:
             try:
-                group = -int(chan)
+                channel = int(chan)
+                if channel <= 0: # channels start at 1
+                    group = -channel
+                else:
+                    group = self._findVideoGroup(chan, isplayer, chan_index)
             except ValueError:
-                group = 0
-            if group <= 0:
-                for i in range(len(config.TV_CHANNELS)):
-                    chan_info = config.TV_CHANNELS[i]
-                    if chan_info[chan_index] == chan:
-                        if len(chan_info) > 4:
-                            group = chan_info[4]
-                        try:
-                            group = int(group)
-                        except ValueError:
-                            group = 0
-                        break
+                group = self._findVideoGroup(chan, isplayer, chan_index)
 
-                else: # Channel not found
-                    #DJW this should be noticed
-                    import traceback
-                    traceback.print_stack()
-                    #DJW
+            vg = config.TV_VIDEO_GROUPS[group]
             if not isplayer:
-                record_group = config.TV_VIDEO_GROUPS[group].record_group
+                record_group = vg.record_group
                 if record_group:
                     try:
                         # some simple checks
-                        group = int(record_group)
-                        record_vg = config.TV_VIDEO_GROUPS[group]
+                        vg = config.TV_VIDEO_GROUPS[int(record_group)]
                     except:
                         _debug_('TV_VIDEO_GROUPS[%s].record_group=%s is invalid' % (group, record_group), DWARNING)
         finally:
             self.lock.release()
 
-        return config.TV_VIDEO_GROUPS[group]
+        return vg
 
 
     def chanUp(self, isplayer, app=None, app_cmd=None):
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and 
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today. 
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to