Example #1
0
def change_group(id, type_tv_radio, **kwargs):
    if not id or len(str(id)) == 0:
        return False

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

    select_list = []

    if type_tv_radio == 'radio':
        groups = load_file('radio_groups.json', ext=False, isJSON=True)
        typestr = 'Radio'
    else:
        groups = load_file('tv_groups.json', ext=False, isJSON=True)
        typestr = 'TV'

    select_list.append(typestr)

    for group in groups:
        select_list.append(group)

    selected = gui.select(_.SELECT_GROUP, select_list)

    if type_tv_radio == 'radio':
        prefs = load_radio_prefs(profile_id=1)
    else:
        prefs = load_prefs(profile_id=1)

    try:
        prefs[id]['group'] = select_list[selected]
    except:
        pass

    if type_tv_radio == 'radio':
        save_radio_prefs(profile_id=1, prefs=prefs)
    else:
        save_prefs(profile_id=1, prefs=prefs)

    method = 'GUI.ActivateWindow'
    json_rpc(
        method, {
            "window":
            "videos",
            "parameters": [
                'plugin://' + str(ADDON_ID) +
                '/?_=group_picker_menu&type_tv_radio=' + type_tv_radio
            ]
        })
Example #2
0
def check_devices():
    device_id = load_file('device_id', isJSON=False)

    if not device_id:
        LOGPATH = xbmcvfs.translatePath('special://logpath')
        LOGFILE = os.path.join(LOGPATH, 'kodi.old.log')

        with io.open(LOGFILE, 'r', encoding='utf-8', errors='ignore') as f:
            text = f.read()

        regex = r"HEADER_IN:\sX-DRM-Device-ID:\s([a-zA-Z0-9]*)"

        matches = re.finditer(regex, text, re.MULTILINE)

        for matchNum, match in enumerate(matches, start=1):
            device_id = match.group(1)
            break

        if not device_id:
            LOGFILE = os.path.join(LOGPATH, 'kodi.log')

            with io.open(LOGFILE, 'r', encoding='utf-8', errors='ignore') as f:
                text = f.read()

            regex = r"HEADER_IN:\sX-DRM-Device-ID:\s([a-zA-Z0-9]*)"

            matches = re.finditer(regex, text, re.MULTILINE)

            for matchNum, match in enumerate(matches, start=1):
                device_id = match.group(1)
                break

        if device_id:
            from resources.lib.api import api_list_devices, api_replace_device, api_new_device

            devices = api_list_devices()

            select_list = []
            device_ar = {}
            count = 0

            if devices:
                found = False

                for device in devices:
                    if str(device['deviceId']) == device_id:
                        found = True
                        break

                    device_ar[count] = device['deviceId']
                    count += 1
                    select_list.append(device['customerDefinedName'])

                if found == False:
                    if len(devices) == 5:
                        selected = gui.select(
                            'Selecteer Device om te vervangen:', select_list)
                        if check_key(device_ar, selected):
                            api_replace_device(device_ar[selected], device_id)
                    else:
                        api_new_device(device_id)
        else:
            gui.ok(
                message=
                'Geen device ID gevonden. Het afspelen zal zo mislukken, hierna wordt automatisch een device ID gegenereerd. Je krijgt hier geen bericht van. Herstart direct het afspelen.',
                heading='Geen device ID gevonden')
Example #3
0
def change_channel(id, type_tv_radio, **kwargs):
    if not id or len(str(id)) == 0:
        return False

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

    if type_tv_radio == 'radio':
        prefs = load_radio_prefs(profile_id=1)

        mod_pref = prefs[id]

        if int(mod_pref['radio']) == 0:
            mod_pref['radio'] = 1
        else:
            mod_pref['radio'] = 0

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

        method = 'GUI.ActivateWindow'
        json_rpc(
            method, {
                "window":
                "videos",
                "parameters": [
                    'plugin://' + str(ADDON_ID) +
                    '/?_=channel_picker_menu&type_tv_radio=radio&save_all=0'
                ]
            })
    else:
        profile_settings = load_profile(profile_id=1)
        prefs = load_prefs(profile_id=1)
        all_channels = load_channels(type='all')
        type_tv_radio = str(type_tv_radio)

        select_list = []
        num = 0

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

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

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

                row2 = all_channels[id]

                type_id = str(row2[video_addon + '_id'])

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

                    disabled = False

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

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

        select_list.append(_.DISABLED)

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

        if selected and selected >= 0:
            mod_pref[type_tv_radio + '_auto'] = 0

            if selected == num:
                mod_pref[type_tv_radio] = 0
                mod_pref[type_tv_radio + '_addonid'] = ''
                mod_pref[type_tv_radio + '_channelid'] = ''
                mod_pref[type_tv_radio + '_channelassetid'] = ''

                if type_tv_radio == 'live':
                    mod_pref['channelname'] = ''
                    mod_pref['channelicon'] = ''
            else:
                mod_pref[type_tv_radio] = 1
                mod_pref[type_tv_radio +
                         '_addonid'] = 'plugin.video.' + select_list[selected]
                mod_pref[type_tv_radio + '_channelid'] = ''
                mod_pref[type_tv_radio + '_channelassetid'] = ''
                if type_tv_radio == 'live':
                    mod_pref['channelname'] = ''
                    mod_pref['channelicon'] = ''

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

                type_id = str(row2[mod_pref[type_tv_radio + '_addonid'] +
                                   '_id'])

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

                    mod_pref[type_tv_radio + '_channelid'] = row['id']
                    mod_pref[type_tv_radio +
                             '_channelassetid'] = row['assetid']

                    if type_tv_radio == 'live':
                        mod_pref['channelname'] = row['name']
                        mod_pref['channelicon'] = row['icon']

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

        method = 'GUI.ActivateWindow'
        json_rpc(
            method, {
                "window":
                "videos",
                "parameters": [
                    'plugin://' + str(ADDON_ID) +
                    '/?_=channel_picker_menu&type_tv_radio=' + type_tv_radio +
                    '&save_all=0'
                ]
            })
Example #4
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"]}}')