Author: duncan
Date: Sat Feb 24 14:18:29 2007
New Revision: 9268

Added:
   branches/rel-1/freevo/src/plugins/freeboxtv.py   (contents, props changed)
   branches/rel-1/freevo/src/video/plugins/vlc.py   (contents, props changed)

Log:
Two plug-ins for running freevo with vlc
From Valère JEANTET RAMOS


Added: branches/rel-1/freevo/src/plugins/freeboxtv.py
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/plugins/freeboxtv.py      Sat Feb 24 14:18:29 2007
@@ -0,0 +1,153 @@
+# encoding: utf-8
+
+# Valere JEANTET RAMOS 2
+# Copyright (c) 2006 Valère JEANTET RAMOS
+# COOLLLO
+
+import sys
+import os
+import codecs
+import urllib
+
+#regular expression
+import re
+
+
+#freevo modules
+import config, menu, rc, plugin, skin, osd, util
+from gui   import PopupBox, AlertBox, ConfirmBox
+from item  import Item
+from video import VideoItem
+
+#get the singletons so we get skin info and access the osd
+skin = skin.get_singleton()
+osd  = osd.get_singleton()
+
+
+class PluginInterface(plugin.MainMenuPlugin):
+    """
+    A plugin to obtain TV streams on Freevo
+
+    To activate, put the following lines in local_conf.py:
+
+    plugin.activate('freebox TV', level=45)
+    PLUGIN_FREEBOXTV_LOCATION = 
"http://mafreebox.freebox.fr/freeboxtv/playlist.m3u";
+    plugin.activate('video.vlc')
+    # ================
+    # VLC Settings :
+    # ================
+    VLC_NICE    = -30
+    VLC_CMD     = CONF.vlc
+
+    dans /etc/freevo/freevo.conf
+    rajouter
+    vlc = /usr/bin/vlc
+    """
+    # make an init func that creates the cache dir if it don't exist
+    def __init__(self):
+        if not hasattr(config, 'PLUGIN_FREEBOXTV_LOCATION'):
+            PLUGIN_FREEBOXTV_LOCATION = 
"http://mafreebox.freebox.fr/freeboxtv/playlist.m3u";
+        plugin.MainMenuPlugin.__init__(self)
+
+
+    def config(self):
+        return [('PLUGIN_FREEBOXTV_LOCATION',\
+            "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u",\
+            "Location url to grab streams list" )]
+
+
+    def items(self, parent):
+        return [ FreeboxTVMainMenu(parent) ]
+
+
+
+class FreeboxTVMainMenu(Item):
+    """
+    this is the item for the main menu and creates the list
+    of TV channels in a submenu.
+    """
+    def __init__(self, parent):
+        Item.__init__(self, parent, skin_type='tv')
+        self.parent = parent
+        self.name   = _('Freebox TV')
+
+
+    def actions(self):
+        """
+        return a list of actions for this item
+        """
+        items = [ ( self.create_Streamslocation_menu , _('Freebox TV :: Les 
chaines') ) ]
+        return items
+
+
+    def __call__(self, arg=None, menuw=None):
+        """
+        call first action in the actions() list
+        """
+        if self.actions():
+            return self.actions()[0][0](arg=arg, menuw=menuw)
+
+
+    def create_Streamslocation_menu(self, arg=None, menuw=None):
+        chaines_items  = []
+        lesFlux = []
+        autoselect = 0
+
+        # recuperation des chaines dans le tableau lesFlux
+        lesFlux = self.getChaines(config.PLUGIN_FREEBOXTV_LOCATION)
+        keys = lesFlux.keys()
+        keys.sort()
+
+        for c_name in keys:
+            chaine_item = ChaineItem(self, c_name,lesFlux[c_name])
+            #chaine_item = VideoItem(self, lesFlux[location],self.parent)
+            #chaine_item.name = location
+
+            # Only display this entry if no errors were found
+            chaines_items.append ( chaine_item )
+
+        # if only 1 valid location, autoselect it and go right to the detail 
screen
+
+        # if no locations were found, add a menu entry indicating that
+        if not chaines_items:
+            nolocation = menu.MenuItem(_('No locations specified'), 
menuw.goto_prev_page, 0)
+            chaines_items.append( nolocation )
+
+        # create menu
+        freeboxtv_site_menu = menu.Menu(_('Freebox TV :: Les chaines 
Multiposte'), chaines_items)
+        menuw.pushmenu(freeboxtv_site_menu)
+        menuw.refresh()
+
+
+    def getChaines(self,zeUrl):
+        filehandle = urllib.urlopen(zeUrl)
+        i = "o"
+        d = {}
+        while i <> "":
+            if re.search ( '#EXTINF', i ):
+                result = re.match('#EXTINF:.* - (.*)',i)
+                i=filehandle.readline()
+                d[result.group(1)] = i[0:len(i)-1]
+            i=filehandle.readline()
+
+        return d
+
+
+
+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         = flux_name.decode('utf8')
+        self.type = 'video'
+        self.force_player = 'vlc'
+
+
+
+if __name__ == '__main__':
+    print "Plugin Freevo for Freebox :: http://www.sodadi.com/freevo/freebox";

Added: branches/rel-1/freevo/src/video/plugins/vlc.py
==============================================================================
--- (empty file)
+++ branches/rel-1/freevo/src/video/plugins/vlc.py      Sat Feb 24 14:18:29 2007
@@ -0,0 +1,111 @@
+# -*- coding: iso-8859-1 -*-
+
+# vlc.py - based on mplayer.py and xine.py
+
+import os, re
+import threading
+import popen2
+#import kaa.metadata as metadata
+
+import config     # Configuration handler. reads config file.
+import util       # Various utilities
+import childapp   # Handle child applications
+import rc         # The RemoteControl class.
+import plugin
+
+from event import *
+
+class PluginInterface(plugin.Plugin):
+    """
+    VLC plugin for the video player, for RTSP streams
+    """
+    def __init__(self):
+        plugin.Plugin.__init__(self)
+        plugin.register(Vlc(), plugin.VIDEO_PLAYER, True)
+
+
+
+class Vlc:
+    """
+    the main class to control vlc
+    """
+    def __init__(self):
+        """
+        init the vlc object
+        """
+        self.name       = 'vlc'
+        self.app_mode   = 'video'
+        self.app        = None
+        self.plugins    = []
+        self.cmd        = config.VLC_CMD
+
+
+    def rate(self, item):
+        """
+        How good can this player play the file:
+        2 = good
+        1 = possible, but not good
+        0 = unplayable
+        """
+        if item.url[:7] == 'rtsp://':
+            return 2
+        return 0
+
+
+    def play(self, options, item):
+        """
+        play a videoitem with vlc
+        """
+        self.options = options
+        self.item    = item
+
+        mode         = item.mode
+        url          = item.url
+
+        self.item_info    = None
+        self.item_length  = -1
+        self.item.elapsed = 0
+
+        try:
+            _debug_('Vlc.play(): url=%s' % url)
+        except UnicodeError:
+            _debug_('Vlc.play(): [non-ASCII data]')
+
+        command = self.cmd + ' --intf dummy -f --key-quit=esc "%s"' % url
+        rc.app(self)
+
+        self.app = childapp.ChildApp2(command)
+        return None
+
+
+    def stop(self):
+        """
+        Stop vlc
+        """
+        if not self.app:
+            return
+        self.app.kill(2)
+
+        rc.app(None)
+        self.app = None
+
+
+    def eventhandler(self, event, menuw=None):
+        """
+        eventhandler for vlc control. If an event is not bound in this
+        function it will be passed over to the items eventhandler
+        """
+        #print "VLC::EventHendler : " + str(event)
+        if not self.app:
+            #print "VLC::Eventhandler : NNE"
+            return self.item.eventhandler(event)
+
+        if event == STOP:
+            self.stop()
+            return self.item.eventhandler(event)
+
+        if event in ( PLAY_END, USER_END ):
+            self.stop()
+            return self.item.eventhandler(event)
+
+        return self.item.eventhandler(event)

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to