Patch for kaa.epg

"Adam Charrett" <[email protected]>
Newsgroups gmane.comp.video.freevo.devel
Message-ID <[email protected]>
I'm starting to look into moving freevo 1.x to using the kaa.epg as I'm
hoping this should reduce memory requirements for my record server. Also
it should allow me to have only 1 database of the EPG on the database for
both my recording server and frontend.

Anyway while investigating kaa.epg I found some bugs and here's the patch
to fix them.

Briefly source.xmltv was trying to use 'genre' when adding a program but
that doesn't exists so it now uses 'genres' and can supply a list of
categories/genres.

There was a minor bug in kaa.epg.Guide where if the database path didn't
have a name os.path.makedirs would fail.

An additional argument was removed from the epg call in
kaa.epg.rpc.Client.search.


Cheers

Adam

------------------------------------------------------------------------------

_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel
kaa.epg.xmltv.patch (text/x-patch, 3.4 KB)
Index: src/sources/xmltv.py
===================================================================
--- src/sources/xmltv.py	(revision 4218)
+++ src/sources/xmltv.py	(working copy)
@@ -92,7 +92,7 @@
             'title':'title',
             'sub-title':'subtitle',
             'episode-num':'episode',
-            'category':'genre',
+            'category':'genres',
             'desc':'desc',
             'date':'date'
             }
@@ -156,6 +156,11 @@
             stop = attrs.get('stop',None)
             self._dict['stop'] = stop
             self._dict['channel_id'] = attrs.get('channel',None)
+        elif name == 'category':
+            if 'genres' not in self._dict:
+                self._dict['genres']=[]
+            self._dict['genres'].append(u'')
+            self._current = 'genre'
         elif name in self.mapping:
             # translate element name using self.mapping
             name = self.mapping[name]
@@ -171,7 +176,9 @@
         if self._dict is not None and self._current:
             if self._current == 'display-name':
                 # there might be more than one display-name
-                self._dict['display-name'][-1] +=ch
+                self._dict['display-name'][-1] += ch
+            elif self._current == 'genre':
+                self._dict['genres'][-1] += ch
             else:
                 self._dict[self._current] += ch
 
@@ -187,6 +194,7 @@
             # fill programme info to database
             self.handle_programme(self._dict)
             self._dict = None
+            
         # in any case:
         self._current = None
 
@@ -217,8 +225,11 @@
             # stuff, maybe others work different. Maybe check the <tv> tag
             # for the used grabber somehow.
             name = display or station
-            db_id = self.add_channel(tuner_id=channel, name=station, long_name=name)
-            self.channels[attr['channel_id']] = [db_id, None]
+        if not channel:
+            channel = channel_id
+            
+        db_id = self.add_channel(tuner_id=channel, name=station, long_name=name)
+        self.channels[attr['channel_id']] = [db_id, None]
 
     def handle_programme(self, attr):
         """
Index: src/guide.py
===================================================================
--- src/guide.py	(revision 4218)
+++ src/guide.py	(working copy)
@@ -52,8 +52,9 @@
     EPG guide with db access.
     """
     def __init__(self, database):
-        if not os.path.isdir(os.path.dirname(database)):
-            os.makedirs(os.path.dirname(database))
+        db_dir = os.path.dirname(database)
+        if db_dir and not os.path.isdir(db_dir):
+            os.makedirs(db_dir)
         self._db = Database(database)
         # create the db and register objects
         self._db.register_inverted_index('keywords', min = 2, max = 30)
Index: src/rpc.py
===================================================================
--- src/rpc.py	(revision 4218)
+++ src/rpc.py	(working copy)
@@ -160,7 +160,7 @@
                 time = convert(time[0]), convert(time[1])
             else:
                 time = convert(time)
-        query_data = yield self.channel.rpc('search', channel, time, True, None, **kwargs)
+        query_data = yield self.channel.rpc('search', channel, time, None, **kwargs)
         # Convert raw search result data from the server into python objects.
         results = []
         channel = None
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.