Author: rshortt
Date: Sun Mar 12 16:51:45 2006
New Revision: 1279
Modified:
trunk/WIP/epg2/src/client.py
trunk/WIP/epg2/src/server.py
Log:
-do not wipe database
-change tuner_id into a list
-check for channel updates
-start checking for program updates (needs more work)
Modified: trunk/WIP/epg2/src/client.py
==============================================================================
--- trunk/WIP/epg2/src/client.py (original)
+++ trunk/WIP/epg2/src/client.py Sun Mar 12 16:51:45 2006
@@ -43,8 +43,8 @@
chan.db_id = db_id
self._channels_by_name[short_name] = chan
self._channels_by_db_id[db_id] = chan
- if tuner_id:
- self._channels_by_tuner_id[tuner_id] = chan
+ for t in tuner_id:
+ self._channels_by_tuner_id[t] = chan
self._channels_list.append(chan)
self._max_program_length = self._server.get_max_program_length()
@@ -109,7 +109,7 @@
if not short_name:
# then there must be one of the others
if tuner_id:
- short_name = tuner_id
+ short_name = tuner_id[0]
else:
short_name = long_name
@@ -117,8 +117,8 @@
# then there must be one of the others
if short_name:
long_name = short_name
- else:
- long_name = tuner_id
+ elif tuner_id:
+ long_name = tuner_id[0]
return Channel(tuner_id, short_name, long_name, epg=None)
Modified: trunk/WIP/epg2/src/server.py
==============================================================================
--- trunk/WIP/epg2/src/server.py (original)
+++ trunk/WIP/epg2/src/server.py Sun Mar 12 16:51:45 2006
@@ -1,4 +1,6 @@
import libxml2, sys, time, os, weakref, logging
+from types import ListType
+
from kaa.db import *
from kaa import ipc
from kaa.notifier import Signal
@@ -34,7 +36,7 @@
db = Database(dbfile)
db.register_object_type_attrs("channel",
- tuner_id = (unicode, ATTR_SEARCHABLE),
+ tuner_id = (list, ATTR_SIMPLE),
short_name = (unicode, ATTR_SEARCHABLE),
long_name = (unicode, ATTR_SEARCHABLE),
)
@@ -117,7 +119,8 @@
except ImportError:
raise ValueError, "No such update backend '%s'" % backend
- self._wipe()
+ # TODO: delte old programs
+ # self._wipe()
self.signals["update_progress"].connect_weak(self._update_progress,
time.time())
backend.update(self, *args, **kwargs)
@@ -165,7 +168,11 @@
If there is a tuner_id then it will assist programs using kaa.epg to
match real channels and EPG data.
"""
- log.debug('tuner_id: "%s" short_name: "%s" long_name: "%s"', tuner_id,
short_name, long_name)
+ log.debug('tuner_id: "%s" short_name: "%s" long_name: "%s"',
+ tuner_id, short_name, long_name)
+
+ if type(tuner_id) != ListType:
+ tuner_id = [ tuner_id ]
# require at least one field
if not tuner_id and not short_name and not long_name:
@@ -175,7 +182,7 @@
if not short_name:
# then there must be one of the others
if tuner_id:
- short_name = tuner_id
+ short_name = tuner_id[0]
else:
short_name = long_name
@@ -183,12 +190,29 @@
# then there must be one of the others
if short_name:
long_name = short_name
- else:
- long_name = tuner_id
+ elif tuner_id:
+ long_name = tuner_id[0]
+
+ if not tuner_id:
+ tuner_id = [ short_name ]
- # NOTE: by now we do not care if there is no tuner_id, it only helps
+ log.debug('tuner_id: "%s" short_name: "%s" long_name: "%s"',
+ tuner_id, short_name, long_name)
- log.debug('tuner_id: "%s" short_name: "%s" long_name: "%s"', tuner_id,
short_name, long_name)
+ c2 = self._db.query(type = "channel", short_name = short_name)
+ if len(c2):
+ c2 = c2[0]
+ log.debug('c2: %s', c2)
+
+ for t in tuner_id:
+ if t not in c2["tuner_id"]:
+ c2["tuner_id"].append(t)
+
+ # TODO: if everything is the same do not update
+ self._db.update_object(("channel", c2["id"]),
+ tuner_id = c2["tuner_id"],
+ long_name = long_name)
+ return c2["id"]
o = self._db.add_object("channel",
tuner_id = tuner_id,
@@ -198,16 +222,40 @@
def _add_program_to_db(self, channel_db_id, start, stop, title, desc):
- log.debug('channel_db_id: "%s" start: "%s" title: "%s"',
channel_db_id, start, title)
- o = self._db.add_object("program",
- parent = ("channel", channel_db_id),
- start = start,
- stop = stop,
- title = title,
- desc = desc, ratings = 42)
- if stop - start > self._max_program_length:
- self._max_program_length = stop = start
- return o["id"]
+ #log.debug('channel_db_id: "%s" start: "%s" title: "%s"',
+ # channel_db_id, start, title)
+
+ # TODO: check time range
+ p2 = self._db.query(parent = ("channel", channel_db_id),
+ type = "program", start = start)
+
+ if len(p2):
+ # we have a program at this time
+ p2 = p2[0]
+
+ log.debug('updating program: %s', p2["title"])
+ # TODO: if everything is the same do not update
+ self._db.update_object(("program", p2["id"]),
+ start = start,
+ stop = stop,
+ title = title,
+ desc = desc)
+ return p2["id"]
+
+ # TODO: check title, see if it is a different program. Also check
+ # if the program is the same but shifted times a bit
+ else:
+ log.debug('adding program: %s', title)
+ o = self._db.add_object("program",
+ parent = ("channel", channel_db_id),
+ start = start,
+ stop = stop,
+ title = title,
+ desc = desc, ratings = 42)
+
+ if stop - start > self._max_program_length:
+ self._max_program_length = stop = start
+ return o["id"]
def query(self, **kwargs):
-------------------------------------------------------
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