Example #1
0
def search_kids():
    downloadPath = api_url_120(
        'TRAY/SEARCH/PROGRAM?outputFormat=EXTENDED&dfilter_channels=subscription&filter_isTvPremiere=true&filter_isCatchUp=true&filter_fuzzy=true&from=0&to=9999&filter_genre=kinderen,kids'
    )
    downloadPath += '&filter_endTime=' + str(
        func.datetime_to_ticks(datetime.utcnow() -
                               timedelta(minutes=var.RecordingProcessMinutes)))
    return downloadPath
Example #2
0
def epg_day(dateStringDay):
    #Get all playable channel ids
    ChannelIdsPlayableString = ''
    for playableId in var.ChannelIdsPlayable:
        ChannelIdsPlayableString += playableId + ','
    ChannelIdsPlayableString = ChannelIdsPlayableString[:-1]

    #Set download time range
    datetimeMidnight = func.datetime_from_string(dateStringDay, '%Y-%m-%d')
    startTimeEpoch = func.datetime_to_ticks(datetimeMidnight -
                                            timedelta(hours=6))
    endTimeEpoch = func.datetime_to_ticks(datetimeMidnight +
                                          timedelta(hours=30))

    return api_url_120('TRAY/EPG?outputFormat=EXTENDED&filter_startTime=' +
                       str(startTimeEpoch) + '&filter_endTime=' +
                       str(endTimeEpoch) + '&filter_channelIds=' +
                       ChannelIdsPlayableString)
Example #3
0
def vod_yesterday():
    #Set download time range
    dateTimeMidnight = func.datetime_to_midnight(datetime.now())
    startTimeEpoch = func.datetime_to_ticks(
        dateTimeMidnight - timedelta(days=1), True)
    endTimeEpoch = func.datetime_to_ticks(
        dateTimeMidnight + timedelta(hours=1), True)

    downloadPath = api_url_120(
        'TRAY/SEARCH/PROGRAM?outputFormat=EXTENDED&dfilter_channels=subscription&filter_isTvPremiere=true&filter_isCatchUp=true&filter_fuzzy=true&from=0&to=9999'
    )
    downloadPath += '&filter_airingStartTime=' + str(
        startTimeEpoch) + '&filter_airingEndTime=' + str(endTimeEpoch)
    if var.addon.getSetting('TelevisionChannelNoErotic') == 'true':
        downloadPath += '&filter_excludedGenre=kinderen,kids,erotiek&filter_excludedGenres=kinderen,kids,erotiek'
    else:
        downloadPath += '&filter_excludedGenre=kinderen,kids&filter_excludedGenres=kinderen,kids'
    return downloadPath
Example #4
0
def search_program(programName):
    downloadPath = api_url_120(
        'TRAY/SEARCH/PROGRAM?outputFormat=EXTENDED&dfilter_channels=subscription&query='
        + programName +
        '&filter_isTvPremiere=true&filter_isCatchUp=true&filter_fuzzy=true&from=0&to=9999&orderBy=airingStartTime&sortOrder=desc'
    )
    downloadPath += '&filter_endTime=' + str(
        func.datetime_to_ticks(datetime.utcnow() -
                               timedelta(minutes=var.RecordingProcessMinutes)))
    if var.addon.getSetting('TelevisionChannelNoErotic') == 'true':
        downloadPath += '&filter_excludedGenre=erotiek'
    return downloadPath
Example #5
0
def search_series():
    downloadPath = api_url_120(
        'TRAY/SEARCH/PROGRAM?outputFormat=EXTENDED&dfilter_channels=subscription&filter_isTvPremiere=true&filter_isCatchUp=true&filter_fuzzy=true&from=0&to=9999&filter_programType=serie'
    )
    downloadPath += '&filter_endTime=' + str(
        func.datetime_to_ticks(datetime.utcnow() -
                               timedelta(minutes=var.RecordingProcessMinutes)))
    if var.addon.getSetting('TelevisionChannelNoErotic') == 'true':
        downloadPath += '&filter_excludedGenre=kinderen,kids,erotiek&filter_excludedGenres=kinderen,kids,erotiek'
    else:
        downloadPath += '&filter_excludedGenre=kinderen,kids&filter_excludedGenres=kinderen,kids'
    return downloadPath
Example #6
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)