Update of /cvsroot/freevo/freevo/src/tv
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23055
Modified Files:
channels.py
Log Message:
-Removed get_channels() because config/channels.py creates the only
ChannelList instance.
-Use sysconfig.datafile('epgdb').
-Move get_settings_by_id() and get_settings_by_name() into ChannelList.
-Also some tuner_id/access_id/call_sign/display_name cosmetic changes.
-Add checks and ballances when instantiating ChannelList. This checks the EPG,
TV_CHANNELS, TV_DEFAULT_SETTING (that can now be a list, or 'tv' to cover
tv0-n). It also supports multiple access_ids in TV_CHANNELS (3rd and up
entries). You should definately not see duplicate entries, TV_CHANNELS has
priority over the EPG.
Index: channels.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/tv/channels.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** channels.py 27 Nov 2004 15:00:10 -0000 1.34
--- channels.py 4 Dec 2004 01:45:09 -0000 1.35
***************
*** 43,46 ****
--- 43,47 ----
# freevo imports
import config
+ import sysconfig
import plugin
import item
***************
*** 51,55 ****
from program import ProgramItem
! EPGDB = os.path.join(config.FREEVO_CACHEDIR, 'epgdb')
_channels = None
--- 52,56 ----
from program import ProgramItem
! EPGDB = sysconfig.datafile('epgdb')
_channels = None
***************
*** 77,117 ****
- def get_channels():
- """
- Return an already created ChannelList, this may save a bit of time.
- """
- global _channels
- if not _channels:
- log.info('no channels in memory, loading')
- _channels = ChannelList()
- return _channels
-
-
- def get_settings_by_id(chan_id):
- """
- """
- settings = []
- for c in get_channels().get_all():
- if c.id == chan_id:
- for u in c.uri:
- which = u.split(':')[0]
- settings.append(which)
- return settings
- return None
-
-
- def get_settings_by_name(chan_name):
- """
- """
- settings = []
- for c in get_channels().get_all():
- if c.name == chan_name:
- for u in c.uri:
- which = u.split(':')[0]
- settings.append(which)
- return settings
- return None
-
-
def get_lockfile(which):
"""
--- 78,81 ----
***************
*** 271,291 ****
epg informations.
"""
! def __init__(self, id, display_name, uri):
item.Item.__init__(self)
self.chan_id = id
! self.tuner_id = ''
self.uri = []
self.programs = []
self.logo = ''
! if isinstance(uri, list) or isinstance(uri, tuple):
! for u in uri:
! self.__add_uri__(u)
else:
! self.__add_uri__(uri)
# XXX Change this to config.TV_CHANNEL_DISPLAY_FORMAT or something as
! # XXX many people won't want to see the tuner_id.
# XXX What should we use, name or title, or both?
self.name = self.title = display_name
--- 235,255 ----
epg informations.
"""
! def __init__(self, id, display_name, access_id):
item.Item.__init__(self)
self.chan_id = id
! self.access_id = ''
self.uri = []
self.programs = []
self.logo = ''
! if isinstance(access_id, list) or isinstance(access_id, tuple):
! for a_id in access_id:
! self.__add_uri__(a_id)
else:
! self.__add_uri__(access_id)
# XXX Change this to config.TV_CHANNEL_DISPLAY_FORMAT or something as
! # XXX many people won't want to see the access_id.
# XXX What should we use, name or title, or both?
self.name = self.title = display_name
***************
*** 295,306 ****
"""
Add a URI to the internal list where to find that channel.
! Also save the tuner_id because many people, mostly North Americans,
like to use it (usually in the display).
"""
if uri.find(':') == -1:
! self.info['tuner_id'] = uri
! uri = '%s:%s' % (config.TV_DEFAULT_SETTINGS, uri)
else:
! self.info['tuner_id'] = uri.split(':')[1]
self.uri.append(uri)
--- 259,292 ----
"""
Add a URI to the internal list where to find that channel.
! Also save the access_id because many people, mostly North Americans,
like to use it (usually in the display).
"""
if uri.find(':') == -1:
! self.access_id = uri
! defaults = []
! if isinstance(config.TV_DEFAULT_SETTINGS, list) or \
! isinstance(config.TV_DEFAULT_SETTINGS, tuple):
! for s in config.TV_DEFAULT_SETTINGS:
! defaults.append(s)
! else:
! defaults.append(config.TV_DEFAULT_SETTINGS)
!
! for which in defaults:
! try:
! int(which[-1:])
! except ValueError:
! # This means that TV_DEFAULT_SETTINGS does NOT end with
! # a number (it is dvb/tv/ivtv) so we add this channel
! # to all matching TV_SETTINGS.
! log.debug('TV_DEFAULT_SETTINGS does NOT end with a
number')
!
! for s in config.TV_SETTINGS.keys():
! if s.find(which) == 0:
! self.__add_uri__('%s:%s' % (s, uri))
! return
!
! uri = '%s:%s' % (which, uri)
else:
! self.access_id = uri.split(':')[1]
self.uri.append(uri)
***************
*** 316,319 ****
--- 302,306 ----
# try all internal URIs
for p in plugin.getbyname(plugin.TV, True):
+ print p
# FIXME: better handling for rate == 1 or 2
if p.rate(self, device, uri):
***************
*** 495,500 ****
return
for c in config.TV_CHANNELS:
! self.add_channel(ChannelItem(c[0], c[1], c[2]))
--- 482,541 ----
return
+ # Check the EPGDB for channels. If some of these exist in TV_CHHANELS
+ # we use that information if not we use the info from the database.
+ for c in self.epg.get_channels():
+ if String(c['id']) in config.TV_CHANNELS_EXCLUDE:
+ # Skip channels that we explicitly do not want.
+ continue
+
+ override = False
+ for cc in config.TV_CHANNELS:
+ if String(c['id']) == cc[0]:
+ # Override with config data.
+ self.add_channel(ChannelItem(cc[0], cc[1], cc[2:]))
+ override = True
+ break
+
+ if not override:
+ self.add_channel(ChannelItem(c['id'], c['display_name'],
c['access_id']))
+
+ # Check TV_CHANNELS for any channels that aren't in EPGDB then
+ # at them to the list.
for c in config.TV_CHANNELS:
! if c[0] in config.TV_CHANNELS_EXCLUDE:
! # Skip channels that we explicitly do not want.
! continue
! if not c[0] in self.channel_dict.keys():
! self.add_channel(ChannelItem(c[0], c[1], c[2:]))
!
!
! def sort_channels(self):
! pass
!
!
! def get_settings_by_id(self, chan_id):
! """
! """
! settings = []
! chan = self.channel_dict.get(chan_id)
! if chan:
! for u in c.uri:
! which = u.split(':')[0]
! settings.append(which)
!
! return settings
!
!
! def get_settings_by_name(self, chan_name):
! """
! """
! settings = []
! for c in self.channel_list:
! if c.name == chan_name:
! for u in c.uri:
! which = u.split(':')[0]
! settings.append(which)
!
! return settings
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog