Beispiel #1
0
def radio_select(num, **kwargs):
    num = int(num)

    profile_settings = load_profile(profile_id=1)

    for x in range(num, 6):
        profile_settings['addon' + unicode(x)] = ''

    save_profile(profile_id=1, profile=profile_settings)

    folder = plugin.Folder(title=_.ADD_RADIO)

    desc = _.ADD_RADIO_DESC

    folder.add_item(label=_.YES,
                    info={'plot': desc},
                    path=plugin.url_for(func_or_url=live_channel_picker_menu,
                                        save_all=1,
                                        radio=1))
    folder.add_item(label=_.NO,
                    info={'plot': desc},
                    path=plugin.url_for(func_or_url=live_channel_picker_menu,
                                        save_all=1,
                                        radio=0))

    return folder
Beispiel #2
0
def alternative(num, addon, addons, **kwargs):
    num = int(num)
    profile_settings = load_profile(profile_id=1)
    profile_settings['addon' + unicode(num)] = addon
    save_profile(profile_id=1, profile=profile_settings)

    folder = plugin.Folder(title=_.SELECT_SECONDARY)

    addons = json.loads(addons)
    addons2 = []

    desc = _.SELECT_SECONDARY_DESC

    for entry in addons:
        if not entry['addonid'] == addon:
            addons2.append(entry)

    for entry in addons2:
        folder.add_item(label=_(entry['label'], _bold=True),
                        info={'plot': desc},
                        path=plugin.url_for(func_or_url=alternative,
                                            num=num + 1,
                                            addon=entry['addonid'],
                                            addons=json.dumps(addons2)))

    folder.add_item(label=_.DONE,
                    info={'plot': desc},
                    path=plugin.url_for(func_or_url=radio_select, num=num + 1))

    return folder
Beispiel #3
0
def primary(addons, **kwargs):
    folder = plugin.Folder(title=_.SELECT_PRIMARY)

    addons = json.loads(addons)

    desc = _.SELECT_PRIMARY_DESC
    desc2 = _.SKIP_DESC

    for entry in addons:
        folder.add_item(label=_(entry['label'], _bold=True),
                        info={'plot': desc},
                        path=plugin.url_for(func_or_url=alternative,
                                            num=1,
                                            addon=entry['addonid'],
                                            addons=json.dumps(addons)))

    profile_settings = load_profile(profile_id=1)

    try:
        if len(profile_settings['addon1']) > 0:
            folder.add_item(label=_(_.SKIP, _bold=True),
                            info={'plot': desc2},
                            path=plugin.url_for(func_or_url=radio_select,
                                                num=6))
    except:
        pass

    return folder
Beispiel #4
0
def live_channel_picker_menu(save_all=0, radio=None, **kwargs):
    save_all = int(save_all)

    if not radio == None:
        radio = int(radio)
        profile_settings = load_profile(profile_id=1)
        profile_settings['radio'] = radio
        save_profile(profile_id=1, profile=profile_settings)

    if save_all == 1:
        save_all_live_prefs()

    folder = plugin.Folder(title=_.SELECT_LIVE)

    desc2 = _.NEXT_SETUP_REPLAY

    folder.add_item(label=_(_.NEXT, _bold=True),
                    info={'plot': desc2},
                    path=plugin.url_for(func_or_url=replay_channel_picker_menu,
                                        save_all=1))

    prefs = load_prefs(profile_id=1)

    if prefs:
        for currow in prefs:
            row = prefs[currow]

            if row['live'] == 1:
                color = 'green'
                addon_type = row['live_addonid'].replace('plugin.video.', '')
            else:
                color = 'red'
                addon_type = _.DISABLED

            label = _(row['name'] + ": " + addon_type,
                      _bold=True,
                      _color=color)

            folder.add_item(
                label=label,
                path=plugin.url_for(func_or_url=change_live_channel,
                                    id=currow),
                playable=False,
            )

    folder.add_item(label=_(_.NEXT, _bold=True),
                    info={'plot': desc2},
                    path=plugin.url_for(func_or_url=replay_channel_picker_menu,
                                        save_all=1))

    return folder
Beispiel #5
0
def api_get_all_epg():
    updated = False

    profile_settings = load_profile(profile_id=1)

    for x in range(1, 6):
        if check_key(profile_settings, 'addon' + unicode(x)):
            if len(profile_settings['addon' + unicode(x)]) > 0:
                if api_get_epg_by_addon(profile_settings['addon' + unicode(x)].replace('plugin.video.', '')) == True:
                    updated = True

    clear_cache()

    if updated == True:
        return True
    else:
        return False
Beispiel #6
0
def tv_order_picker_menu(double=None, primary=None, **kwargs):
    save_all_tv_order(double=double, primary=primary)

    folder = plugin.Folder(title=_.SELECT_ORDER)

    profile_settings = load_profile(profile_id=1)
    if int(profile_settings['radio']) == 1:
        desc2 = _.NEXT_SETUP_RADIO
        path = plugin.url_for(func_or_url=radio_channel_picker_menu,
                              save_all=1)
    else:
        desc2 = _.NEXT_SETUP_IPTV
        path = plugin.url_for(func_or_url=simple_iptv_menu)

    folder.add_item(label=_(_.NEXT, _bold=True),
                    info={'plot': desc2},
                    path=path)

    prefs = load_prefs(profile_id=1)
    order = load_order(profile_id=1)

    if order:
        for currow in order:
            row = prefs[currow]

            if int(row['live']) == 0:
                continue

            label = _(row['name'] + ": " + unicode(order[unicode(currow)]),
                      _bold=True)

            folder.add_item(
                label=label,
                path=plugin.url_for(func_or_url=change_tv_order, id=currow),
                playable=False,
            )

    folder.add_item(label=_(_.NEXT, _bold=True),
                    info={'plot': desc2},
                    path=path)

    return folder
Beispiel #7
0
def change_replay_channel(id, **kwargs):
    if not id or len(unicode(id)) == 0:
        return False

    profile_settings = load_profile(profile_id=1)
    prefs = load_prefs(profile_id=1)
    all_channels = load_channels(type='all')
    id = unicode(id)

    select_list = []
    num = 0

    for x in range(1, 6):
        if len(profile_settings['addon' + unicode(x)]) > 0:
            type = profile_settings['addon' + unicode(x)]

            type_channels = load_channels(
                type=type.replace('plugin.video.', ''))

            VIDEO_ADDON_PROFILE = ADDON_PROFILE.replace(ADDON_ID, type)
            addon_prefs = load_file(VIDEO_ADDON_PROFILE + 'prefs.json',
                                    ext=True,
                                    isJSON=True)
            addon_profile = load_file(VIDEO_ADDON_PROFILE + 'profile.json',
                                      ext=True,
                                      isJSON=True)

            ziggov3 = 0

            try:
                if int(addon_profile['v3']) == 1:
                    ziggov3 = 1
            except:
                pass

            row2 = all_channels[id]

            if ziggov3 == 1:
                try:
                    type_id = unicode(row2[type + '_idv3'])
                except:
                    type_id = ''
            else:
                type_id = unicode(row2[type + '_id'])

            if len(type_id) > 0:
                row = type_channels[type_id]

                disabled = False

                if addon_prefs:
                    try:
                        if check_key(addon_prefs, unicode(row['id'])) and int(
                                addon_prefs[unicode(
                                    row['id'])]['replay']) == 0:
                            disabled = True
                    except:
                        pass

                if disabled == False:
                    select_list.append(
                        profile_settings['addon' + unicode(x)].replace(
                            'plugin.video.', ''))
                    num += 1

    select_list.append(_.DISABLED)

    selected = gui.select(_.SELECT_ADDON, select_list)
    mod_pref = prefs[id]

    if selected >= 0:
        mod_pref['replay_auto'] = 0

        if selected == num:
            mod_pref['replay'] = 0
            mod_pref['replay_addonid'] = ''
            mod_pref['replay_channelid'] = ''
            mod_pref['replay_channelassetid'] = ''
        else:
            mod_pref['replay'] = 1
            mod_pref[
                'replay_addonid'] = 'plugin.video.' + select_list[selected]
            mod_pref['replay_channelid'] = ''
            mod_pref['replay_channelassetid'] = ''

            type_channels = load_channels(type=select_list[selected])
            row2 = all_channels[id]

            if ziggov3 == 1:
                try:
                    type_id = unicode(row2[mod_pref['replay_addonid'] +
                                           '_idv3'])
                except:
                    type_id = ''
            else:
                type_id = unicode(row2[mod_pref['replay_addonid'] + '_id'])

            if len(type_id) > 0:
                row = type_channels[type_id]

                mod_pref['replay_channelid'] = row['id']
                mod_pref['replay_channelassetid'] = row['assetid']

        prefs[id] = mod_pref
        save_prefs(profile_id=1, prefs=prefs)

    xbmc.executeJSONRPC(
        '{"jsonrpc":"2.0","id":1,"method":"GUI.ActivateWindow","params":{"window":"videos","parameters":["plugin://'
        + unicode(ADDON_ID) +
        '/?_=replay_channel_picker_menu&num=6&save_all=0"]}}')
Beispiel #8
0
def save_all_replay_prefs():
    if api_get_channels() == True:
        profile_settings = load_profile(profile_id=1)

        all_channels = load_channels(type='all')
        prefs = load_prefs(profile_id=1)
        found_ar = []

        for x in range(1, 6):
            if len(profile_settings['addon' + unicode(x)]) > 0:
                type = profile_settings['addon' + unicode(x)]

                type_channels = load_channels(
                    type=type.replace('plugin.video.', ''))

                VIDEO_ADDON_PROFILE = ADDON_PROFILE.replace(ADDON_ID, type)
                addon_prefs = load_file(VIDEO_ADDON_PROFILE + 'prefs.json',
                                        ext=True,
                                        isJSON=True)
                addon_profile = load_file(VIDEO_ADDON_PROFILE + 'profile.json',
                                          ext=True,
                                          isJSON=True)

                ziggov3 = 0

                try:
                    if int(addon_profile['v3']) == 1:
                        ziggov3 = 1
                except:
                    pass

                for currow in type_channels:
                    row = type_channels[currow]

                    all_id = None

                    for currow2 in all_channels:
                        row2 = all_channels[currow2]

                        if (ziggov3 == 0 and unicode(row2[type + '_id'])
                                == unicode(row['id'])) or (
                                    ziggov3 == 1
                                    and check_key(row2, type + '_idv3')
                                    and unicode(row2[type + '_idv3'])
                                    == unicode(row['id'])):
                            all_id = unicode(currow2)

                    if not all_id or not check_key(prefs, all_id):
                        continue

                    disabled = False

                    if addon_prefs:
                        try:
                            if int(addon_prefs[unicode(
                                    row['id'])]['replay']) == 0:
                                disabled = True
                        except:
                            pass

                    if disabled == True:
                        try:
                            if all_id and check_key(
                                    prefs, all_id
                            ) and prefs[all_id]['replay_addonid'] == type:
                                del prefs[all_id]['replay']
                                del prefs[all_id]['replay_addonid']
                                del prefs[all_id]['replay_auto']
                                del prefs[all_id]['replay_channelid']
                                del prefs[all_id]['replay_channelassetid']
                        except:
                            pass

                        continue

                    try:
                        if (not prefs or not check_key(prefs, all_id)) or (
                                int(prefs[all_id]['replay_auto']) == 1
                                and all_id and not all_id in found_ar):
                            prefs[all_id]['replay'] = 1
                            prefs[all_id]['replay_addonid'] = type
                            prefs[all_id]['replay_auto'] = 1
                            prefs[all_id]['replay_channelid'] = row['id']
                            prefs[all_id]['replay_channelassetid'] = row[
                                'assetid']
                    except:
                        prefs[all_id]['replay'] = 1
                        prefs[all_id]['replay_addonid'] = type
                        prefs[all_id]['replay_auto'] = 1
                        prefs[all_id]['replay_channelid'] = row['id']
                        prefs[all_id]['replay_channelassetid'] = row['assetid']

                    found_ar.append(all_id)

        prefs2 = prefs.copy()

        for currow in prefs:
            if not currow in found_ar:
                del prefs2[currow]

        save_prefs(profile_id=1, prefs=prefs2)