Пример #1
0
def download_recording_event(forceUpdate=False):
    #Check if data is already cached
    if var.ChannelsDataJsonRecordingEvent != [] and forceUpdate == False:
        return None

    #Check if user has pvr access
    if var.RecordingAccess == False:
        return None

    #Check if user is logged in
    if var.ApiLoggedIn == False:
        apilogin.ApiLogin(False)

    try:
        DownloadHeaders = {
            "User-Agent": var.addon.getSetting('CustomUserAgent'),
            "Cookie": var.ApiLoginCookie,
            "X-Xsrf-Token": var.ApiLoginToken
        }

        DownloadRequest = hybrid.urllib_request(path.recording_event(),
                                                headers=DownloadHeaders)
        DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest)
        DownloadDataJson = json.load(DownloadDataHttp)

        #Check if connection is successful
        if DownloadDataJson['resultCode'] and DownloadDataJson[
                'errorDescription']:
            resultCode = DownloadDataJson['resultCode']
            resultMessage = DownloadDataJson['message']
            if resultCode == 'KO':
                var.ApiLoggedIn = False
                notificationIcon = path.resources(
                    'resources/skins/default/media/common/record.png')
                xbmcgui.Dialog().notification(
                    var.addonname,
                    'Opnames download mislukt: ' + resultMessage,
                    notificationIcon, 2500, False)
                return False

        var.ChannelsDataJsonRecordingEvent = DownloadDataJson
        return True
    except:
        notificationIcon = path.resources(
            'resources/skins/default/media/common/record.png')
        xbmcgui.Dialog().notification(var.addonname,
                                      'Opnames download mislukt.',
                                      notificationIcon, 2500, False)
        return False
Пример #2
0
def download_search_program(programName):
    #Check if user is logged in
    if var.ApiLoggedIn == False:
        apilogin.ApiLogin(False)

    try:
        DownloadHeaders = {
            "User-Agent": var.addon.getSetting('CustomUserAgent'),
            "Cookie": var.ApiLoginCookie,
            "X-Xsrf-Token": var.ApiLoginToken
        }

        programName = hybrid.urllib_quote(programName)
        DownloadRequest = hybrid.urllib_request(
            path.search_program(programName), headers=DownloadHeaders)
        DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest)
        DownloadDataJson = json.load(DownloadDataHttp)

        #Check if connection is successful
        if DownloadDataJson['resultCode'] and DownloadDataJson[
                'errorDescription']:
            resultCode = DownloadDataJson['resultCode']
            resultMessage = DownloadDataJson['message']
            if resultCode == 'KO':
                var.ApiLoggedIn = False
                notificationIcon = path.resources(
                    'resources/skins/default/media/common/search.png')
                xbmcgui.Dialog().notification(
                    var.addonname, 'Zoek download mislukt: ' + resultMessage,
                    notificationIcon, 2500, False)
                return None

        return DownloadDataJson
    except:
        notificationIcon = path.resources(
            'resources/skins/default/media/common/search.png')
        xbmcgui.Dialog().notification(var.addonname, 'Zoek download mislukt.',
                                      notificationIcon, 2500, False)
        return None
Пример #3
0
def download_epg_day(dateStringDay, forceUpdate=False):
    #Check if data is already cached
    epgDayCache = None
    for epgCache in var.EpgCacheArray:
        try:
            if epgCache.dateStringDay == dateStringDay:
                epgDayCache = epgCache
                break
        except:
            continue

    #Check if update is needed
    if epgDayCache != None:
        if forceUpdate == True:
            var.EpgCacheArray.remove(epgDayCache)
        else:
            return epgDayCache.epgJson

    #Check if user is logged in
    if var.ApiLoggedIn == False:
        apilogin.ApiLogin(False)

    try:
        DownloadHeaders = {
            "User-Agent": var.addon.getSetting('CustomUserAgent'),
            "Cookie": var.ApiLoginCookie,
            "X-Xsrf-Token": var.ApiLoginToken,
            'Content-Type': 'application/json'
        }

        #Download epg information
        DownloadRequest = hybrid.urllib_request(path.epg_day(dateStringDay),
                                                headers=DownloadHeaders)
        DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest)
        DownloadDataJson = json.load(DownloadDataHttp)

        #Check if connection is successful
        if DownloadDataJson['resultCode'] and DownloadDataJson[
                'errorDescription']:
            resultCode = DownloadDataJson['resultCode']
            resultMessage = DownloadDataJson['message']
            if resultCode == 'KO':
                var.ApiLoggedIn = False
                notificationIcon = path.resources(
                    'resources/skins/default/media/common/epg.png')
                xbmcgui.Dialog().notification(
                    var.addonname,
                    'TV Gids download mislukt: ' + resultMessage,
                    notificationIcon, 2500, False)
                return None

        #Update epg information
        classAdd = classes.Class_EpgCache()
        classAdd.dateStringDay = dateStringDay
        classAdd.epgJson = DownloadDataJson
        var.EpgCacheArray.append(classAdd)

        return DownloadDataJson
    except:
        notificationIcon = path.resources(
            'resources/skins/default/media/common/epg.png')
        xbmcgui.Dialog().notification(var.addonname, 'TV Gids laden mislukt.',
                                      notificationIcon, 2500, False)
        return None
Пример #4
0
def record_event_remove(RecordId, StartDeltaTime=0):
    #Check if user is logged in
    if var.ApiLoggedIn == False:
        apilogin.ApiLogin(False)

    try:
        DownloadHeaders = {
            "User-Agent": var.addon.getSetting('CustomUserAgent'),
            "Content-Type": "application/json",
            "Cookie": var.ApiLoginCookie,
            "X-Xsrf-Token": var.ApiLoginToken
        }

        DownloadData = json.dumps([{
            "recordId": int(RecordId),
            "startDeltaTime": int(StartDeltaTime)
        }]).encode('ascii')
        DownloadRequest = hybrid.urllib_request(
            path.recording_event_add_remove(),
            data=DownloadData,
            headers=DownloadHeaders)
        DownloadRequest.get_method = lambda: 'DELETE'
        DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest)
        DownloadDataJson = json.load(DownloadDataHttp)

        #Check if connection is successful
        if DownloadDataJson['resultCode'] and DownloadDataJson[
                'errorDescription']:
            resultCode = DownloadDataJson['resultCode']
            resultMessage = DownloadDataJson['message']
            if resultCode == 'KO':
                var.ApiLoggedIn = False
                notificationIcon = path.resources(
                    'resources/skins/default/media/common/record.png')
                xbmcgui.Dialog().notification(
                    var.addonname,
                    'Opname annulering mislukt: ' + resultMessage,
                    notificationIcon, 2500, False)
                return False

        notificationIcon = path.resources(
            'resources/skins/default/media/common/record.png')
        xbmcgui.Dialog().notification(var.addonname,
                                      'Opname is geannuleerd of verwijderd.',
                                      notificationIcon, 2500, False)

        #Download the recording event
        download_recording_event(True)

        #Update the main page count
        if var.guiMain != None:
            var.guiMain.count_recorded_event()
            var.guiMain.count_recording_event()

        return True
    except:
        notificationIcon = path.resources(
            'resources/skins/default/media/common/record.png')
        xbmcgui.Dialog().notification(var.addonname,
                                      'Opname annulering mislukt.',
                                      notificationIcon, 2500, False)
        return False
Пример #5
0
def record_event_add(ProgramId):
    #Check if user is logged in
    if var.ApiLoggedIn == False:
        apilogin.ApiLogin(False)

    try:
        DownloadHeaders = {
            "User-Agent": var.addon.getSetting('CustomUserAgent'),
            "Content-Type": "application/json",
            "Cookie": var.ApiLoginCookie,
            "X-Xsrf-Token": var.ApiLoginToken
        }

        DownloadData = json.dumps({
            "externalContentId": ProgramId,
            "isAutoDeletionEnabled": True
        }).encode('ascii')
        DownloadRequest = hybrid.urllib_request(
            path.recording_event_add_remove(),
            data=DownloadData,
            headers=DownloadHeaders)
        DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest)
        DownloadDataJson = json.load(DownloadDataHttp)

        #Check if connection is successful
        if DownloadDataJson['resultCode'] and DownloadDataJson[
                'errorDescription']:
            resultCode = DownloadDataJson['resultCode']
            resultMessage = DownloadDataJson['message']
            if resultCode == 'KO':
                var.ApiLoggedIn = False
                notificationIcon = path.resources(
                    'resources/skins/default/media/common/record.png')
                xbmcgui.Dialog().notification(
                    var.addonname, 'Opname planning mislukt: ' + resultMessage,
                    notificationIcon, 2500, False)
                return ''

        notificationIcon = path.resources(
            'resources/skins/default/media/common/record.png')
        xbmcgui.Dialog().notification(var.addonname,
                                      'Programma wordt opgenomen.',
                                      notificationIcon, 2500, False)

        #Download the recording event
        download_recording_event(True)

        #Update the main page count
        if var.guiMain != None:
            var.guiMain.count_recorded_event()
            var.guiMain.count_recording_event()

        return str(DownloadDataJson['resultObj']['containers'][0]['metadata']
                   ['contentId'])
    except:
        notificationIcon = path.resources(
            'resources/skins/default/media/common/record.png')
        xbmcgui.Dialog().notification(var.addonname,
                                      'Opname planning mislukt.',
                                      notificationIcon, 2500, False)
        return ''
Пример #6
0
def record_series_add(ChannelId, liveSeriesId):
    #Check if user is logged in
    if var.ApiLoggedIn == False:
        apilogin.ApiLogin(False)

    try:
        DownloadHeaders = {
            "User-Agent": var.addon.getSetting('CustomUserAgent'),
            "Content-Type": "application/json",
            "Cookie": var.ApiLoginCookie,
            "X-Xsrf-Token": var.ApiLoginToken
        }

        DownloadData = json.dumps({
            "channelId": ChannelId,
            "seriesId": liveSeriesId,
            "isAutoDeletionEnabled": True,
            "episodeScope": "ALL",
            "isChannelBoundEnabled": True
        }).encode('ascii')
        DownloadRequest = hybrid.urllib_request(
            path.recording_series_add_remove(),
            data=DownloadData,
            headers=DownloadHeaders)
        DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest)
        DownloadDataJson = json.load(DownloadDataHttp)

        #Check if connection is successful
        if DownloadDataJson['resultCode'] and DownloadDataJson[
                'errorDescription']:
            resultCode = DownloadDataJson['resultCode']
            resultMessage = DownloadDataJson['message']
            if resultCode == 'KO':
                var.ApiLoggedIn = False
                notificationIcon = path.resources(
                    'resources/skins/default/media/common/recordseries.png')
                xbmcgui.Dialog().notification(
                    var.addonname,
                    'Serie seizoen planning mislukt: ' + resultMessage,
                    notificationIcon, 2500, False)
                return False

        notificationIcon = path.resources(
            'resources/skins/default/media/common/recordseries.png')
        xbmcgui.Dialog().notification(var.addonname,
                                      'Serie seizoen wordt opgenomen.',
                                      notificationIcon, 2500, False)

        #Download the recording series
        download_recording_series(True)

        #Download the recording event
        download_recording_event(True)

        #Update the main page count
        if var.guiMain != None:
            var.guiMain.count_recorded_event()
            var.guiMain.count_recording_event()
            var.guiMain.count_recording_series()

        return True
    except:
        notificationIcon = path.resources(
            'resources/skins/default/media/common/recordseries.png')
        xbmcgui.Dialog().notification(var.addonname,
                                      'Serie seizoen planning mislukt.',
                                      notificationIcon, 2500, False)
        return False
Пример #7
0
def play_stream_recorded(listItem, Windowed):
    #Check if user is logged in
    if var.ApiLoggedIn == False:
        apilogin.ApiLogin(False)

    #Download the program stream url
    try:
        DownloadHeaders = {
            "User-Agent": var.addon.getSetting('CustomUserAgent'),
            "Cookie": var.ApiLoginCookie,
            "X-Xsrf-Token": var.ApiLoginToken
        }

        #Get and set the stream asset id
        ProgramAssetId = listItem.getProperty('ProgramAssetId')
        ProgramRecordEventId = listItem.getProperty('ProgramRecordEventId')

        #Check the set stream asset id
        if func.string_isnullorempty(
                ProgramAssetId) or func.string_isnullorempty(
                    ProgramRecordEventId):
            notificationIcon = path.resources(
                'resources/skins/default/media/common/recorddone.png')
            xbmcgui.Dialog().notification(
                var.addonname,
                'Opname is niet speelbaar, wegens stream rechten.',
                notificationIcon, 2500, False)
            return

        DownloadRequest = hybrid.urllib_request(path.stream_url_recording(
            ProgramRecordEventId, ProgramAssetId),
                                                headers=DownloadHeaders)
        DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest)
        DownloadDataJson = json.load(DownloadDataHttp)
    except:
        notificationIcon = path.resources(
            'resources/skins/default/media/common/recorddone.png')
        xbmcgui.Dialog().notification(var.addonname,
                                      'Opname is niet gevonden.',
                                      notificationIcon, 2500, False)
        return

    #Check if connection is successful
    if DownloadDataJson['resultCode'] and DownloadDataJson['errorDescription']:
        resultCode = DownloadDataJson['resultCode']
        resultMessage = DownloadDataJson['message']
        if resultCode == 'KO':
            var.ApiLoggedIn = False
            notificationIcon = path.resources(
                'resources/skins/default/media/common/recorddone.png')
            xbmcgui.Dialog().notification(
                var.addonname, 'Opname is niet beschikbaar: ' + resultMessage,
                notificationIcon, 2500, False)
            return

    #Check the target resolution
    if var.addon.getSetting('StreamResolution') == '2160p':
        targetResolution = '10000000'
    elif var.addon.getSetting('StreamResolution') == '1080p':
        targetResolution = '6000000'
    elif var.addon.getSetting('StreamResolution') == '720p':
        targetResolution = '4000000'
    elif var.addon.getSetting('StreamResolution') == '576p':
        targetResolution = '2500000'
    elif var.addon.getSetting('StreamResolution') == '432p':
        targetResolution = '1600000'
    elif var.addon.getSetting('StreamResolution') == '360p':
        targetResolution = '1200000'

    #Set stream headers dictionary
    StreamHeadersDict = {"User-Agent": var.addon.getSetting('CustomUserAgent')}

    #Create stream headers string
    StreamHeaders = ''
    for name, value in StreamHeadersDict.items():
        StreamHeaders += '&' + name + '=' + hybrid.urllib_quote(value)
    StreamHeaders = StreamHeaders.replace('&', '', 1)

    #Get and adjust the stream url
    try:
        StreamUrl = DownloadDataJson['resultObj']['src']['sources']['src']
        StreamUrl = StreamUrl.replace('&max_bitrate=1200000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl = StreamUrl.replace('&max_bitrate=1600000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl = StreamUrl.replace('&max_bitrate=2500000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl = StreamUrl.replace('&max_bitrate=4000000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl = StreamUrl.replace('&max_bitrate=6000000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl = StreamUrl.replace('&max_bitrate=10000000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl += '&drm=clear'
    except:
        notificationIcon = path.resources(
            'resources/skins/default/media/common/recorddone.png')
        xbmcgui.Dialog().notification(var.addonname,
                                      'Stream is niet beschikbaar.',
                                      notificationIcon, 2500, False)
        return

    #Set input adaptive stream
    listItem.setProperty(hybrid.inputstreamname, 'inputstream.adaptive')
    listItem.setProperty('inputstream.adaptive.manifest_type', 'mpd')
    listItem.setProperty('inputstream.adaptive.stream_headers', StreamHeaders)

    #Get and set stream license key
    try:
        AdaptiveLicenseUrl = DownloadDataJson['resultObj']['src']['sources'][
            'contentProtection']['widevine']['licenseAcquisitionURL']
        AdaptivePostData = 'R{SSM}'
        AdaptiveResponse = ''
        listItem.setProperty('inputstream.adaptive.license_type',
                             'com.widevine.alpha')
        listItem.setProperty(
            'inputstream.adaptive.license_key', AdaptiveLicenseUrl + "|" +
            StreamHeaders + "|" + AdaptivePostData + "|" + AdaptiveResponse)
    except:
        pass

    #Update the list item name label
    listItem.setLabel(listItem.getProperty('ProgramName'))

    #Set stream start offset in seconds
    listItem.setProperty('StartOffset', '120')

    #Set internet stream property
    listItem.setProperty("get_stream_details_from_player", 'true')

    #Start playing the media
    var.PlayerCustom.PlayCustom(StreamUrl, listItem, Windowed, False)
Пример #8
0
def play_stream_television(listItem, Windowed):
    #Get channel settings and variables
    NewAssetId = listItem.getProperty('AssetId')
    NewChannelId = listItem.getProperty('ChannelId')
    NewExternalId = listItem.getProperty('ExternalId')
    NewChannelName = listItem.getProperty('ChannelName')
    CurrentAssetId = var.addon.getSetting('CurrentAssetId')
    CurrentChannelId = var.addon.getSetting('CurrentChannelId')
    CurrentExternalId = var.addon.getSetting('CurrentExternalId')
    CurrentChannelName = var.addon.getSetting('CurrentChannelName')

    #Allow longer back seeking
    DateTimeUtc = datetime.utcnow() - timedelta(
        minutes=int(var.addon.getSetting('StreamSeekMinutes')))
    StartString = '&time=' + str(func.datetime_to_ticks(DateTimeUtc))

    #Check if user is logged in
    if var.ApiLoggedIn == False:
        apilogin.ApiLogin(False)

    #Download the television stream url
    try:
        DownloadHeaders = {
            "User-Agent": var.addon.getSetting('CustomUserAgent'),
            "Cookie": var.ApiLoginCookie,
            "X-Xsrf-Token": var.ApiLoginToken
        }

        RequestUrl = path.stream_url_tv(NewChannelId, NewAssetId) + StartString
        DownloadRequest = hybrid.urllib_request(RequestUrl,
                                                headers=DownloadHeaders)
        DownloadDataHttp = hybrid.urllib_urlopen(DownloadRequest)
        DownloadDataJson = json.load(DownloadDataHttp)
    except:
        notificationIcon = path.resources(
            'resources/skins/default/media/common/television.png')
        xbmcgui.Dialog().notification(var.addonname,
                                      'Zender is niet gevonden.',
                                      notificationIcon, 2500, False)
        return

    #Check if connection is successful
    if DownloadDataJson['resultCode'] and DownloadDataJson['errorDescription']:
        resultCode = DownloadDataJson['resultCode']
        resultMessage = DownloadDataJson['message']
        if resultCode == 'KO':
            var.ApiLoggedIn = False
            notificationIcon = path.resources(
                'resources/skins/default/media/common/television.png')
            xbmcgui.Dialog().notification(
                var.addonname, 'Zender is niet beschikbaar: ' + resultMessage,
                notificationIcon, 2500, False)
            return

    #Check the target resolution
    if var.addon.getSetting('StreamResolution') == '2160p':
        targetResolution = '10000000'
    elif var.addon.getSetting('StreamResolution') == '1080p':
        targetResolution = '6000000'
    elif var.addon.getSetting('StreamResolution') == '720p':
        targetResolution = '4000000'
    elif var.addon.getSetting('StreamResolution') == '576p':
        targetResolution = '2500000'
    elif var.addon.getSetting('StreamResolution') == '432p':
        targetResolution = '1600000'
    elif var.addon.getSetting('StreamResolution') == '360p':
        targetResolution = '1200000'

    #Set stream headers dictionary
    StreamHeadersDict = {"User-Agent": var.addon.getSetting('CustomUserAgent')}

    #Create stream headers string
    StreamHeaders = ''
    for name, value in StreamHeadersDict.items():
        StreamHeaders += '&' + name + '=' + hybrid.urllib_quote(value)
    StreamHeaders = StreamHeaders.replace('&', '', 1)

    #Get and adjust the stream url
    try:
        StreamUrl = DownloadDataJson['resultObj']['src']['sources']['src']
        StreamUrl = StreamUrl.replace('&max_bitrate=1200000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl = StreamUrl.replace('&max_bitrate=1600000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl = StreamUrl.replace('&max_bitrate=2500000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl = StreamUrl.replace('&max_bitrate=4000000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl = StreamUrl.replace('&max_bitrate=6000000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl = StreamUrl.replace('&max_bitrate=10000000',
                                      '&max_bitrate=' + targetResolution)
        StreamUrl += '&drm=clear'
    except:
        notificationIcon = path.resources(
            'resources/skins/default/media/common/television.png')
        xbmcgui.Dialog().notification(var.addonname,
                                      'Stream is niet beschikbaar.',
                                      notificationIcon, 2500, False)
        return

    #Update channel settings and variables
    if CurrentChannelId != NewChannelId:
        var.addon.setSetting('LastAssetId', CurrentAssetId)
        var.addon.setSetting('LastChannelId', CurrentChannelId)
        var.addon.setSetting('LastExternalId', CurrentExternalId)
        var.addon.setSetting('LastChannelName', CurrentChannelName)

    var.addon.setSetting('CurrentAssetId', NewAssetId)
    var.addon.setSetting('CurrentChannelId', NewChannelId)
    var.addon.setSetting('CurrentExternalId', NewExternalId)
    var.addon.setSetting('CurrentChannelName', NewChannelName)

    #Set input adaptive stream
    listItem.setProperty(hybrid.inputstreamname, 'inputstream.adaptive')
    listItem.setProperty('inputstream.adaptive.manifest_type', 'mpd')
    listItem.setProperty('inputstream.adaptive.stream_headers', StreamHeaders)
    listItem.setProperty('inputstream.adaptive.manifest_update_parameter',
                         'full')

    #Get and set stream license key
    try:
        AdaptiveLicenseUrl = DownloadDataJson['resultObj']['src']['sources'][
            'contentProtection']['widevine']['licenseAcquisitionURL']
        AdaptivePostData = 'R{SSM}'
        AdaptiveResponse = ''
        listItem.setProperty('inputstream.adaptive.license_type',
                             'com.widevine.alpha')
        listItem.setProperty(
            'inputstream.adaptive.license_key', AdaptiveLicenseUrl + "|" +
            StreamHeaders + "|" + AdaptivePostData + "|" + AdaptiveResponse)
    except:
        pass

    #Update the list item name label
    listItem.setLabel(NewChannelName)

    #Set internet stream property
    listItem.setProperty("get_stream_details_from_player", 'true')

    #Start playing the media
    var.PlayerCustom.PlayCustom(StreamUrl, listItem, Windowed, True)
Пример #9
0
    def onInit(self):
        #Check if logged in on launch
        if var.ApiLoggedIn == False:
            func.updateLabelText(self, 1, "Aan het aanmelden.")
            apilogin.ApiLogin(False)

        #Update the current login status
        if var.ApiLoggedIn == True:
            func.updateLabelText(self, 1, "Aangemeld, veel kijkplezier.")
        else:
            func.updateLabelText(self, 1, "Aanmelden is mislukt.")

        #Add menu buttons to the page
        menuButtons = self.buttons_add_menu()

        #Add media buttons to the page
        self.buttons_add_media(False)

        #Focus on the menu buttons
        listcontainer = self.getControl(1000)
        self.setFocus(listcontainer)
        xbmc.sleep(100)

        #Update the active alarms count
        self.count_alarm(True)

        #Update the recorded event count
        self.count_recorded_event()

        #Update the recording event count
        self.count_recording_event()

        #Update the recording series count
        self.count_recording_series()

        #Check if menu is already filled / prevent one time code
        if menuButtons == True:
            return

        #Check if Widevine is installed
        if var.thread_check_requirements == None:
            var.thread_check_requirements = Thread(
                target=widevine.thread_check_requirements)
            var.thread_check_requirements.start()

        #Check television favorite setting
        if var.addon.getSetting('TelevisionChannelFavorite') == 'true':
            var.LoadChannelFavoritesOnly = True
        else:
            var.LoadChannelFavoritesOnly = False

        #Check if user is logged in
        if var.ApiLoggedIn == True:
            #Open the last known television channel
            if var.addon.getSetting(
                    'StartWithLastChannel') == 'true' and var.addon.getSetting(
                        'StartWithKids') == 'false':
                CurrentAssetId = var.addon.getSetting('CurrentAssetId')
                CurrentChannelId = var.addon.getSetting('CurrentChannelId')
                CurrentExternalId = var.addon.getSetting('CurrentExternalId')
                CurrentChannelName = var.addon.getSetting('CurrentChannelName')
                stream.switch_channel_tv_channelid(CurrentAssetId,
                                                   CurrentChannelId,
                                                   CurrentExternalId,
                                                   CurrentChannelName,
                                                   'Televisie', True, False)

            #Go to the desired page on startup
            if var.addon.getSetting('StartWithTelevision') == 'true':
                television.switch_to_page()
            elif var.addon.getSetting('StartWithKids') == 'true':
                kids.switch_to_page()