Author: duncan
Date: Sun Nov 18 05:40:25 2007
New Revision: 10139

Log:
[ 1833829 ] cleaner solution for itv player selection
Patch from Tanja Kotthaus applied


Modified:
   branches/rel-1-7/freevo/ChangeLog
   branches/rel-1-7/freevo/src/plugins/itv.py
   branches/rel-1-7/freevo/src/video/configure.py
   branches/rel-1-7/freevo/src/video/plugins/xine.py
   branches/rel-1-7/freevo/src/video/videoitem.py
   branches/rel-1/freevo/ChangeLog
   branches/rel-1/freevo/src/plugins/itv.py
   branches/rel-1/freevo/src/video/configure.py
   branches/rel-1/freevo/src/video/plugins/xine.py
   branches/rel-1/freevo/src/video/videoitem.py

Modified: branches/rel-1-7/freevo/ChangeLog
==============================================================================
--- branches/rel-1-7/freevo/ChangeLog   (original)
+++ branches/rel-1-7/freevo/ChangeLog   Sun Nov 18 05:40:25 2007
@@ -17,13 +17,7 @@
 --------------------------------
 
  * Updated French translation (F#1832751)
- * Fixed itv plug-in, having "No player for this item found" (B#1833018)
-
-== Release 1.7.5 (2007-??-??) ==
---------------------------------
-
- * Updated French translation (F#1832751)
- * Fixed itv plug-in, having "No player for this item found" (B#1833018)
+ * Fixed itv plug-in, having "No player for this item found" 
(B#1833018,B#1833829)
  * Fixed helper plugins, not allowing tuples as arguments (B#1832837)
 
 == Release 1.7.4 (2007-11-15) ==

Modified: branches/rel-1-7/freevo/src/plugins/itv.py
==============================================================================
--- branches/rel-1-7/freevo/src/plugins/itv.py  (original)
+++ branches/rel-1-7/freevo/src/plugins/itv.py  Sun Nov 18 05:40:25 2007
@@ -70,8 +70,6 @@
 
     | plugin.activate('itv', level=45)
     |
-    | ITV_PLAYER = 'mplayer'
-    | ITV_ARGS = '-nolirc -nojoystick -autoq 100 -screenw 800 -screenh 600 -fs 
'
     | ITV_LOCATIONS = [
     |     ('JT LCI 18h', 'http://tf1.lci.fr/xml/rss/0,,14,00.xml'),
     |     ('JT i>Tele', 
'http://podcast12.streamakaci.com/iTELE/iTELElejournal.xml'),
@@ -90,16 +88,13 @@
         plugin.MainMenuPlugin.__init__(self)
 
     def config(self):
-        return [
-            ('ITV_PLAYER', 'mplayer', 'player for the iTV feed, must support 
http://'),
-            ('ITV_ARGS', '-nolirc -nojoystick -autoq 100 -screenw 800 -screenh 
600 -fs ', 'player options'),
-            ('ITV_LOCATIONS', [
+        return [('ITV_LOCATIONS', [
                 ('JT LCI 18h', 'http://tf1.lci.fr/xml/rss/0,,14,00.xml'),
                 ('JT i>Tele', 
'http://podcast12.streamakaci.com/iTELE/iTELElejournal.xml'),
                 ('Flash Equipe', 
'http://www.lequipe.fr/Podcast/flashETV_rss.xml'),
                 ('M�t�o LCI', 'http://tf1.fr/xml/rss/0,,23,00.xml'),
                 ('M�t�o France 2', 'file:///home/henri2/.freevo/meteo.xml')],
-            'where to get the news')]
+                 'where to get the news')]
 
     def items(self, parent):
         return [ HeadlinesMainMenuItem(parent) ]
@@ -111,34 +106,28 @@
     """
     def __init__(self, parent):
         Item.__init__(self, parent)
+        self.parent = parent
         self.url = ''
         self.cachedir = '%s/itv' % config.FREEVO_CACHEDIR
         if not os.path.isdir(self.cachedir):
             os.mkdir(self.cachedir,
                      
stat.S_IMODE(os.stat(config.FREEVO_CACHEDIR)[stat.ST_MODE]))
         self.location_index = None
-        self.player        = ChaineItem(self, "http","file://")
-
-    def eventhandler(self, event, menuw=None):
-        """
-        eventhandler
-        """
-        if event in ('USER_END','PLAY_END','STOP'):
-            self.player.stop()
-            menuw.show()
-            return True
-
-        return False
-
+   
+     
     def actions(self):
         """
         return a list of actions for this item
         """
-        items = [ ( self.getheadlines , _('Show Sites Headlines') ) ]
+        items = [ ( self.getheadlines, _('Show Sites Headlines') ) ]
         return items
 
 
     def getsiteheadlines(self):
+        """
+        this returns the raw headlines (title, link and description tuples),
+        it reads them from the cache file or fetches them from the internet.
+        """
         headlines = []
         pfile = os.path.join(self.cachedir, 'itv-%i' % self.location_index)
         if (os.path.isfile(pfile) == 0 or \
@@ -152,6 +141,10 @@
 
 
     def fetchheadlinesfromurl(self):
+        """ 
+        this fetches the headlines (title, link and description) from the url.
+        Here the parsing of the xml is done
+        """
         headlines = []
         # create Reader object
         reader = Sax2.Reader()
@@ -202,22 +195,18 @@
         return headlines
 
 
-    def show_details(self, arg=None, menuw=None):
-        self.player.mode = 'http'
-        self.player.url = arg.link
-        lien = arg.link
-        self.player.play(lien, menuw)
-
-
     def getheadlines(self, arg=None, menuw=None):
+        """
+        this returns a menu with VideoItems for each headline
+        """
         headlines = []
         rawheadlines = []
         rawheadlines = self.getsiteheadlines()
         for title, link, description in rawheadlines:
-            mi = menu.MenuItem('%s' % title, self.show_details, 0)
-            mi.arg = mi
-            mi.link = link
-
+            # create a VideoItem for each headline  
+            mi = VideoItem(link, self.parent)
+            mi.name = title
+            
             description = description.replace('\n\n', '&#xxx;').replace('\n', 
' ').\
                           replace('&#xxx;', '\n')
             description = description.replace('<p>', '\n').replace('<br>', 
'\n')
@@ -225,11 +214,11 @@
             description = description + '\n \n \nLink: ' + link
             description = util.htmlenties2txt(description)
 
-            mi.description = re.sub('<.*?>', '', description)
+            mi.plot = re.sub('<.*?>', '', description)
 
             headlines.append(mi)
 
-
+        # create the menu
         if (len(headlines) == 0):
             headlines += [menu.MenuItem(_('No Headlines found'), 
menuw.goto_prev_page, 0)]
 
@@ -270,15 +259,4 @@
         menuw.pushmenu(headlines_site_menu)
         menuw.refresh()
 
-class ChaineItem(VideoItem):
-    """
-    Item for the menu for one rss feed
-    """
-    def __init__(self, parent, flux_name,flux_location):
-        VideoItem.__init__(self, flux_location, parent)
-        self.network_play = True
-        self.parent       = parent
-        self.location     = flux_location
-        self.name         = '' #parent.name
-        self.type = 'video'
-        self.force_player = 'mplayer'
+

Modified: branches/rel-1-7/freevo/src/video/configure.py
==============================================================================
--- branches/rel-1-7/freevo/src/video/configure.py      (original)
+++ branches/rel-1-7/freevo/src/video/configure.py      Sun Nov 18 05:40:25 2007
@@ -4,8 +4,6 @@
 # -----------------------------------------------------------------------
 # $Id$
 #
-# Notes: Not integrated right now
-# Todo:  Fix some stuff, wait for the mplayer people what they are doing
 #
 # -----------------------------------------------------------------------
 # Freevo - A Home Theater PC framework
@@ -273,9 +271,11 @@
     next_start = 0
     items = []
 
+    if len(item.possible_player) >1:
+            items.append(menu.MenuItem(_('Play with alternate player'), 
+                         player_selection_menu, item))
+
     if item.filename or (item.mode in ('dvd', 'vcd') and item.player_rating >= 
20):
-        if len(item.possible_player) >1:
-            items.append(menu.MenuItem(_('Play with alternate player'), 
player_selection_menu, item))
         if item.info.has_key('audio') and len(item.info['audio']) > 1:
             items.append(menu.MenuItem(_('Audio selection'), 
audio_selection_menu, item))
         if item.info.has_key('subtitles') and len(item.info['subtitles']) >= 1:

Modified: branches/rel-1-7/freevo/src/video/plugins/xine.py
==============================================================================
--- branches/rel-1-7/freevo/src/video/plugins/xine.py   (original)
+++ branches/rel-1-7/freevo/src/video/plugins/xine.py   Sun Nov 18 05:40:25 2007
@@ -131,6 +131,9 @@
         if item.mimetype in config.VIDEO_XINE_SUFFIX:
             _debug_('%r good' % (item.url))
             return 2
+        if item.mode in ('http') and not item.filename and not item.media:
+            _debug_('%r unplayable' % (item.url), 2)
+            return 0   
         if item.network_play:
             _debug_('%r possible' % (item.url))
             return 1

Modified: branches/rel-1-7/freevo/src/video/videoitem.py
==============================================================================
--- branches/rel-1-7/freevo/src/video/videoitem.py      (original)
+++ branches/rel-1-7/freevo/src/video/videoitem.py      Sun Nov 18 05:40:25 2007
@@ -83,7 +83,7 @@
         self.set_url(url, info=parse)
         if info:
             self.info.set_variables(info)
-
+        
 
         # deinterlacing and related things
         video_deinterlace = config.VIDEO_DEINTERLACE != None and 
config.VIDEO_DEINTERLACE or False
@@ -198,11 +198,15 @@
                 rating += 1
             if hasattr(self, 'force_player') and p.name == self.force_player:
                 rating += 100
-            self.possible_player.append((rating, p))
+            if rating >10:
+                #exclude players that cannot play this item    
+                self.possible_player.append((rating, p))
+        # sort the players in the order of the rating        
         self.possible_player.sort(lambda l, o: -cmp(l[0], o[0]))
         if len(self.possible_player) > 0:
+            # choose the best player as default player     
             self.player_rating, self.player = self.possible_player[0]
-
+        _debug_(self.possible_player, 2)       
 
 
     def id(self):
@@ -449,7 +453,7 @@
         play the item.
         """
 
-        if not self.player:
+        if not self.player or self.player_rating<10:
             AlertBox(text=_('No player for this item found')).show()
             return
 
@@ -533,18 +537,6 @@
                     (self.media_id, self.url), handler=self.play).show()
                 return
 
-        elif self.mode in ('http') and not self.filename and not self.media:
-            self.player_rating, self.player = self.possible_player[0]
-            self.player_rating = 20
-            for p in plugin.getbyname(plugin.VIDEO_PLAYER, True):
-                rating = p.rate(self) * 10
-                if p.name == 'mplayer':
-                    self.player = p
-
-        if self.player_rating < 10:
-            AlertBox(text=_('No player for this item found')).show()
-            return
-
         mplayer_options = self.mplayer_options.split(' ')
         if not mplayer_options:
             mplayer_options = []

Modified: branches/rel-1/freevo/ChangeLog
==============================================================================
--- branches/rel-1/freevo/ChangeLog     (original)
+++ branches/rel-1/freevo/ChangeLog     Sun Nov 18 05:40:25 2007
@@ -22,7 +22,7 @@
 --------------------------------
 
  * Updated French translation (F#1832751)
- * Fixed itv plug-in, having "No player for this item found" (B#1833018)
+ * Fixed itv plug-in, having "No player for this item found" 
(B#1833018,B#1833829)
  * Fixed helper plugins, not allowing tuples as arguments (B#1832837)
 
 == Release 1.7.4 (2007-11-15) ==

Modified: branches/rel-1/freevo/src/plugins/itv.py
==============================================================================
--- branches/rel-1/freevo/src/plugins/itv.py    (original)
+++ branches/rel-1/freevo/src/plugins/itv.py    Sun Nov 18 05:40:25 2007
@@ -70,8 +70,6 @@
 
     | plugin.activate('itv', level=45)
     |
-    | ITV_PLAYER = 'mplayer'
-    | ITV_ARGS = '-nolirc -nojoystick -autoq 100 -screenw 800 -screenh 600 -fs 
'
     | ITV_LOCATIONS = [
     |     ('JT LCI 18h', 'http://tf1.lci.fr/xml/rss/0,,14,00.xml'),
     |     ('JT i>Tele', 
'http://podcast12.streamakaci.com/iTELE/iTELElejournal.xml'),
@@ -90,16 +88,13 @@
         plugin.MainMenuPlugin.__init__(self)
 
     def config(self):
-        return [
-            ('ITV_PLAYER', 'mplayer', 'player for the iTV feed, must support 
http://'),
-            ('ITV_ARGS', '-nolirc -nojoystick -autoq 100 -screenw 800 -screenh 
600 -fs ', 'player options'),
-            ('ITV_LOCATIONS', [
+        return [('ITV_LOCATIONS', [
                 ('JT LCI 18h', 'http://tf1.lci.fr/xml/rss/0,,14,00.xml'),
                 ('JT i>Tele', 
'http://podcast12.streamakaci.com/iTELE/iTELElejournal.xml'),
                 ('Flash Equipe', 
'http://www.lequipe.fr/Podcast/flashETV_rss.xml'),
                 ('M�t�o LCI', 'http://tf1.fr/xml/rss/0,,23,00.xml'),
                 ('M�t�o France 2', 'file:///home/henri2/.freevo/meteo.xml')],
-            'where to get the news')]
+                 'where to get the news')]
 
     def items(self, parent):
         return [ HeadlinesMainMenuItem(parent) ]
@@ -111,34 +106,28 @@
     """
     def __init__(self, parent):
         Item.__init__(self, parent)
+        self.parent = parent
         self.url = ''
         self.cachedir = '%s/itv' % config.FREEVO_CACHEDIR
         if not os.path.isdir(self.cachedir):
             os.mkdir(self.cachedir,
                      
stat.S_IMODE(os.stat(config.FREEVO_CACHEDIR)[stat.ST_MODE]))
         self.location_index = None
-        self.player        = ChaineItem(self, "http","file://")
-
-    def eventhandler(self, event, menuw=None):
-        """
-        eventhandler
-        """
-        if event in ('USER_END','PLAY_END','STOP'):
-            self.player.stop()
-            menuw.show()
-            return True
-
-        return False
-
+   
+     
     def actions(self):
         """
         return a list of actions for this item
         """
-        items = [ ( self.getheadlines , _('Show Sites Headlines') ) ]
+        items = [ ( self.getheadlines, _('Show Sites Headlines') ) ]
         return items
 
 
     def getsiteheadlines(self):
+        """
+        this returns the raw headlines (title, link and description tuples),
+        it reads them from the cache file or fetches them from the internet.
+        """
         headlines = []
         pfile = os.path.join(self.cachedir, 'itv-%i' % self.location_index)
         if (os.path.isfile(pfile) == 0 or \
@@ -152,6 +141,10 @@
 
 
     def fetchheadlinesfromurl(self):
+        """ 
+        this fetches the headlines (title, link and description) from the url.
+        Here the parsing of the xml is done
+        """
         headlines = []
         # create Reader object
         reader = Sax2.Reader()
@@ -202,22 +195,18 @@
         return headlines
 
 
-    def show_details(self, arg=None, menuw=None):
-        self.player.mode = 'http'
-        self.player.url = arg.link
-        lien = arg.link
-        self.player.play(lien, menuw)
-
-
     def getheadlines(self, arg=None, menuw=None):
+        """
+        this returns a menu with VideoItems for each headline
+        """
         headlines = []
         rawheadlines = []
         rawheadlines = self.getsiteheadlines()
         for title, link, description in rawheadlines:
-            mi = menu.MenuItem('%s' % title, self.show_details, 0)
-            mi.arg = mi
-            mi.link = link
-
+            # create a VideoItem for each headline  
+            mi = VideoItem(link, self.parent)
+            mi.name = title
+            
             description = description.replace('\n\n', '&#xxx;').replace('\n', 
' ').\
                           replace('&#xxx;', '\n')
             description = description.replace('<p>', '\n').replace('<br>', 
'\n')
@@ -225,11 +214,11 @@
             description = description + '\n \n \nLink: ' + link
             description = util.htmlenties2txt(description)
 
-            mi.description = re.sub('<.*?>', '', description)
+            mi.plot = re.sub('<.*?>', '', description)
 
             headlines.append(mi)
 
-
+        # create the menu
         if (len(headlines) == 0):
             headlines += [menu.MenuItem(_('No Headlines found'), 
menuw.goto_prev_page, 0)]
 
@@ -270,15 +259,4 @@
         menuw.pushmenu(headlines_site_menu)
         menuw.refresh()
 
-class ChaineItem(VideoItem):
-    """
-    Item for the menu for one rss feed
-    """
-    def __init__(self, parent, flux_name,flux_location):
-        VideoItem.__init__(self, flux_location, parent)
-        self.network_play = True
-        self.parent       = parent
-        self.location     = flux_location
-        self.name         = '' #parent.name
-        self.type = 'video'
-        self.force_player = 'mplayer'
+

Modified: branches/rel-1/freevo/src/video/configure.py
==============================================================================
--- branches/rel-1/freevo/src/video/configure.py        (original)
+++ branches/rel-1/freevo/src/video/configure.py        Sun Nov 18 05:40:25 2007
@@ -4,8 +4,6 @@
 # -----------------------------------------------------------------------
 # $Id$
 #
-# Notes: Not integrated right now
-# Todo:  Fix some stuff, wait for the mplayer people what they are doing
 #
 # -----------------------------------------------------------------------
 # Freevo - A Home Theater PC framework
@@ -273,9 +271,11 @@
     next_start = 0
     items = []
 
+    if len(item.possible_player) >1:
+            items.append(menu.MenuItem(_('Play with alternate player'), 
+                         player_selection_menu, item))
+
     if item.filename or (item.mode in ('dvd', 'vcd') and item.player_rating >= 
20):
-        if len(item.possible_player) >1:
-            items.append(menu.MenuItem(_('Play with alternate player'), 
player_selection_menu, item))
         if item.info.has_key('audio') and len(item.info['audio']) > 1:
             items.append(menu.MenuItem(_('Audio selection'), 
audio_selection_menu, item))
         if item.info.has_key('subtitles') and len(item.info['subtitles']) >= 1:

Modified: branches/rel-1/freevo/src/video/plugins/xine.py
==============================================================================
--- branches/rel-1/freevo/src/video/plugins/xine.py     (original)
+++ branches/rel-1/freevo/src/video/plugins/xine.py     Sun Nov 18 05:40:25 2007
@@ -131,6 +131,9 @@
         if item.mimetype in config.VIDEO_XINE_SUFFIX:
             _debug_('%r good' % (item.url))
             return 2
+        if item.mode in ('http') and not item.filename and not item.media:
+            _debug_('%r unplayable' % (item.url), 2)
+            return 0   
         if item.network_play:
             _debug_('%r possible' % (item.url))
             return 1

Modified: branches/rel-1/freevo/src/video/videoitem.py
==============================================================================
--- branches/rel-1/freevo/src/video/videoitem.py        (original)
+++ branches/rel-1/freevo/src/video/videoitem.py        Sun Nov 18 05:40:25 2007
@@ -83,7 +83,7 @@
         self.set_url(url, info=parse)
         if info:
             self.info.set_variables(info)
-
+        
 
         # deinterlacing and related things
         video_deinterlace = config.VIDEO_DEINTERLACE != None and 
config.VIDEO_DEINTERLACE or False
@@ -198,11 +198,15 @@
                 rating += 1
             if hasattr(self, 'force_player') and p.name == self.force_player:
                 rating += 100
-            self.possible_player.append((rating, p))
+            if rating >10:
+                #exclude players that cannot play this item    
+                self.possible_player.append((rating, p))
+        # sort the players in the order of the rating        
         self.possible_player.sort(lambda l, o: -cmp(l[0], o[0]))
         if len(self.possible_player) > 0:
+            # choose the best player as default player     
             self.player_rating, self.player = self.possible_player[0]
-
+        _debug_(self.possible_player, 2)       
 
 
     def id(self):
@@ -449,7 +453,7 @@
         play the item.
         """
 
-        if not self.player:
+        if not self.player or self.player_rating<10:
             AlertBox(text=_('No player for this item found')).show()
             return
 
@@ -533,18 +537,6 @@
                     (self.media_id, self.url), handler=self.play).show()
                 return
 
-        elif self.mode in ('http') and not self.filename and not self.media:
-            self.player_rating, self.player = self.possible_player[0]
-            self.player_rating = 20
-            for p in plugin.getbyname(plugin.VIDEO_PLAYER, True):
-                rating = p.rate(self) * 10
-                if p.name == 'mplayer':
-                    self.player = p
-
-        if self.player_rating < 10:
-            AlertBox(text=_('No player for this item found')).show()
-            return
-
         mplayer_options = self.mplayer_options.split(' ')
         if not mplayer_options:
             mplayer_options = []

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to