Author: dmeyer
Date: Tue Mar 21 16:57:07 2006
New Revision: 8122

Removed:
   trunk/core/src/ipc/epg.py
Modified:
   trunk/tvserver/bin/freevo-epg
   trunk/tvserver/bin/freevo-tvserver
   trunk/tvserver/src/config.py
   trunk/tvserver/src/epg.py

Log:
move epg update code into tvserver script

Modified: trunk/tvserver/bin/freevo-epg
==============================================================================
--- trunk/tvserver/bin/freevo-epg       (original)
+++ trunk/tvserver/bin/freevo-epg       Tue Mar 21 16:57:07 2006
@@ -62,106 +62,6 @@
 TVSERVER = {'type': 'home-theatre', 'module': 'tvserver'}
 
 
-def update_guide():
-    """
-    Update epg data.
-    """
-    
-    def update_progress(cur, total):
-        n = 0
-        if total > 0:
-            n = int((cur / float(total)) * 50)
-        sys.stdout.write("|%51s| %d / %d\r" % (("="*n + ">").ljust(51), cur, 
total))
-        sys.stdout.flush()
-        if cur == total:
-            print
-
-    import freevo.ipc.epg as epg
-    
-    guide = kaa.epg.guide
-
-    # FIXME: This needs a huge cleanup. The grabbing will block the main
-    # loop, that is a very bad idea. And we also have the problem that update
-    # does not work for some reason
-    #
-    # The whole update stuff has to move into the tvserver. The tvserver
-    # should have the epg config and only the tvserver. The rest can get it
-    # by asking the server.
-    
-    guide.signals["update_progress"].connect(update_progress)
-    guide.signals["updated"].connect(sys.exit)
-
-    if epg.config.xmltv.activate == 1:
-
-        data_file = str(epg.config.xmltv.data_file)
-        if not data_file:
-            data_file = os.path.join(kaa.TEMP, 'TV.xml')
-
-        if epg.config.xmltv.grabber and \
-           os.path.isfile(epg.config.xmltv.grabber.split()[0]):
-            # NOTE: should the grabbing code be put into a seperate module
-            #       so other programs can cal it?
-
-            log.info('grabbing listings using %s', epg.config.xmltv.grabber)
-            xmltvtmp = '/tmp/TV.xml.tmp'
-            ec = os.system('%s --output %s --days %s' % 
(epg.config.xmltv.grabber,
-                                                         xmltvtmp,
-                                                         
epg.config.xmltv.days))
-
-            if os.path.exists(xmltvtmp) and ec == 0:
-                if os.path.isfile(epg.config.xmltv.sort):
-                    log.info('sorting listings')
-                    os.system('%s --output %s %s' % (epg.config.xmltv.sort,
-                                                     xmltvtmp+'.1',
-                                                     xmltvtmp))
-
-                    shutil.move(xmltvtmp+'.1', xmltvtmp)
-
-                else:
-                    log.info('not configured to use tv_sort, skipping')
-
-                shutil.move(xmltvtmp, data_file)
-
-            else:
-                log.error('xmltv grabbing failed and returned exit code %d.', 
ec >> 8)
-                log.error('if you did not change your system, it is likely '+
-                          'that the site being grabbed did.  You might want to 
try '+
-                          'updating your xmltv: http://www.xmltv.org/')
-
-        else:
-            log.error('not configured to run XMLTV grabber')
-
-        if not os.path.isfile(data_file):
-            log.error('problem with data file, not updating EPG')
-
-        else:
-            log.debug('xmltv_file: %s', data_file)
-            log.info('loading data into EPG...')
-            guide.update("xmltv", data_file)
-
-    else:
-        log.info('not configured to use xmltv')
-
-
-    if epg.config.zap2it.activate == 1:
-        guide.update("zap2it", username=str(epg.config.zap2it.username), 
-                               passwd=str(epg.config.zap2it.password))
-
-    else:
-        log.info('not configured to use Zap2it')
-
-
-    if epg.config.vdr.activate == 1:
-        log.info('configured to use VDR')
-        guide.update("vdr", vdr_dir=str(epg.config.vdr.dir), 
-                     channels_file=str(epg.config.vdr.channels_file), 
-                     epg_file=str(epg.config.vdr.epg_file),
-                     host=str(epg.config.vdr.host), 
port=int(epg.config.vdr.port), 
-                     access_by=str(epg.config.vdr.access_by), 
-                     limit_channels=str(epg.config.vdr.limit_channels))
-
-    else:
-        log.info('not configured to use VDR')
 
 
 def search():

Modified: trunk/tvserver/bin/freevo-tvserver
==============================================================================
--- trunk/tvserver/bin/freevo-tvserver  (original)
+++ trunk/tvserver/bin/freevo-tvserver  Tue Mar 21 16:57:07 2006
@@ -106,12 +106,31 @@
 # get logging object
 log = logging.getLogger('record')
     
-if len(sys.argv) > 1 and sys.argv[1] == '-i':
-    # import interactive mode
-    from freevo.tvserver import interactive
+if len(sys.argv) > 1:
+
+    if sys.argv[1] == '-i':
+        # import interactive mode
+        from freevo.tvserver import interactive
+
+        kaa.main()
+        sys.exit(0)
+
+    if sys.argv[1] == 'update-epg':
+        # epg update
+        from freevo.tvserver import epg
+
+        # connect to tvserver
+        mbus = freevo.ipc.Instance('epg-update')
+        mbus.connect('freevo.ipc.tvserver')
+
+        # connect epg update
+        mbus.tvserver.epg.signals['connected'].connect(epg.update)
+
+        kaa.main()
+        sys.exit(0)
+
+    sys.exit(1)
 
-    kaa.main()
-    sys.exit(0)
 
 # get logging object
 log = logging.getLogger('record')

Modified: trunk/tvserver/src/config.py
==============================================================================
--- trunk/tvserver/src/config.py        (original)
+++ trunk/tvserver/src/config.py        Tue Mar 21 16:57:07 2006
@@ -29,10 +29,78 @@
     Var(name='dir', default='',
         desc=_('directory where to store recordings')) ]),
 
+
     # epg group
-    Group(name='epg', desc=_('epg settings'), schema=[
+    Group(name='epg', desc=_('EPG settings'), schema=[
     Var(name='database', default=freevo.conf.datafile('epg.sqlite'),
         desc=_('epg database file')),
+
+    # XMLTV settings
+    Group(name='xmltv', desc=_('''
+    XMLTV settings
+
+    You can use a xmltv rabber to populate the epg database. To activate the 
xmltv
+    grabber you need to set 'activate' to True and specify a data_file which 
already
+    contains the current listing or define a grabber to fetch the listings.
+    Optionally you can define arguments for that grabber and the location of a
+    sort program to sort the data after the grabber has finished.
+    '''), desc_type='group', schema = [
+    Var(name='activate', default=False,
+        desc=_('Use XMLTV file to populate database.')),
+    Var(name='data_file', default='',
+        desc=_('Location of XMLTV data file.')),
+    Var(name='grabber', default='',
+        desc=_('If you want to run an XMLTV grabber to fetch your listings\n'
+               'set this to the full path of your grabber program plus any\n'
+               'additional arguments.')),
+    Var(name='days', default=5,
+        desc=_('How many days of XMLTV data you want to fetch.')),
+    Var(name='sort', default='',
+        desc=_('Set this to the path of the tv_sort program if you need to\n'
+               'sort your listings.')),
+    ]),
+
+    # Zap2it settings
+    Group(name='zap2it', desc=_('''
+    Zap2it settings
+
+    Add more doc here please!
+    '''), desc_type='group', schema = [
+    Var(name='activate', default=False,
+        desc=_('Use Zap2it service to populate database.')),
+    Var(name='username', default='',
+        desc=_('Zap2it username.')),
+    Var(name='password', default='',
+        desc=_('Zap2it password.')),
+    ]),
+
+    # VDR settings
+    Group(name='vdr', desc=_('''
+    VDR settings
+
+    Add more doc here please!
+    '''), desc_type='group', schema = [
+    Var(name='activate', default=False,
+        desc=_('Use VDR to populate the database.')),
+    Var(name='dir', default='/video',
+        desc=_('VDR main directory.')),
+    Var(name='channels_file', default='channels.conf',
+        desc=_('VDR channels file name.')),
+    Var(name='epg_file', default='epg.data',
+        desc=_('VDR EPG file name.')),
+    Var(name='host', default='localhost',
+        desc=_('VDR SVDRP host.')),
+    Var(name='port', default=2001,
+        desc=_('VDR SVDRP port.')),
+    Var(name='access_by', type=('name', 'sid' 'rid'), default='sid',
+        desc=_('Which field to access channels by: name, sid (service id), \n'+
+               'or rid (radio id).')),
+    Var(name='limit_channels', type=('epg', 'chan' 'both'), default='chan',
+        desc=_('Limit channels added to those found in the EPG file, the \n'+
+               'channels file, or both.  Values: epg, chan, both')),
+    ]),
+
+    # EPG mapping
     Dict(name='mapping', type=unicode, schema=Var(type=unicode),
          desc=_('EPG channel mapping'))])
     ])

Modified: trunk/tvserver/src/epg.py
==============================================================================
--- trunk/tvserver/src/epg.py   (original)
+++ trunk/tvserver/src/epg.py   Tue Mar 21 16:57:07 2006
@@ -31,6 +31,7 @@
 # -----------------------------------------------------------------------------
 
 # python imports
+import sys
 import time
 import logging
 
@@ -43,6 +44,7 @@
 # record imports
 from record_types import *
 from recording import Recording
+from config import config
 
 # get logging object
 log = logging.getLogger('record')
@@ -204,3 +206,58 @@
 
         # done with this one favorite
         return True
+
+
+
+def update():
+    """
+    Update epg data.
+    """
+    def update_progress(cur, total):
+        n = 0
+        if total > 0:
+            n = int((cur / float(total)) * 50)
+        sys.stdout.write("|%51s| %d / %d\r" % (("="*n + ">").ljust(51), cur, 
total))
+        sys.stdout.flush()
+        if cur == total:
+            print
+
+    guide = kaa.epg.guide
+
+    guide.signals["update_progress"].connect(update_progress)
+    guide.signals["updated"].connect(sys.exit)
+
+    if config.epg.xmltv.activate == 1:
+
+        if not config.epg.xmltv.data_file:
+            log.error('XMLTV gabber not supported yet. Please download the')
+            log.error('file manually and set epg.xmltv.data_file')
+        else:
+
+            data_file = str(config.epg.xmltv.data_file)
+            log.info('loading data into EPG...')
+            guide.update("xmltv", data_file)
+            
+    else:
+        print 'not configured to use xmltv'
+
+
+    if config.epg.zap2it.activate == 1:
+        guide.update("zap2it", username=str(config.epg.zap2it.username), 
+                               passwd=str(config.epg.zap2it.password))
+
+    else:
+        print 'not configured to use Zap2it'
+
+
+    if config.epg.vdr.activate == 1:
+        print 'update epg based on vdr data'
+        guide.update("vdr", vdr_dir=str(config.epg.vdr.dir), 
+                     channels_file=str(config.epg.vdr.channels_file), 
+                     epg_file=str(config.epg.vdr.epg_file),
+                     host=str(config.epg.vdr.host), 
port=int(config.epg.vdr.port), 
+                     access_by=str(config.epg.vdr.access_by), 
+                     limit_channels=str(config.epg.vdr.limit_channels))
+
+    else:
+        print 'not configured to use VDR'


-------------------------------------------------------
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

Reply via email to