Beispiel #1
0
def api_get_session(force=0):
    force = int(force)
    profile_settings = load_profile(profile_id=1)

    #if not force ==1 and check_key(profile_settings, 'last_login_time') and profile_settings['last_login_time'] > int(time.time() - 3600) and profile_settings['last_login_success'] == 1:
    #    return True
    #elif force == 1 and (not check_key(profile_settings, 'last_login_time') or not profile_settings['last_login_success'] == 1):
    #    return False

    devices_url = '{api_url}/USER/DEVICES'.format(api_url=CONST_DEFAULT_API)

    download = api_download(url=devices_url, type='get', headers=None, data=None, json_data=False, return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(data, 'resultCode') or not data['resultCode'] == 'OK':
        login_result = api_login()

        if not login_result['result']:
            return False

    try:
        profile_settings = load_profile(profile_id=1)
        profile_settings['last_login_success'] = 1
        profile_settings['last_login_time'] = int(time.time())
        save_profile(profile_id=1, profile=profile_settings)
    except:
        pass

    return True
Beispiel #2
0
def api_get_session(force=0):
    force = int(force)
    profile_settings = load_profile(profile_id=1)

    #if not force ==1 and check_key(profile_settings, 'last_login_time') and profile_settings['last_login_time'] > int(time.time() - 3600) and profile_settings['last_login_success'] == 1:
    #    return True
    #elif force == 1 and not profile_settings['last_login_success'] == 1:
    #    return False

    if not check_key(profile_settings, 'access_token_age') or not check_key(
            profile_settings, 'access_token') or int(
                profile_settings['access_token_age']) < int(time.time() -
                                                            3540):
        login_result = api_login()

        if not login_result['result']:
            return False

    try:
        profile_settings = load_profile(profile_id=1)
        profile_settings['last_login_success'] = 1
        profile_settings['last_login_time'] = int(time.time())
        save_profile(profile_id=1, profile=profile_settings)
    except:
        pass

    return True
Beispiel #3
0
def api_get_session(force=0):
    force = int(force)
    profile_settings = load_profile(profile_id=1)

    devices_url = CONST_API_URLS['devices_url']

    download = api_download(url=devices_url,
                            type='get',
                            headers=api_get_headers(),
                            data=None,
                            json_data=False,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(
            data, 'isAccountEnabled'):
        login_result = api_login()

        if not login_result['result']:
            return False

    profile_settings = load_profile(profile_id=1)
    profile_settings['last_login_success'] = 1
    profile_settings['last_login_time'] = int(time.time())
    save_profile(profile_id=1, profile=profile_settings)

    return True
Beispiel #4
0
def login(ask=1, **kwargs):
    ask = int(ask)

    creds = get_credentials()

    if len(creds['username']) < 1 or len(creds['password']) < 1 or ask == 1:
        user_info = plugin_ask_for_creds(creds)

        if user_info['result']:
            set_credentials(username=user_info['username'], password=user_info['password'])

    login_result = api_login()

    if not login_result['result']:
        profile_settings = load_profile(profile_id=1)
        profile_settings['last_login_success'] = 0
        profile_settings['pswd'] = ''
        save_profile(profile_id=1, profile=profile_settings)

        plugin_login_error(login_result)
    else:
        profile_settings = load_profile(profile_id=1)
        profile_settings['last_login_success'] = 1
        save_profile(profile_id=1, profile=profile_settings)

        gui.ok(message=_.LOGIN_SUCCESS)

        api_get_channels()
        plugin_post_login()

    gui.refresh()
Beispiel #5
0
def api_get_session(force=0):
    force = int(force)
    profile_settings = load_profile(profile_id=1)

    #if not force ==1 and check_key(profile_settings, 'last_login_time') and profile_settings['last_login_time'] > int(time.time() - 3600) and profile_settings['last_login_success'] == 1:
    #    return True
    #elif force == 1 and not profile_settings['last_login_success'] == 1:
    #    return False
    
    headers = {'Authorization': 'Bearer ' + profile_settings['session_token']}

    capi_url = '{api_url}/settings'.format(api_url=CONST_DEFAULT_API)

    download = api_download(url=capi_url, type='get', headers=headers, data=None, json_data=False, return_json=False, allow_redirects=False)
    data = download['data']
    code = download['code']

    if not code or not code == 200:
        login_result = api_login()

        if not login_result['result']:
            return False

    try:
        profile_settings = load_profile(profile_id=1)
        profile_settings['last_login_success'] = 1
        profile_settings['last_login_time'] = int(time.time())
        save_profile(profile_id=1, profile=profile_settings)
    except:
        pass

    return True
Beispiel #6
0
def api_get_session(force=0):
    force = int(force)
    profile_settings = load_profile(profile_id=1)

    #if not force ==1 and check_key(profile_settings, 'last_login_time') and profile_settings['last_login_time'] > int(time.time() - 3600) and profile_settings['last_login_success'] == 1:
    #    return True
    #elif force == 1 and not profile_settings['last_login_success'] == 1:
    #    return False

    heartbeat_url = '{base_url}/VSP/V3/OnLineHeartbeat?from=inMSAAccess'.format(base_url=CONST_BASE_URL)

    headers = {'Content-Type': 'application/json', 'X_CSRFToken': profile_settings['csrf_token']}

    session_post_data = {}

    download = api_download(url=heartbeat_url, type='post', headers=headers, data=session_post_data, json_data=True, return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(data, 'result') or not check_key(data['result'], 'retCode') or not data['result']['retCode'] == '000000000':
        login_result = api_login()

        if not login_result['result']:
            return False

    try:
        profile_settings = load_profile(profile_id=1)
        profile_settings['last_login_success'] = 1
        profile_settings['last_login_time'] = int(time.time())
        save_profile(profile_id=1, profile=profile_settings)
    except:
        pass

    return True
Beispiel #7
0
def api_get_session(force=0):
    force = int(force)
    profile_settings = load_profile(profile_id=1)

    #if not force ==1 and check_key(profile_settings, 'last_login_time') and profile_settings['last_login_time'] > int(time.time() - 3600) and profile_settings['last_login_success'] == 1:
    #    return True
    #elif force == 1 and not profile_settings['last_login_success'] == 1:
    #    return False

    if not check_key(profile_settings, 'resource_verifier'):
        login_result = api_login()

        if not login_result['result']:
            return False
    else:
        token_url_base = '{base_url}/v6/favorites/items'.format(
            base_url=CONST_API_URL)

        token_parameter = 'oauth_consumer_key=key&oauth_signature_method=HMAC-SHA1&oauth_verifier=' + unicode(
            profile_settings['resource_verifier']
        ) + '&oauth_token={token}&oauth_version=1.0&oauth_timestamp={timestamp}&oauth_nonce={nonce}&count=1&expand=false&expandlist=false&maxResults=1&offset=0'

        url_encoded = api_oauth_encode(type="GET",
                                       base_url=token_url_base,
                                       parameters=token_parameter)

        download = api_download(url=url_encoded,
                                type='get',
                                headers=None,
                                data=None,
                                json_data=False,
                                return_json=False)
        data = download['data']
        code = download['code']

        if not code or not code == 200:
            login_result = api_login()

            if not login_result['result']:
                return False

    try:
        profile_settings = load_profile(profile_id=1)
        profile_settings['last_login_success'] = 1
        profile_settings['last_login_time'] = int(time.time())
        save_profile(profile_id=1, profile=profile_settings)
    except:
        pass

    return True
Beispiel #8
0
def api_get_session(force=0, return_data=False):
    force = int(force)
    profile_settings = load_profile(profile_id=1)

    heartbeat_url = '{base_url}/VSP/V3/OnLineHeartbeat?from=inMSAAccess'.format(
        base_url=CONST_URLS['base'])

    headers = {
        'Content-Type': 'application/json',
        'X_CSRFToken': profile_settings['csrf_token']
    }

    session_post_data = {}

    download = api_download(url=heartbeat_url,
                            type='post',
                            headers=headers,
                            data=session_post_data,
                            json_data=True,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(
            data, 'result') or not check_key(
                data['result'],
                'retCode') or not data['result']['retCode'] == '000000000':
        login_result = api_login()

        if not login_result['result']:
            if return_data == True:
                return {
                    'result': False,
                    'data': login_result['data'],
                    'code': login_result['code']
                }

            return False

    profile_settings = load_profile(profile_id=1)
    profile_settings['last_login_success'] = 1
    profile_settings['last_login_time'] = int(time.time())
    save_profile(profile_id=1, profile=profile_settings)

    if return_data == True:
        return {'result': True, 'data': data, 'code': code}

    return True
Beispiel #9
0
    def __init__(self, headers=None, cookies_key=None, save_cookies=True, base_url='{}', timeout=None, attempts=None):
        super(Session, self).__init__()

        profile_settings = load_profile(profile_id=1)
        base_headers = CONST_BASE_HEADERS
        base_headers.update({'User-Agent': profile_settings['user_agent']})

        if headers:
            base_headers.update(headers)

        self._headers = base_headers or {}
        self._cookies_key = cookies_key
        self._save_cookies = save_cookies
        self._base_url = base_url
        self._timeout = timeout or (5, 10)
        self._attempts = attempts or 2

        self.headers.update(self._headers)

        if self._cookies_key:
            try:
                cookies = json.loads(profile_settings[cookies_key])
            except:
                cookies = {}

            self.cookies.update(cookies)
Beispiel #10
0
def api_remove_from_watchlist(id):
    if not api_get_session():
        return None

    profile_settings = load_profile(profile_id=1)

    if int(profile_settings['v3']) == 1:
        remove_url = '{watchlist_url}/{watchlist_id}/entries/{id}?sharedProfile=true'.format(
            watchlist_url=CONST_API_URLS[int(
                profile_settings['v3'])]['watchlist_url'],
            watchlist_id=profile_settings['watchlist_id'],
            id=id)
    else:
        remove_url = '{watchlist_url}/entries/{id}'.format(
            watchlist_url=CONST_API_URLS[int(
                profile_settings['v3'])]['watchlist_url'],
            id=id)

    download = api_download(url=remove_url,
                            type='delete',
                            headers=api_get_headers(),
                            data=None,
                            json_data=False,
                            return_json=False)
    code = download['code']

    if not code or not code == 204:
        return False

    return True
Beispiel #11
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' + str(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=channel_picker_menu,
                                        type_tv_radio='live',
                                        save_all=1,
                                        radio=1))
    folder.add_item(label=_.NO,
                    info={'plot': desc},
                    path=plugin.url_for(func_or_url=channel_picker_menu,
                                        type_tv_radio='live',
                                        save_all=1,
                                        radio=0))

    return folder
Beispiel #12
0
def update_settings():
    profile_settings = load_profile(profile_id=1)
    settingsJSON = load_file(file='settings.json', isJSON=True)

    try:
        api_url = settingsJSON['api_url']

        if len(api_url) == 0:
            api_url = CONST_DEFAULT_API
    except:
        api_url = CONST_DEFAULT_API

    user_agent = profile_settings['user_agent']

    if len(user_agent) == 0:
        user_agent = DEFAULT_USER_AGENT

    browser_name = uaparser.detect(user_agent)['browser']['name']
    browser_version = uaparser.detect(user_agent)['browser']['version']
    os_name = uaparser.detect(user_agent)['os']['name']
    os_version = uaparser.detect(user_agent)['os']['version']

    query = "UPDATE `vars` SET `api_url`='{api_url}', `browser_name`='{browser_name}', `browser_version`='{browser_version}', `os_name`='{os_name}', `os_version`='{os_version}', `user_agent`='{user_agent}' WHERE profile_id={profile_id}".format(
        api_url=api_url,
        browser_name=browser_name,
        browser_version=browser_version,
        os_name=os_name,
        os_version=os_version,
        user_agent=user_agent,
        profile_id=1)
    query_settings(query=query,
                   return_result=False,
                   return_insert=False,
                   commit=True)
Beispiel #13
0
def api_get_headers():
    creds = get_credentials()
    username = creds['username']

    profile_settings = load_profile(profile_id=1)

    headers = {
        'User-Agent':
        DEFAULT_USER_AGENT,
        'X-Client-Id':
        '{clientid}||{defaultagent}'.format(clientid=CONST_DEFAULT_CLIENTID,
                                            defaultagent=DEFAULT_USER_AGENT),
    }

    if check_key(profile_settings, 'ziggo_profile_id') and len(
            str(profile_settings['ziggo_profile_id'])) > 0:
        headers['X-OESP-Profile-Id'] = profile_settings['ziggo_profile_id']

    if check_key(
            profile_settings,
            'access_token') and len(str(profile_settings['access_token'])) > 0:
        headers['X-OESP-Token'] = profile_settings['access_token']

    if len(str(username)) > 0:
        headers['X-OESP-Username'] = username

    return headers
Beispiel #14
0
def home(**kwargs):
    clear_old()
    check_first()

    profile_settings = load_profile(profile_id=1)

    folder = plugin.Folder()

    if profile_settings and check_key(profile_settings, 'pswd') and len(profile_settings['pswd']) > 0:
        folder.add_item(label=_(_.LIVE_TV, _bold=True),  path=plugin.url_for(func_or_url=live_tv))
        folder.add_item(label=_(_.CHANNELS, _bold=True), path=plugin.url_for(func_or_url=replaytv))

        if settings.getBool('showMoviesSeries'):
            for vod_entry in CONST_VOD_CAPABILITY:
                folder.add_item(label=_(vod_entry['label'], _bold=True), path=plugin.url_for(func_or_url=vod, file=vod_entry['file'], label=vod_entry['label'], start=vod_entry['start'], online=vod_entry['online'], split=vod_entry['split']))

        if CONST_WATCHLIST:
            folder.add_item(label=_(_.WATCHLIST, _bold=True), path=plugin.url_for(func_or_url=watchlist))

        folder.add_item(label=_(_.SEARCH, _bold=True), path=plugin.url_for(func_or_url=search_menu))

    folder.add_item(label=_(_.LOGIN, _bold=True), path=plugin.url_for(func_or_url=login))
    folder.add_item(label=_.SETTINGS, path=plugin.url_for(func_or_url=settings_menu))

    return folder
Beispiel #15
0
def check_first():
    profile_settings = load_profile(profile_id=1)

    if not check_key(profile_settings, 'setup_complete'):
        if gui.yes_no(message=_.DISABLE_EROTICA) == False:
            settings.setBool(key='disableErotica', value=False)
        else:
            settings.setBool(key='disableErotica', value=True)

        if gui.yes_no(message=_.MINIMAL_CHANNELS) == False:
            settings.setBool(key='minimalChannels', value=False)
        else:
            settings.setBool(key='minimalChannels', value=True)

        if gui.yes_no(message=_.DISABLE_REGIONAL) == False:
            settings.setBool(key='disableRegionalChannels', value=False)
        else:
            settings.setBool(key='disableRegionalChannels', value=True)

        if PROVIDER_NAME == 'kpn':
            if gui.yes_no(message=_.HOME_CONNECTION) == True:
                settings.setBool(key='homeConnection', value=True)
            else:
                settings.setBool(key='homeConnection', value=False)

        profile_settings['setup_complete'] = 1
        save_profile(profile_id=1, profile=profile_settings)
Beispiel #16
0
def api_get_session(force=0):
    force = int(force)
    profile_settings = load_profile(profile_id=1)

    if not check_key(profile_settings, 'access_token_age') or not check_key(profile_settings, 'access_token') or int(profile_settings['access_token_age']) < int(time.time() - 3540):
        login_result = api_login()

        if not login_result['result']:
            return False

    profile_settings = load_profile(profile_id=1)
    profile_settings['last_login_success'] = 1
    profile_settings['last_login_time'] = int(time.time())
    save_profile(profile_id=1, profile=profile_settings)

    return True
Beispiel #17
0
def api_add_to_watchlist(id, type):
    if not api_get_session():
        return None

    profile_settings = load_profile(profile_id=1)

    if type == "item":
        mediaitems_url = '{listings_url}/{id}'.format(listings_url=CONST_API_URLS[0]['listings_url'], id=id)
        download = api_download(url=mediaitems_url, type='get', headers=api_get_headers(), data=None, json_data=False, return_json=True)
        data = download['data']
        code = download['code']

        if not code or not code == 200 or not data or not check_key(data, 'mediaGroupId'):
            return False

        id = data['mediaGroupId']

    watchlist_url = '{watchlist_url}/{watchlist_id}/entries/{id}?sharedProfile=true'.format(watchlist_url=CONST_API_URLS[0]['watchlist_url'], watchlist_id=profile_settings['watchlist_id'], id=id)

    download = api_download(url=watchlist_url, type='post', headers=api_get_headers(), data={"mediaGroup": {'id': id}}, json_data=True, return_json=False)
    data = download['data']
    code = download['code']

    if not code or not code == 204 or not data:
        return False

    return True
Beispiel #18
0
def api_get_info(id, channel=''):
    profile_settings = load_profile(profile_id=1)

    info = {}
    base_listing_url = CONST_URLS['listings_url']

    try:
        listing_url = '{listings_url}?byEndTime={time}~&byStationId={channel}&range=1-1&sort=startTime'.format(
            listings_url=base_listing_url,
            time=int(time.time() * 1000),
            channel=id)
        download = api_download(url=listing_url,
                                type='get',
                                headers=api_get_headers(),
                                data=None,
                                json_data=False,
                                return_json=True)
        data = download['data']
        code = download['code']

        if code and code == 200 and data and check_key(data, 'listings'):
            for row in data['listings']:
                if check_key(row, 'program'):
                    info = row['program']

        info = plugin_process_info({
            'title': '',
            'channel': channel,
            'info': info
        })
    except:
        pass

    return info
Beispiel #19
0
def api_clean_after_playback():
    profile_settings = load_profile(profile_id=1)

    headers = api_get_headers()
    headers['Content-type'] = 'application/json'

    download = api_download(url=CONST_API_URLS[0]['clearstreams_url'], type='post', headers=headers, data='{}', json_data=False, return_json=False)
Beispiel #20
0
def api_get_info(id, channel=''):
    if not api_get_session():
        return None

    profile_settings = load_profile(profile_id=1)

    info = {}
    headers = {
        'Authorization':
        'Bearer {token}'.format(token=profile_settings['session_token'])
    }

    info_url = '{api_url}/assets/{channel}'.format(api_url=CONST_URLS['api'],
                                                   channel=id)

    download = api_download(url=info_url,
                            type='get',
                            headers=headers,
                            data=None,
                            json_data=False,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(data, 'id'):
        return info

    info = data

    info = plugin_process_info({'title': '', 'channel': channel, 'info': info})

    return info
Beispiel #21
0
def alternative(num, addon, addons, **kwargs):
    num = int(num)
    profile_settings = load_profile(profile_id=1)
    profile_settings['addon' + str(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 #22
0
def api_get_watchlist_id():
    if not api_get_session():
        return None

    profile_settings = load_profile(profile_id=1)

    watchlist_url = '{watchlist_url}/profile/{profile_id}?language=nl&maxResults=1&order=DESC&sharedProfile=true&sort=added'.format(
        watchlist_url=CONST_API_URLS[int(
            profile_settings['v3'])]['watchlist_url'],
        profile_id=profile_settings['ziggo_profile_id'])

    download = api_download(url=watchlist_url,
                            type='get',
                            headers=api_get_headers(),
                            data=None,
                            json_data=False,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(
            data, 'watchlistId'):
        return False

    try:
        profile_settings['watchlist_id'] = data['watchlistId']
        save_profile(profile_id=1, profile=profile_settings)
    except:
        pass

    return True
Beispiel #23
0
def api_vod_season(series, id, use_cache=True):
    type = "vod_season_{id}".format(id=id)
    type = encode32(type)

    file = os.path.join("cache", "{type}.json".format(type=type))
    cache = 0

    profile_settings = load_profile(profile_id=1)

    if not is_file_older_than_x_days(file=os.path.join(ADDON_PROFILE, file),
                                     days=0.5) and use_cache == True:
        data = load_file(file=file, isJSON=True)
        cache = 1
    else:
        season_url = '{mediaitems_url}?byMediaType=Episode%7CFeatureFilm&byParentId={id}&includeAdult=true&range=1-1000&sort=seriesEpisodeNumber|ASC'.format(
            mediaitems_url=CONST_URLS['mediaitems_url'], id=id)
        download = api_download(url=season_url,
                                type='get',
                                headers=None,
                                data=None,
                                json_data=False,
                                return_json=True)
        data = download['data']
        code = download['code']

    return {'data': data, 'cache': cache}
Beispiel #24
0
def api_oauth_encode(type, base_url, parameters):
    profile_settings = load_profile(profile_id=1)

    base_url_encode = quote(base_url, safe='')

    nonce = ''.join(random.choice(string.ascii_uppercase + string.ascii_lowercase + string.digits) for _ in range(6))
    token_timestamp = int(time.time())

    parameters = parameters.format(token=profile_settings['resource_key'], timestamp=token_timestamp, nonce=nonce)

    parsed_parameters = parse_qs(parameters, keep_blank_values=True)
    encode_string = ''

    for parameter in sorted(parsed_parameters):
        encode_string += quote(unicode(parameter).replace(" ", "%2520") + "=" + unicode(parsed_parameters[parameter][0]).replace(" ", "%2520") + "&", safe='%')

    if encode_string.endswith("%26"):
        encode_string = encode_string[:-len("%26")]

    base_string = '{type}&{token_url_base_encode}&{token_parameter_encode}'.format(type=type, token_url_base_encode=base_url_encode, token_parameter_encode=encode_string)
    base_string_bytes = base_string.encode('utf-8')
    key = 'secret&{key}'.format(key=profile_settings['resource_secret'])
    key_bytes = key.encode('utf-8')

    hashed = hmac.new(key_bytes, base_string_bytes, sha1)
    signature = quote(base64.b64encode(hashed.digest()).decode(), safe='')

    url = '{token_url_base}?{token_parameter}&oauth_signature={signature}'.format(token_url_base=base_url, token_parameter=parameters, signature=signature)

    return url
Beispiel #25
0
def plugin_process_playdata(playdata):
    creds = get_credentials()
    profile_settings = load_profile(profile_id=1)

    CDMHEADERS = {
        'User-Agent': DEFAULT_USER_AGENT,
        'X-Client-Id': CONST_DEFAULT_CLIENTID + '||' + DEFAULT_USER_AGENT,
        'X-OESP-Token': profile_settings['access_token'],
        'X-OESP-Username': creds['username'],
        'X-OESP-License-Token': profile_settings['drm_token'],
        'X-OESP-DRM-SchemeIdUri': 'urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed',
        'X-OESP-Content-Locator': playdata['locator'],
    }

    params = []

    try:
        params.append(('_', 'renew_token'))
        params.append(('path', str(playdata['path']).encode('utf-8')))
        params.append(('locator', str(playdata['locator']).encode('utf-8')))
    except:
        params.append(('_', 'renew_token'))
        params.append(('path', playdata['path']))
        params.append(('locator', playdata['locator']))

    item_inputstream = inputstream.Widevine(
        license_key = playdata['license'],
        media_renewal_url = 'plugin://{0}/?{1}'.format(ADDON_ID, urlencode(encode_obj(params))),
        media_renewal_time = 60,
    )

    return item_inputstream, CDMHEADERS
Beispiel #26
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 #27
0
def api_list_watchlist():
    if not api_get_session():
        return None

    profile_settings = load_profile(profile_id=1)

    if int(profile_settings['v3']) == 1:
        watchlist_url = '{watchlist_url}/profile/{profile_id}?language=nl&order=DESC&sharedProfile=true&sort=added'.format(
            watchlist_url=CONST_API_URLS[int(
                profile_settings['v3'])]['watchlist_url'],
            profile_id=profile_settings['ziggo_profile_id'])
    else:
        watchlist_url = CONST_API_URLS[int(
            profile_settings['v3'])]['watchlist_url']

    download = api_download(url=watchlist_url,
                            type='get',
                            headers=api_get_headers(),
                            data=None,
                            json_data=False,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(
            data, 'entries'):
        return False

    return data
Beispiel #28
0
def api_get_session(force=0):
    force = int(force)
    profile_settings = load_profile(profile_id=1)

    if not force ==1 and check_key(profile_settings, 'last_login_time') and profile_settings['last_login_time'] > int(time.time() - 3600) and profile_settings['last_login_success'] == 1:
        return True
    elif force == 1 and not profile_settings['last_login_success'] == 1:
        return False

    heartbeat_url = '{base_url}/VSP/V3/OnLineHeartbeat?from=inMSAAccess'.format(base_url=CONST_BASE_URL)

    headers = {'Content-Type': 'application/json', 'X_CSRFToken': profile_settings['csrf_token']}

    session_post_data = {}

    download = api_download(url=heartbeat_url, type='post', headers=headers, data=session_post_data, json_data=True, return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(data, 'result') or not check_key(data['result'], 'retCode') or not data['result']['retCode'] == '000000000':
        login_result = api_login()

        if not login_result['result']:
            return False

    try:
        query = "UPDATE `vars` SET `last_login_time`={last_login_time}, `last_login_success`=1 WHERE profile_id={profile_id}".format(last_login_time=int(time.time()),profile_id=1)
        query_settings(query=query, return_result=False, return_insert=False, commit=True)
    except:
        pass

    return True
Beispiel #29
0
def api_watchlist_listing(id):
    if not api_get_session():
        return None

    profile_settings = load_profile(profile_id=1)

    end = int(time.time() * 1000)
    start = end - (7 * 24 * 60 * 60 * 1000)

    mediaitems_url = '{media_items_url}?&byMediaGroupId={id}&byStartTime={start}~{end}&range=1-250&sort=startTime%7Cdesc'.format(
        media_items_url=CONST_API_URLS[int(
            profile_settings['v3'])]['listings_url'],
        id=id,
        start=start,
        end=end)
    download = api_download(url=mediaitems_url,
                            type='get',
                            headers=api_get_headers(),
                            data=None,
                            json_data=False,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(
            data, 'listings'):
        return False

    return data
Beispiel #30
0
def api_list_watchlist(type='watchlist'):
    if not api_get_session():
        return None

    profile_settings = load_profile(profile_id=1)

    headers = api_get_headers(personal=False)

    if type == 'continuewatch':
        watchlist_url = '{base_url}/api/v3/progress/{id}'.format(
            base_url=CONST_URLS['base'], id=profile_settings['profile_id'])
    elif type == 'watchlist':
        watchlist_url = '{base_url}/api/v3/watchlist/{id}'.format(
            base_url=CONST_URLS['base'], id=profile_settings['profile_id'])

    download = api_download(url=watchlist_url,
                            type='get',
                            headers=headers,
                            data=None,
                            json_data=False,
                            return_json=True)
    data = download['data']
    code = download['code']

    if code and code == 200 and data and check_key(data, 'count'):
        return data

    return None