當前位置: 首頁>>代碼示例>>Python>>正文


Python Channel.checkExist方法代碼示例

本文整理匯總了Python中channel.Channel.checkExist方法的典型用法代碼示例。如果您正苦於以下問題:Python Channel.checkExist方法的具體用法?Python Channel.checkExist怎麽用?Python Channel.checkExist使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在channel.Channel的用法示例。


在下文中一共展示了Channel.checkExist方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: importChannels

# 需要導入模塊: from channel import Channel [as 別名]
# 或者: from channel.Channel import checkExist [as 別名]
  def importChannels(self):
    # self.createDb()
    # self.migrateDb()
    
    with open(SETTINGS.CHAN_LIST) as json_file:
      data = json.loads(json_file.read())
      json_file.close()

      self.cleanCategories()

      parsedIds = []

      for group in data['groups']:
        addon_log(str(group['id']) + " " + group['name'])
        cat = Category(id = group['id'], name=group['name'])
        cat.insert()
        
        for channel in group['channels']:
          #addon_log(str(channel['id'])+" "+unicode(channel['name'])+" "+ str(channel['language'])+" "+str(channel['status']))
          if ((not channel['unverified']) or (SETTINGS.SHOW_UNVERIFIED=='true')):

            #addon_log(channel['name'].encode('utf8'))

            # schedule_id = 0
            # thumbnail = ""
            # video_resolution = ""
            # video_aspect = 0
            # audio_codec = ""
            # video_codec = ""

            # stream_type = channel['stream_type']
            # if 'schedule' in channel:
            #   schedule = channel['schedule']
            #   schedule_id = schedule['ch_id']
            # if 'thumbnail' in channel:
            #   thumbnail = channel['thumbnail']
            # if 'video_resolution' in stream_type:
            #   video_resolution = stream_type['video_resolution']
            # if 'video_aspect' in stream_type:
            #   video_aspect = stream_type['video_aspect']
            # if 'audio_codec' in stream_type:
            #   audio_codec = stream_type['audio_codec']
            # if 'video_codec' in stream_type:
            #   video_codec = stream_type['video_codec']
            if(channel['status'] == 2): 
              status = Channel.STATUS_ONLINE 
            else: 
              status = Channel.STATUS_OFFLINE

            ch = Channel(id = str(channel['id']),
                         id_cat = group['id'],
                         name = channel['name'],
                         address = channel['address'], 
                         protocol = channel['protocol'],
                         language = channel['language'],
                         status = status,
                         unverified = channel['unverified']
                        )
            if((ch.checkExist() == False) and (ch.checkAddrExist() == False)):
              ch.insert()
            else:
              if(ch.checkIsMy() == False):
                ch.update(id_cat = group['id'],
                          name = channel['name'],
                          address = channel['address'], 
                          protocol = channel['protocol'],
                          language = channel['language'],
                          status = status,
                          unverified = channel['unverified'])
            
            if(ch.checkIsMy() == False):
              parsedIds.append(ch.id)
      
      addon_log('parsed %d channels' % len(parsedIds))
      self.cleanChannels(parsedIds)
開發者ID:moromete,項目名稱:plugin.video.streams,代碼行數:77,代碼來源:channels.py


注:本文中的channel.Channel.checkExist方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。