Example #1
0
def _channels():

    # Fetch remote data
    log.info('fetch free to air channel info')
    chn_data = cache.get_data('uk_satellite_channels.csv', ttl=86400 * 7)
    reg_data = cache.get_data('uk_satellite_regions.csv', ttl=86400 * 7)

    # Channels list
    log.info('processing channel list')
    regional = []
    chns = []
    for l in chn_data.splitlines()[1:]:
        p = l.strip().split(',')
        if len(p) < 9: continue
        try:
            c = Channel()
            c.extra['stream'] = [(int(p[0]), p[1])]
            c.uri = p[2]
            c.title = p[3]
            c.extra['freesat_number'] = int(p[4])
            c.number = c.extra['sky_number'] = int(p[5])
            c.hd = p[6] == '1'
            c.radio = p[8] == '1'
            if (p[10]):
                c.image = p[10]
            else:
                c.image = p[9]

            # Skip
            if not c.uri: continue

            # Already included
            if c in chns:
                for t in chns:
                    if t == c:
                        t.extra['stream'].extend(c.extra['stream'])
                        break
                continue

            # Regional channel
            if p[7] == '1':
                regional.append(c)

            # Store
            elif c.extra['stream'][0][0]:
                chns.append(c)

        except Exception, e:
            log.error('failed to process [%s] [e=%s]' % (l, str(e)))
Example #2
0
def load_channels ():
  ret = set()
  log.info('get atlas channel list')

  # Process
  data = cache.get_data('atlas_channels.csv')
  if data:
    for l in data.splitlines():
      p = map(lambda x: x.strip(), l.split(','))
      if len(p) < 3: continue
      c = Channel()
      c.uri       = p[0]
      c.shortid   = p[1]
      c.publisher = [ p[3] ]
      ret.add(c)
  return ret
Example #3
0
def load_channels():
    ret = set()
    log.info('get atlas channel list')

    # Process
    data = cache.get_data('atlas_channels.csv')
    if data:
        for l in data.splitlines():
            p = map(lambda x: x.strip(), l.split(','))
            if len(p) < 3: continue
            c = Channel()
            c.uri = p[0]
            c.shortid = p[1]
            c.publisher = [p[3]]
            ret.add(c)
    return ret
Example #4
0
def _channels ():

  # Fetch remote data
  log.info('fetch free to air channel info')
  chn_data = cache.get_data('uk_satellite_channels.csv', ttl=86400*7)
  reg_data = cache.get_data('uk_satellite_regions.csv', ttl=86400*7)

  # Channels list
  log.info('processing channel list')
  regional = []
  chns     = []
  for l in chn_data.splitlines()[1:]:
    p = l.strip().split(',')
    if len(p) < 9: continue
    try:
      c = Channel()
      c.extra['stream']                = [ (int(p[0]), p[1]) ] 
      c.uri                            = p[2]
      c.title                          = p[3]
      c.extra['freesat_number']        = int(p[4])
      c.number = c.extra['sky_number'] = int(p[5])
      c.hd                             = p[6] == '1'
      c.radio                          = p[8] == '1'
      if (p[10]):
        c.image                        = p[10]
      else:
        c.image                        = p[9]

      # Skip
      if not c.uri: continue

      # Already included
      if c in chns:
        for t in chns:
          if t == c:
            t.extra['stream'].extend(c.extra['stream'])
            break
        continue

      # Regional channel
      if p[7] == '1': 
        regional.append(c)

      # Store
      elif c.extra['stream'][0][0]:
        chns.append(c)

    except Exception, e:
      log.error('failed to process [%s] [e=%s]' % (l, str(e)))
Example #5
0
def get_channels(package=None):

    # Get defaults
    if package is None: package = get_package()

    # Map channels
    channels = map(lambda x: Channel(x), conf.get('channel[]', []))
    if package:
        channels = package.channels(channels)

    return channels
Example #6
0
def process_channel(data):
    ret = None
    try:
        c = Channel()
        if 'title' in data:
            c.title = data['title'].encode('utf8')
        elif 'channel_title' in data:
            c.title = data['channel_title'].encode('utf8')
        if 'uri' in data:
            c.uri = data['uri']
        elif 'channel_uri' in data:
            c.uri = data['channel_uri']
        if 'channel_key' in data:
            c.shortid = data['channel_key']
        elif 'id' in data:
            c.shortid = data['id']
        if 'broadcaster' in data and 'key' in data['broadcaster']:
            c.publisher.append(data['broadcaster']['key'])
        if 'media_type' in data:
            c.radio = data['media_type'] == 'audio'
        c.hd = 'HD' in c.title
        ret = c
    except Exception, e:
        log.error(str(e))
Example #7
0
def process_channel ( data ):
  ret = None
  try:
    c = Channel()
    if 'title' in data:
      c.title = data['title'].encode('utf8')
    elif 'channel_title' in data:
      c.title = data['channel_title'].encode('utf8')
    if 'uri' in data:
      c.uri   = data['uri']
    elif 'channel_uri' in data:
      c.uri   = data['channel_uri']
    if 'channel_key' in data:
      c.shortid = data['channel_key']
    elif 'id' in data:
      c.shortid = data['id']
    if 'broadcaster' in data and 'key' in data['broadcaster']:
      c.publisher.append(data['broadcaster']['key'])
    if 'media_type' in data:
      c.radio = data['media_type'] == 'audio'
    c.hd      = 'HD' in c.title
    ret = c
  except Exception, e:
    log.error(str(e))