Re: Patch for kaa.epg

"Adam Charrett" <[email protected]>
Newsgroups gmane.comp.video.freevo.devel
Message-ID <[email protected]>
On Wed, April 28, 2010 6:49 pm, Jason Tackaberry wrote:
> Hi Adam,
>
> On Wed, 2010-04-28 at 13:14 +0100, Adam Charrett wrote:
>> 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.
>
> Cool.  Would be nice to get kaa.epg a bit more testing.
>
>
>>              'title':'title',
>>              'sub-title':'subtitle',
>>              'episode-num':'episode',
>> -            'category':'genre',
>> +            'category':'genres',
>>              'desc':'desc',
>>              'date':'date'
>>              }
>
> I don't think the 'category' key is needed at all now with your patch,
> no?

Agreed,

>
>> @@ -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'
>
> Better to use self._current = name here, as with display-name.

Agreed,

>> +            elif self._current == 'genre':
>> +                self._dict['genres'][-1] += ch
>
> And then check for 'category' here.

Same again, agreed :-)

>
>> -            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]
>
> Surely this is also a bug fix?  Looks like the current code would only
> actually add channels whose names _couldn't_ be determined, which your
> patch fixes.

Indeed it is I forgot to mention it :-)

> Otherwise looks ok.  I assume you tested it. :)  Please comment on the
> above and either submit a new patch or let me know if you agree and I
> can make the changes when committing.

Yep tested using the test scripts in the tests directory :-)
2nd patch attached.

> Thanks,
> Jason.
>

Cheers

Adam

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

_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel
kaa.epg.xmltv-2.patch (text/x-patch, 3.3 KB)
Index: src/sources/xmltv.py
===================================================================
--- src/sources/xmltv.py	(revision 4218)
+++ src/sources/xmltv.py	(working copy)
@@ -92,7 +92,6 @@
             'title':'title',
             'sub-title':'subtitle',
             'episode-num':'episode',
-            'category':'genre',
             'desc':'desc',
             'date':'date'
             }
@@ -156,6 +155,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 = name
         elif name in self.mapping:
             # translate element name using self.mapping
             name = self.mapping[name]
@@ -171,7 +175,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 == 'category':
+                self._dict['genres'][-1] += ch
             else:
                 self._dict[self._current] += ch
 
@@ -187,6 +193,7 @@
             # fill programme info to database
             self.handle_programme(self._dict)
             self._dict = None
+            
         # in any case:
         self._current = None
 
@@ -217,8 +224,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.