Esempio n. 1
0
def reorder_preset_elements(elementslist):
    log_debug('reorder_preset_elements', 2)
    newelementslist = []
    maxpresetnum = get_max_preset_num(elementslist)
    presetnum = 1
    while presetnum <= maxpresetnum:
        for element in elementslist:
            if 'show' in element and utils.get_int(element['show'], 'preset_number') == presetnum:
                newelementslist.append({'show': element['show']})
                break
            elif 'station' in element and utils.get_int(element['station'], 'preset_number') == presetnum:
                newelementslist.append({'station': element['station']})
                break
            elif 'link' in element and __tunein__.is_custom_url_id(utils.get_value(element['link'], 'guide_id')) and utils.get_int(element['link'], 'preset_number') == presetnum:
                newelementslist.append({'link': element['link']})
                break
        presetnum = presetnum + 1

    # Add any links or topics to ordered elements list.
    for element in elementslist:
        if 'link' in element and not __tunein__.is_custom_url_id(utils.get_value(element['link'], 'guide_id')):
            newelementslist.append({'link': element['link']})
        elif 'topic' in element:
            newelementslist.append({'topic': element['topic']})

    return newelementslist
Esempio n. 2
0
def reorder_preset_elements(elementslist):
    log_debug("reorder_preset_elements", 2)
    newelementslist = []
    maxpresetnum = get_max_preset_num(elementslist)
    presetnum = 1
    while presetnum <= maxpresetnum:
        for element in elementslist:
            if "show" in element and utils.get_int(element["show"], "preset_number") == presetnum:
                newelementslist.append({"show": element["show"]})
                break
            elif "station" in element and utils.get_int(element["station"], "preset_number") == presetnum:
                newelementslist.append({"station": element["station"]})
                break
            elif (
                "link" in element
                and __tunein__.is_custom_url_id(utils.get_value(element["link"], "guide_id"))
                and utils.get_int(element["link"], "preset_number") == presetnum
            ):
                newelementslist.append({"link": element["link"]})
                break
        presetnum = presetnum + 1

    # Add any links or topics to ordered elements list.
    for element in elementslist:
        if "link" in element and not __tunein__.is_custom_url_id(utils.get_value(element["link"], "guide_id")):
            newelementslist.append({"link": element["link"]})
        elif "topic" in element:
            newelementslist.append({"topic": element["topic"]})

    return newelementslist
Esempio n. 3
0
def get_max_preset_num(elementslist):
    maxpresetnum = 0
    for element in elementslist:
        if 'show' in element and utils.get_int(element['show'], 'preset_number') > maxpresetnum:
            maxpresetnum = utils.get_int(element['show'], 'preset_number')
        elif 'station' in element and utils.get_int(element['station'], 'preset_number') > maxpresetnum:
            maxpresetnum = utils.get_int(element['station'], 'preset_number')
        elif 'link' in element and __tunein__.is_custom_url_id(utils.get_value(element['link'], 'guide_id')) and utils.get_int(element['link'], 'preset_number') > maxpresetnum:
            maxpresetnum = utils.get_int(element['link'], 'preset_number')
    return maxpresetnum
Esempio n. 4
0
def get_max_preset_num(elementslist):
    maxpresetnum = 0
    for element in elementslist:
        if "show" in element and utils.get_int(element["show"], "preset_number") > maxpresetnum:
            maxpresetnum = utils.get_int(element["show"], "preset_number")
        elif "station" in element and utils.get_int(element["station"], "preset_number") > maxpresetnum:
            maxpresetnum = utils.get_int(element["station"], "preset_number")
        elif (
            "link" in element
            and __tunein__.is_custom_url_id(utils.get_value(element["link"], "guide_id"))
            and utils.get_int(element["link"], "preset_number") > maxpresetnum
        ):
            maxpresetnum = utils.get_int(element["link"], "preset_number")
    return maxpresetnum