本文整理汇总了Python中channel.Channel.update方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.update方法的具体用法?Python Channel.update怎么用?Python Channel.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类channel.Channel
的用法示例。
在下文中一共展示了Channel.update方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_channel_state
# 需要导入模块: from channel import Channel [as 别名]
# 或者: from channel.Channel import update [as 别名]
def on_channel_state(self, msg):
if msg.channel_id not in self.channels_by_id:
chan = Channel(self.bot, msg.channel_id)
self.channels_by_id[msg.channel_id] = chan
else:
chan = self.channels_by_id[msg.channel_id]
chan.update(msg)
if msg.parent == msg.channel_id:
if not msg.channel_id == 0:
LOGGER.warning('Root channel not ID 0.')
if self.root and self.root != chan:
LOGGER.error('Received 2 different roots...?')
raise Exception('Two roots.')
self.root = chan
elif chan.parent:
if chan.parent.id != msg.parent:
chan.parent.remove_child(chan)
self.channels_by_id[msg.parent].add_child(chan)
else:
if not msg.parent in self.channels_by_id:
LOGGER.error('Parent ID passed by server is not in the channel list.')
raise Exception('Invalid Parent.')
self.channels_by_id[msg.parent].add_child(chan)
print msg
示例2: importChannels
# 需要导入模块: from channel import Channel [as 别名]
# 或者: from channel.Channel import update [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)