コード例 #1
0
def change_order(id, type_tv_radio, **kwargs):
    if not id or len(str(id)) == 0:
        return False

    if type_tv_radio == 'live':
        order = load_order(profile_id=1)
    else:
        order = load_radio_order(profile_id=1)

    id = str(id)
    type_tv_radio = str(type_tv_radio)

    selected = gui.numeric(_.SELECT_ORDER, order[id])
    double = None
    double_query = ''

    if selected and selected >= 0:
        for currow in order:
            if id == str(currow):
                continue

            if int(order[currow]) == int(selected):
                double = currow
                break

        order[id] = selected

    if type_tv_radio == 'live':
        save_order(profile_id=1, order=order)
    else:
        save_radio_order(profile_id=1, order=order)

    if double:
        double_query = '&double={double}&primary={primary}'.format(
            double=double, primary=id)

    method = 'GUI.ActivateWindow'
    json_rpc(
        method, {
            "window":
            "videos",
            "parameters": [
                'plugin://' + str(ADDON_ID) + '/?_=order_picker_menu' +
                double_query + '&type_tv_radio=' + type_tv_radio
            ]
        })
コード例 #2
0
def change_order(id, type_tv_radio, **kwargs):
    if not id or len(unicode(id)) == 0:
        return False

    if type_tv_radio == 'live':
        order = load_order(profile_id=1)
    else:
        order = load_radio_order(profile_id=1)

    id = unicode(id)
    type_tv_radio = unicode(type_tv_radio)

    selected = gui.numeric(_.SELECT_ORDER, order[id])
    double = None
    double_query = ''

    if selected and selected >= 0:
        for currow in order:
            if id == unicode(currow):
                continue

            if int(order[currow]) == int(selected):
                double = currow
                break

        order[id] = selected

    if type_tv_radio == 'live':
        save_order(profile_id=1, order=order)
    else:
        save_radio_order(profile_id=1, order=order)

    if double:
        double_query = '&double={double}&primary={primary}'.format(
            double=double, primary=id)

    xbmc.executeJSONRPC(
        '{"jsonrpc":"2.0","id":1,"method":"GUI.ActivateWindow","params":{"window":"videos","parameters":["plugin://'
        + unicode(ADDON_ID) + '/?_=order_picker_menu' + double_query +
        '&type_tv_radio=' + type_tv_radio + '"]}}')
コード例 #3
0
def save_all_order(type_tv_radio, double=None, primary=None):
    if type_tv_radio == 'live':
        prefs = load_prefs(profile_id=1)
        order = load_order(profile_id=1)
    else:
        prefs = load_radio_prefs(profile_id=1)
        order = load_radio_order(profile_id=1)

    found_ar = []
    last_id = None

    for currow in prefs:
        row = prefs[currow]

        if int(row[type_tv_radio]) == 0:
            continue

        found_ar.append(currow)

        if not check_key(order, str(currow)):
            if not last_id:
                order[str(currow)] = 1
            else:
                order[str(currow)] = order[last_id] + 1

        last_id = str(currow)

    order2 = order.copy()

    for currow in order:
        if not currow in found_ar:
            del order2[currow]

    order2 = collections.OrderedDict(sorted(order2.items(),
                                            key=lambda x: x[1]))
    order3 = order2.copy()

    last_value = 0

    for currow in order2:
        cur_value = order2[currow]

        if cur_value == last_value:
            cur_value += 1

        order3[currow] = cur_value
        last_value = cur_value

    order3 = collections.OrderedDict(sorted(order3.items(),
                                            key=lambda x: x[1]))

    if double and primary:
        tmp_primary = order3[primary]
        order3[primary] = order3[double]
        order3[double] = tmp_primary
        order3 = collections.OrderedDict(
            sorted(order3.items(), key=lambda x: x[1]))

    if type_tv_radio == 'live':
        save_order(profile_id=1, order=order3)
    else:
        save_radio_order(profile_id=1, order=order3)