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


Python Channel.add_option方法代碼示例

本文整理匯總了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
開發者ID:Josele33,項目名稱:TDTChannels,代碼行數:48,代碼來源:utils.py


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