本文整理汇总了Python中channel.Channel.add_option方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.add_option方法的具体用法?Python Channel.add_option怎么用?Python Channel.add_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类channel.Channel
的用法示例。
在下文中一共展示了Channel.add_option方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_tv_channels_from_part
# 需要导入模块: from channel import Channel [as 别名]
# 或者: from channel.Channel import add_option [as 别名]
def get_tv_channels_from_part(text):
line_where_first_channel_starts = 15
attributes_per_item = 6
list_to_iterate = text.split("|")[line_where_first_channel_starts:-1]
while "\n" in list_to_iterate:
list_to_iterate.remove("\n")
channel_list = []
for i in range(0, len(list_to_iterate), attributes_per_item):
item_name = list_to_iterate[i].strip()
item_options = list_to_iterate[i + 1].strip()
item_web = list_to_iterate[i + 2].strip()
if len(item_web) > 0 and item_web[0] != "-":
item_web = stringbetweenparantheses(item_web)
if len(item_web) == 1:
item_web = ""
if "HD" in item_name:
item_resolution = "HD"
else:
item_resolution = "SD"
item_logo = list_to_iterate[i + 3].strip()
if len(item_logo) > 0 and item_logo[0] != "-":
item_logo = stringbetweenparantheses(item_logo)
if len(item_logo) == 1:
item_logo = ""
item_epg = list_to_iterate[i + 4].strip()
if len(item_epg) == 1:
item_epg = ""
item_extra_info = list_to_iterate[i + 5].strip()
if len(item_extra_info) == 1:
item_extra_info = ""
channel = Channel(item_name, item_web, item_resolution, item_logo, item_epg, item_extra_info)
item_options = item_options.split(" - ")
if len(item_options) > 0 and item_options[0] != "-":
for option in item_options:
format = (option[1:5]).replace("]", "")
url = stringbetweenparantheses(option)
channel.add_option(format, url)
channel_list.append(channel)
return channel_list