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 _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)))