def plugin_process_playdata(playdata): profile_settings = load_profile(profile_id=1) CDMHEADERS = { 'User-Agent': DEFAULT_USER_AGENT, 'X_CSRFToken': profile_settings['csrf_token'], 'Cookie': playdata['license']['cookie'], } if check_key(playdata, 'license') and check_key( playdata['license'], 'triggers') and check_key( playdata['license']['triggers'][0], 'licenseURL'): item_inputstream = inputstream.Widevine( license_key=playdata['license']['triggers'][0]['licenseURL'], #manifest_update_parameter = 'update', ) if check_key(playdata['license']['triggers'][0], 'customData'): CDMHEADERS['AcquireLicense.CustomData'] = playdata['license'][ 'triggers'][0]['customData'] CDMHEADERS['CADeviceType'] = 'Widevine OTT client' else: item_inputstream = inputstream.MPD( #manifest_update_parameter = 'update', ) return item_inputstream, CDMHEADERS
def plugin_process_vod_seasons(id, data): seasons = [] if not data: return None season_count = 0 if check_key(data, 'seasons'): for row in data['seasons']: season_count += 1 image = '' if check_key(data, 'image'): if check_key(data['image'], 'portraitUrl'): image = data['image']['portraitUrl'] elif check_key(data['image'], 'landscapeUrl'): image = data['image']['landscapeUrl'] seasons.append({ 'id': row['id'], 'seriesNumber': row['title'], 'description': data['description'], 'image': image }) seasons[:] = sorted(seasons, key=sort_season) return {'program': data, 'type': 'seasons', 'seasons': seasons}
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
def plugin_login_error(login_result): if check_key(login_result['data'], 'result') and check_key( login_result['data']['result'], 'retCode' ) and login_result['data']['result']['retCode'] == "157022007": gui.ok(message=_.TOO_MANY_DEVICES, heading=_.LOGIN_ERROR_TITLE) else: gui.ok(message=_.LOGIN_ERROR, heading=_.LOGIN_ERROR_TITLE)
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
def api_vod_subscription(): if not api_get_session(): return None profile_settings = load_profile(profile_id=1) subscription = [] series_url = '{api_url}/TRAY/SEARCH/VOD?from=1&to=9999&filter_contentType=GROUP_OF_BUNDLES,VOD&filter_contentSubtype=SERIES,VOD&filter_contentTypeExtended=VOD&filter_excludedGenres=erotiek&filter_technicalPackages=10078,10081,10258,10255&dfilter_packages=matchSubscription&orderBy=activationDate&sortOrder=desc'.format( api_url=profile_settings['api_url']) download = api_download(url=series_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' or not check_key( data, 'resultObj') or not check_key(data['resultObj'], 'containers'): return False for row in data['resultObj']['containers']: subscription.append(row['metadata']['contentId']) write_file(file='vod_subscription.json', data=subscription, isJSON=True) return True
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
def api_vod_seasons(type, id, use_cache=True): type = "vod_seasons_{id}".format(id=id) type = encode32(type) file = os.path.join("cache", "{type}.json".format(type=type)) program_url = '{api_url}/CONTENT/DETAIL/GROUP_OF_BUNDLES/{id}'.format( api_url=CONST_URLS['api'], id=id) cache = 0 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: download = api_download(url=program_url, type='get', headers=None, 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, 'resultCode') and data['resultCode'] == 'OK' and check_key( data, 'resultObj') and check_key(data['resultObj'], 'containers'): write_file(file=file, data=data, isJSON=True) return {'data': data, 'cache': cache}
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
def plugin_process_vod_seasons(id, data): seasons = [] if not data or not check_key(data['resultObj'], 'containers'): return None for row in data['resultObj']['containers']: for currow in row['containers']: if check_key(currow, 'metadata') and check_key( currow['metadata'], 'season') and str( currow['metadata']['contentSubtype']) == 'SEASON': seasons.append({ 'id': str(currow['metadata']['contentId']), 'seriesNumber': str(currow['metadata']['season']), 'description': str(currow['metadata']['shortDescription']), 'image': "{image_url}/vod/{image}/1920x1080.jpg?blurred=false". format(image_url=CONST_URLS['image'], image=str(currow['metadata']['pictureUrl'])) }) return {'type': 'seasons', 'seasons': seasons}
def plugin_process_vod_seasons(id, data): seasons = [] ref = id id = id[1:] if not data or not check_key(data, 'details'): return None for currow in data['details']: row = data['details'][currow] if check_key(row, 'type') and row['type'] == 'season': if settings.getBool('use_small_images', default=False) == True: image = data['poster'].replace( CONST_IMAGES['poster']['replace'], CONST_IMAGES['poster']['small']) else: image = data['poster'].replace( CONST_IMAGES['poster']['replace'], CONST_IMAGES['poster']['large']) seasons.append({ 'id': str(id) + '###' + str(row['id']), 'seriesNumber': row['title'], 'description': data['description'], 'image': image, 'watchlist': ref }) return {'type': 'seasons', 'seasons': seasons}
def api_vod_subscription(): file = "cache" + os.sep + "vod_subscription.json" if not is_file_older_than_x_days(file=ADDON_PROFILE + file, days=1): load_file(file=file, isJSON=True) else: if not api_get_session(): return None subscription = [] series_url = '{api_url}/TRAY/SEARCH/VOD?from=1&to=9999&filter_contentType=GROUP_OF_BUNDLES,VOD&filter_contentSubtype=SERIES,VOD&filter_contentTypeExtended=VOD&filter_excludedGenres=erotiek&filter_technicalPackages=10078,10081,10258,10255&dfilter_packages=matchSubscription&orderBy=activationDate&sortOrder=desc'.format( api_url=CONST_DEFAULT_API) download = api_download(url=series_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' or not check_key( data, 'resultObj') or not check_key(data['resultObj'], 'containers'): return False for row in data['resultObj']['containers']: subscription.append(row['metadata']['contentId']) write_file(file=file, data=subscription, isJSON=True) return True
def plugin_process_playdata(playdata): CDMHEADERS = {} if check_key(playdata, 'license') and check_key( playdata['license'], 'drmConfig') and check_key( playdata['license']['drmConfig'], 'widevine'): if 'nlznl.solocoo.tv' in playdata['license']['drmConfig']['widevine'][ 'drmServerUrl']: if xbmc.Monitor().waitForAbort(1): return False if check_key(playdata['license']['drmConfig']['widevine'], 'customHeaders'): for row in playdata['license']['drmConfig']['widevine'][ 'customHeaders']: CDMHEADERS[row] = playdata['license']['drmConfig']['widevine'][ 'customHeaders'][row] item_inputstream = inputstream.Widevine( license_key=playdata['license']['drmConfig']['widevine'] ['drmServerUrl'], ) else: item_inputstream = inputstream.MPD() return item_inputstream, CDMHEADERS
def api_vod_seasons(type, id): if not api_get_session(): return None seasons = [] program_url = '{api_url}/CONTENT/DETAIL/GROUP_OF_BUNDLES/{id}'.format(api_url=CONST_DEFAULT_API, id=id) type = "vod_seasons_" + unicode(id) encodedBytes = base64.b32encode(type.encode("utf-8")) type = unicode(encodedBytes, "utf-8") file = "cache" + os.sep + type + ".json" if not is_file_older_than_x_days(file=ADDON_PROFILE + file, days=0.5): data = load_file(file=file, isJSON=True) else: download = api_download(url=program_url, type='get', headers=None, 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, 'resultCode') and data['resultCode'] == 'OK' and check_key(data, 'resultObj') and check_key(data['resultObj'], 'containers'): write_file(file=file, data=data, isJSON=True) if not data or not check_key(data['resultObj'], 'containers'): return None for row in data['resultObj']['containers']: for currow in row['containers']: if check_key(currow, 'metadata') and check_key(currow['metadata'], 'season') and unicode(currow['metadata']['contentSubtype']) == 'SEASON': seasons.append({'id': unicode(currow['metadata']['contentId']), 'seriesNumber': unicode(currow['metadata']['season']), 'description': unicode(currow['metadata']['shortDescription']), 'image': "{image_url}/vod/{image}/1920x1080.jpg?blurred=false".format(image_url=CONST_IMAGE_URL, image=unicode(currow['metadata']['pictureUrl']))}) return {'type': 'seasons', 'seasons': seasons}
def api_get_session(force=0): force = int(force) profile_url = '{base_url}/api/v3/profiles'.format(base_url=CONST_BASE_URL) headers = { 'videoland-platform': 'videoland', "Referer": CONST_BASE_URL + "/profielkeuze", } download = api_download(url=profile_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[0], 'id') or not check_key(data[0], 'gigya_id'): 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
def api_play_url(type, channel=None, id=None, video_data=None, from_beginning=0, pvr=0, change_audio=0): playdata = {'path': '', 'license': '', 'token': '', 'type': '', 'info': '', 'properties': {}} if not api_get_session(): return playdata from_beginning = int(from_beginning) pvr = int(pvr) change_audio = int(change_audio) profile_settings = load_profile(profile_id=1) license = '' asset_id = '' militime = int(time.time() * 1000) typestr = 'PROGRAM' properties = {} info = {} program_id = None if 'channelId=' in id: #play_url = '{base_url}/1.0/R/ENG/WEB_HLS/ALL/{id}'.format(base_url=CONST_URLS['base'], id=id) play_url = '{base_url}/2.0/R/ENG/WEB_HLS/ALL/{id}'.format(base_url=CONST_URLS['base'], id=id) qs = parse_qs(play_url) info_url = '{base_url}/2.0/R/ENG/WEB_DASH/ALL/CONTENT/VIDEO/{id}/F1_TV_Pro_Annual/2?contentId={id}'.format(base_url=CONST_URLS['base'], id=qs['contentId'][0]) else: #play_url = '{base_url}/1.0/R/ENG/WEB_HLS/ALL/CONTENT/PLAY?contentId={id}'.format(base_url=CONST_URLS['base'], id=id) play_url = '{base_url}/2.0/R/ENG/WEB_HLS/ALL/CONTENT/PLAY?contentId={id}'.format(base_url=CONST_URLS['base'], id=id) info_url = '{base_url}/2.0/R/ENG/WEB_DASH/ALL/CONTENT/VIDEO/{id}/F1_TV_Pro_Annual/2?contentId={id}'.format(base_url=CONST_URLS['base'], id=id) download = api_download(url=info_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' or not check_key(data, 'resultObj') or not check_key(data['resultObj'], 'containers'): return playdata info = data headers = { 'ascendontoken': profile_settings['subscriptionToken'] } download = api_download(url=play_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, 'resultCode') or not data['resultCode'] == 'OK' or not check_key(data, 'resultObj') or not check_key(data['resultObj'], 'entitlementToken') or not check_key(data['resultObj'], 'url'): return playdata path = data['resultObj']['url'] token = data['resultObj']['entitlementToken'] if not len(str(token)) > 0: return playdata playdata = {'path': path, 'license': license, 'token': token, 'type': typestr, 'info': info, 'properties': properties} return playdata
def api_vod_seasons(type, id): if not api_get_session(): return None seasons = [] type = "vod_seasons_" + str(id) encodedBytes = base64.b32encode(type.encode("utf-8")) type = str(encodedBytes, "utf-8") file = "cache" + os.sep + type + ".json" ref = id id = id[1:] if not is_file_older_than_x_days(file=ADDON_PROFILE + file, days=0.5): data = load_file(file=file, isJSON=True) else: headers = { 'videoland-platform': 'videoland', } seasons_url = '{base_url}/api/v3/series/{series}'.format( base_url=CONST_BASE_URL, series=id) download = api_download(url=seasons_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, 'title'): write_file(file=file, data=data, isJSON=True) if not data or not check_key(data, 'details'): return None for currow in data['details']: row = data['details'][currow] if check_key(row, 'type') and row['type'] == 'season': seasons.append({ 'id': str(id) + '###' + str(row['id']), 'seriesNumber': row['title'], 'description': data['description'], 'image': data['poster'].replace('[format]', '960x1433'), 'watchlist': ref }) return {'type': 'seasons', 'seasons': seasons}
def plugin_process_info(playdata): info = { 'label1': '', 'label2': '', 'description': '', 'image': '', 'image_large': '', 'duration': 0, 'credits': [], 'cast': [], 'director': [], 'writer': [], 'genres': [], 'year': '', } if check_key(playdata['info'], 'startTime') and check_key( playdata['info'], 'endTime'): startT = datetime.datetime.fromtimestamp( (int(playdata['info']['startTime']) / 1000)) startT = convert_datetime_timezone(startT, "UTC", "UTC") endT = datetime.datetime.fromtimestamp( (int(playdata['info']['endTime']) / 1000)) endT = convert_datetime_timezone(endT, "UTC", "UTC") info['duration'] = int((endT - startT).total_seconds()) if xbmc.getLanguage(xbmc.ISO_639_1) == 'nl': info[ 'label1'] = '{weekday} {day} {month} {yearhourminute} '.format( weekday=date_to_nl_dag(startT), day=startT.strftime("%d"), month=date_to_nl_maand(startT), yearhourminute=startT.strftime("%Y %H:%M")) else: info['label1'] = startT.strftime("%A %d %B %Y %H:%M ").capitalize() info['label1'] += " - " if check_key(playdata['info'], 'name'): info['label1'] += playdata['info']['name'] info['label2'] = playdata['info']['name'] if check_key(playdata['info'], 'introduce'): info['description'] = playdata['info']['introduce'] if check_key(playdata['info'], 'picture'): info['image'] = playdata['info']['picture']['posters'][0] info['image_large'] = playdata['info']['picture']['posters'][0] data = api_get_channels() try: info['label2'] += " - " + data[unicode(playdata['channel'])]['name'] except: pass return info
def api_get_info(id, channel=''): profile_settings = load_profile(profile_id=1) info = {} friendly = '' data = api_get_channels() try: friendly = data[str(id)]['assetid'] except: return info channel_url = '{base_url}/v7/epg/locations/{friendly}/live/1?fromDate={date}'.format( base_url=CONST_URLS['api'], friendly=friendly, date=datetime.datetime.now().strftime("%Y-%m-%dT%H%M%S")) download = api_download(url=channel_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: return info for row in data: if not check_key(row, 'Channel') or not check_key(row, 'Locations'): return info for row2 in row['Locations']: id = row2['LocationId'] if not id: return info info_url = '{base_url}/v7/epg/location/{location}'.format( base_url=CONST_URLS['api'], location=id) download = api_download(url=info_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: return info info = data return plugin_process_info({'title': '', 'channel': channel, 'info': info})
def plugin_process_vod_season(series, id, data): season = [] episodes = [] if not data or not check_key(data['resultObj'], 'containers'): return None for row in data['resultObj']['containers']: for currow in row['containers']: if check_key(currow, 'metadata') and check_key( currow['metadata'], 'season') and str( currow['metadata'] ['contentSubtype']) == 'EPISODE' and not str( currow['metadata']['episodeNumber']) in episodes: asset_id = '' for asset in currow['assets']: if check_key( asset, 'videoType' ) and asset['videoType'] == 'SD_DASH_PR' and check_key( asset, 'assetType') and asset['assetType'] == 'MASTER': asset_id = str(asset['assetId']) break episodes.append(str(currow['metadata']['episodeNumber'])) label = '{season}.{episode} - {title}'.format( season=str(currow['metadata']['season']), episode=str(currow['metadata']['episodeNumber']), title=str(currow['metadata']['episodeTitle'])) season.append({ 'label': label, 'id': str(currow['metadata']['contentId']), 'assetid': asset_id, 'duration': currow['metadata']['duration'], 'title': str(currow['metadata']['episodeTitle']), 'episodeNumber': '{season}.{episode}'.format( season=str(currow['metadata']['season']), episode=str(currow['metadata']['episodeNumber'])), 'description': str(currow['metadata']['shortDescription']), 'image': "{image_url}/vod/{image}/1920x1080.jpg?blurred=false". format(image_url=CONST_URLS['image'], image=str(currow['metadata']['pictureUrl'])) }) return season
def get_play_url(content): profile_settings = load_profile(profile_id=1) if int(profile_settings['v3']) == 1 and check_key(content, 'url') and check_key(content, 'contentLocator'): return {'play_url': content['url'], 'locator': content['contentLocator']} else: for stream in content: if 'streamingUrl' in stream and 'contentLocator' in stream and 'assetTypes' in stream and 'Orion-DASH' in stream['assetTypes']: return {'play_url': stream['streamingUrl'], 'locator': stream['contentLocator']} return {'play_url': '', 'locator': ''}
def vod_series(label, type, id, **kwargs): folder = plugin.Folder(title=label) items = [] context = [] seasons = api_vod_seasons(type, id) title = label if seasons and check_key(seasons, 'seasons'): if CONST_WATCHLIST and check_key(seasons, 'watchlist'): context.append((_.ADD_TO_WATCHLIST, 'RunPlugin({context_url})'.format(context_url=plugin.url_for(func_or_url=add_to_watchlist, id=seasons['watchlist'], type='group')), )) if seasons['type'] == "seasons": for season in seasons['seasons']: label = _.SEASON + " " + unicode(season['seriesNumber']).replace('Seizoen ', '') items.append(plugin.Item( label = label, info = {'plot': unicode(season['description']), 'sorttitle': label.upper()}, art = { 'thumb': unicode(season['image']), 'fanart': unicode(season['image']) }, path = plugin.url_for(func_or_url=vod_season, label=label, series=id, id=unicode(season['id'])), context = context, )) else: for episode in seasons['seasons']: items.append(plugin.Item( label = unicode(episode['label']), info = { 'plot': unicode(episode['description']), 'duration': episode['duration'], 'mediatype': 'video', 'sorttitle': unicode(episode['label']).upper(), }, art = { 'thumb': unicode(episode['image']), 'fanart': unicode(episode['image']) }, path = plugin.url_for(func_or_url=play_video, type='vod', channel=None, id=unicode(episode['id'])), context = context, playable = True, )) folder.add_items(items) return folder
def change_channel(type, id, change, **kwargs): change = int(change) if not id or len(unicode(id)) == 0 or not type or len(unicode(type)) == 0: return False prefs = load_prefs(profile_id=1) id = unicode(id) type = unicode(type) data = api_get_channels() if data and check_key(data, id) and prefs and check_key(prefs, id) and int(prefs[id][type]) == 0: if type == 'replay' and int(data[id]['replay']) == 0: gui.ok(message=_.EXPLAIN_NO_REPLAY) return False elif settings.getBool(key='homeConnection') == False and int(data[id]['home_only']) == 1: gui.ok(message=_.EXPLAIN_HOME_CONNECTION) return False keys = ['live', 'replay'] mod_pref = { 'live': 1, 'replay': 1, } if prefs and check_key(prefs, id): for key in keys: if key == type: continue mod_pref[key] = prefs[id][key] if change == 0: if not check_key(prefs, id): mod_pref[type] = 0 else: if prefs[id][type] == 1: mod_pref[type] = 0 else: mod_pref[type] = 1 else: mod_pref[type] = 1 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) + '/?_=channel_picker&type=' + type + '"]}}}}')
def plugin_process_playdata(playdata): profile_settings = load_profile(profile_id=1) CDMHEADERS = { 'User-Agent': DEFAULT_USER_AGENT, } if check_key(playdata, 'license') and check_key(playdata['license'], 'widevine') and check_key(playdata['license']['widevine'], 'license'): item_inputstream = inputstream.Widevine( license_key = playdata['license']['widevine']['license'], ) else: item_inputstream = inputstream.MPD() return item_inputstream, CDMHEADERS
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
def api_vod_seasons(type, id): if not api_get_session(): return None type = "vod_seasons_{id}".format(id=id) type = encode32(type) file = os.path.join("cache", "{type}.json".format(type=type)) cache = 0 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: profile_settings = load_profile(profile_id=1) headers = { 'Content-Type': 'application/json', 'X_CSRFToken': profile_settings['csrf_token'] } session_post_data = { 'VODID': str(id), 'offset': '0', 'count': '50', } seasons_url = '{base_url}/VSP/V3/QueryEpisodeList?from=throughMSAAccess'.format( base_url=CONST_URLS['base']) download = api_download(url=seasons_url, type='post', headers=headers, data=session_post_data, json_data=True, return_json=True) data = download['data'] code = download['code'] if code and code == 200 and data and check_key( data, 'result') and check_key( data['result'], 'retCode' ) and data['result']['retCode'] == '000000000' and check_key( data, 'episodes'): write_file(file=file, data=data, isJSON=True) return {'data': data, 'cache': cache}
def search_menu(**kwargs): folder = plugin.Folder(title=_.SEARCHMENU) label = _.NEWSEARCH folder.add_item( label = label, info = {'plot': _.NEWSEARCHDESC}, path = plugin.url_for(func_or_url=search), ) if CONST_ONLINE_SEARCH: folder.add_item( label= label + " (Online)", path=plugin.url_for(func_or_url=online_search) ) profile_settings = load_profile(profile_id=1) for x in range(1, 10): try: if check_key(profile_settings, 'search' + unicode(x)): searchstr = profile_settings['search' + unicode(x)] else: searchstr = '' if searchstr != '': label = unicode(searchstr) path = plugin.url_for(func_or_url=search, query=searchstr) if CONST_ONLINE_SEARCH: if check_key(profile_settings, 'search_type' + unicode(x)): type = profile_settings['search_type' + unicode(x)] else: type = 0 if type == 1: label = unicode(searchstr) + ' (Online)' path = plugin.url_for(func_or_url=online_search, query=searchstr) folder.add_item( label = label, info = {'plot': _(_.SEARCH_FOR, query=searchstr)}, path = path, ) except: pass return folder
def search(query=None, **kwargs): items = [] if not query: query = gui.input(message=_.SEARCH, default='').strip() if not query: return profile_settings = load_profile(profile_id=1) for x in reversed(range(2, 10)): if check_key(profile_settings, 'search' + unicode(x - 1)): profile_settings['search' + unicode(x)] = profile_settings['search' + unicode(x - 1)] else: profile_settings['search' + unicode(x)] = '' profile_settings['search1'] = query if CONST_ONLINE_SEARCH: for x in reversed(range(2, 10)): if check_key(profile_settings, 'search_type' + unicode(x - 1)): profile_settings['search_type' + unicode(x)] = profile_settings['search_type' + unicode(x - 1)] else: profile_settings['search_type' + unicode(x)] = 0 profile_settings['search_type1'] = 0 save_profile(profile_id=1, profile=profile_settings) else: query = unicode(query) folder = plugin.Folder(title=_(_.SEARCH_FOR, query=query)) processed = process_replaytv_search(search=query) items += processed['items'] if settings.getBool('showMoviesSeries'): for vod_entry in CONST_VOD_CAPABILITY: processed = process_vod_content(data=vod_entry['file'], start=vod_entry['start'], search=query, type=vod_entry['label'], online=vod_entry['online']) items += processed['items'] items[:] = sorted(items, key=_sort_replay_items, reverse=True) items = items[:25] folder.add_items(items) return folder
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
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