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 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 api_play_url(type, channel=None, id=None, video_data=None, from_beginning=0, pvr=0): playdata = { 'path': '', 'license': '', 'token': '', 'locator': '', 'type': '', 'alt_path': '', 'alt_license': '', 'alt_locator': '' } if not api_get_session(): return playdata from_beginning = int(from_beginning) pvr = int(pvr) profile_settings = load_profile(profile_id=1) if type == "channel": id = channel alt_path = '' alt_license = '' alt_locator = '' info = {} base_listing_url = CONST_API_URLS[int( profile_settings['v3'])]['listings_url'] urldata = None urldata2 = None path = None locator = None if not type or not len(unicode(type)) > 0 or not id or not len( unicode(id)) > 0: return playdata if type == 'channel': data = api_get_channels() try: split = data[id]['assetid'].rsplit('&%%&', 1) if len(split) == 2: urldata = {'play_url': split[0], 'locator': split[1]} else: return playdata except: return playdata 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'] elif type == 'program': listings_url = "{listings_url}/{id}".format( listings_url=base_listing_url, id=id) download = api_download(url=listings_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, 'program'): return playdata info = data['program'] elif type == 'vod': mediaitems_url = '{mediaitems_url}/{id}'.format( mediaitems_url=CONST_API_URLS[int( profile_settings['v3'])]['mediaitems_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: return playdata info = data if check_key(info, 'videoStreams'): urldata2 = get_play_url(content=info['videoStreams']) if not type == 'channel' and ( not urldata2 or not check_key(urldata2, 'play_url') or not check_key(urldata2, 'locator') or urldata2['play_url'] == 'http://Playout/using/Session/Service') and int( profile_settings['v3']) == 1: urldata2 = {} if type == 'program': playout_str = 'replay' elif type == 'vod': playout_str = 'vod' else: return playdata playout_url = '{base_url}/playout/{playout_str}/{id}?abrType=BR-AVC-DASH'.format( base_url=CONST_API_URLS[int(profile_settings['v3'])]['base_url'], playout_str=playout_str, id=id) download = api_download(url=playout_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, 'url') or not check_key(data, 'contentLocator'): return playdata urldata2['play_url'] = data['url'] urldata2['locator'] = data['contentLocator'] if urldata and urldata2 and check_key(urldata, 'play_url') and check_key( urldata, 'locator') and check_key( urldata2, 'play_url') and check_key(urldata2, 'locator'): path = urldata['play_url'] locator = urldata['locator'] alt_path = urldata2['play_url'] alt_locator = urldata2['locator'] else: if urldata and check_key(urldata, 'play_url') and check_key( urldata, 'locator'): path = urldata['play_url'] locator = urldata['locator'] elif urldata2 and check_key(urldata2, 'play_url') and check_key( urldata2, 'locator'): path = urldata2['play_url'] locator = urldata2['locator'] if not locator or not len(unicode(locator)) > 0: return playdata license = CONST_API_URLS[int(profile_settings['v3'])]['widevine_url'] alt_license = CONST_API_URLS[int(profile_settings['v3'])]['widevine_url'] token = api_get_play_token(locator=locator, path=path, force=1) if not token or not len(unicode(token)) > 0: return playdata token = 'WIDEVINETOKEN' token_regex = re.search(r"(?<=;vxttoken=)(.*?)(?=/)", path) if token_regex and token_regex.group(1) and len(token_regex.group(1)) > 0: path = path.replace(token_regex.group(1), token) else: if 'sdash/' in path: spliturl = path.split('sdash/', 1) if len(spliturl) == 2: if int(profile_settings['v3']) == 1: path = '{urlpart1}sdash;vxttoken={token}/{urlpart2}'.format( urlpart1=spliturl[0], token=token, urlpart2=spliturl[1]) else: path = '{urlpart1}sdash;vxttoken={token}/{urlpart2}?device=Orion-Replay-DASH'.format( urlpart1=spliturl[0], token=token, urlpart2=spliturl[1]) else: spliturl = path.rsplit('/', 1) if len(spliturl) == 2: path = '{urlpart1};vxttoken={token}/{urlpart2}'.format( urlpart1=spliturl[0], token=token, urlpart2=spliturl[1]) playdata = { 'path': path, 'license': license, 'token': token, 'locator': locator, 'info': info, 'type': type, 'alt_path': alt_path, 'alt_license': alt_license, 'alt_locator': alt_license } return playdata
def plugin_process_watchlist_listing(data, id=None): items = [] if check_key(data, 'listings'): for row in data['listings']: context = [] if not check_key(row, 'program'): continue currow = row['program'] if not check_key(currow, 'title') or not check_key(row, 'id'): continue duration = 0 if check_key(row, 'endTime') and check_key(row, 'startTime'): startsplit = int(row['startTime']) // 1000 endsplit = int(row['endTime']) // 1000 duration = endsplit - startsplit startT = datetime.datetime.fromtimestamp(startsplit) startT = convert_datetime_timezone(startT, "UTC", "UTC") endT = datetime.datetime.fromtimestamp(endsplit) endT = convert_datetime_timezone(endT, "UTC", "UTC") if endT < (datetime.datetime.now(pytz.timezone("UTC")) - datetime.timedelta(days=7)): continue if xbmc.getLanguage(xbmc.ISO_639_1) == 'nl': label = '{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: label = startT.strftime("%A %d %B %Y %H:%M ").capitalize() label += currow['title'] else: label = currow['title'] data2 = api_get_channels() try: label += ' ({station})'.format(station=data2[unicode(currow['stationId'])]['name']) except: pass if id: context.append((_.ADD_TO_WATCHLIST, 'RunPlugin({context_url})'.format(context_url=plugin.url_for(func_or_url=add_to_watchlist, id=id, type="group")), )) channel = '' description = '' program_image = '' program_image_large = '' if check_key(currow, 'description'): description = currow['description'] if check_key(currow, 'duration'): duration = int(currow['duration']) if check_key(currow, 'images'): program_image = get_image("boxart", currow['images']) program_image_large = get_image("HighResLandscape", currow['images']) if program_image_large == '': program_image_large = program_image else: program_image_large += '?w=1920&mode=box' items.append(plugin.Item( label = label, info = { 'plot': description, 'duration': duration, 'mediatype': 'video', 'sorttitle': label.upper(), }, art = { 'thumb': program_image, 'fanart': program_image_large }, path = plugin.url_for(func_or_url=play_video, type="program", channel=channel, id=row['id']), playable = True, context = context )) return items
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'): if check_key(playdata['info'], 'latestBroadcastEndTime') and check_key(playdata['info'], 'latestBroadcastStartTime'): startsplit = int(playdata['info']['latestBroadcastStartTime']) // 1000 endsplit = int(playdata['info']['latestBroadcastEndTime']) // 1000 duration = endsplit - startsplit startT = datetime.datetime.fromtimestamp(startsplit) startT = convert_datetime_timezone(startT, "UTC", "UTC") endT = datetime.datetime.fromtimestamp(endsplit) endT = convert_datetime_timezone(endT, "UTC", "UTC") 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() if playdata['title']: info['label1'] += playdata['title'] + ' - ' + playdata['info']['title'] else: info['label1'] += playdata['info']['title'] if check_key(playdata['info'], 'duration'): info['duration'] = int(playdata['info']['duration']) elif check_key(playdata['info'], 'latestBroadcastStartTime') and check_key(playdata['info'], 'latestBroadcastEndTime'): info['duration'] = int(int(playdata['info']['latestBroadcastEndTime']) - int(playdata['info']['latestBroadcastStartTime'])) // 1000 if check_key(playdata['info'], 'description'): info['description'] = playdata['info']['description'] if check_key(playdata['info'], 'duration'): info['duration'] = int(playdata['info']['duration']) if check_key(playdata['info'], 'year'): info['year'] = int(playdata['info']['year']) if check_key(playdata['info'], 'images'): info['image'] = get_image("boxart", playdata['info']['images']) info['image_large'] = get_image("HighResLandscape", playdata['info']['images']) if info['image_large'] == '': info['image_large'] = info['image'] else: info['image_large'] += '?w=1920&mode=box' if check_key(playdata['info'], 'categories'): for categoryrow in playdata['info']['categories']: info['genres'].append(categoryrow['title']) if check_key(playdata['info'], 'cast'): for castrow in playdata['info']['cast']: info['cast'].append(castrow) if check_key(playdata['info'], 'directors'): for directorrow in playdata['info']['directors']: info['director'].append(directorrow) epcode = '' if check_key(playdata['info'], 'seriesNumber'): epcode += 'S' + unicode(playdata['info']['seriesNumber']) if check_key(playdata['info'], 'seriesEpisodeNumber'): epcode += 'E' + unicode(playdata['info']['seriesEpisodeNumber']) if check_key(playdata['info'], 'secondaryTitle'): info['label2'] = playdata['info']['secondaryTitle'] if len(epcode) > 0: info['label2'] += " (" + epcode + ")" else: info['label2'] = playdata['info']['title'] data = api_get_channels() try: info['label2'] += " - " + data[unicode(playdata['channel'])]['name'] except: pass return info
def api_play_url(type, channel=None, id=None, video_data=None, test=False, from_beginning=0, pvr=0): playdata = { 'path': '', 'license': '', 'info': '', 'alt_path': '', 'alt_license': '' } if not api_get_session(): return playdata alt_path = '' alt_license = '' from_beginning = int(from_beginning) pvr = int(pvr) profile_settings = load_profile(profile_id=1) headers = { 'Content-Type': 'application/json', 'X_CSRFToken': profile_settings['csrf_token'] } mediaID = None info = {} if not type or not len(unicode(type)) > 0: return playdata militime = int(time.time() * 1000) if not type == 'vod': if video_data: try: video_data = json.loads(video_data) mediaID = int(video_data['media_id']) + 1 except: pass data = api_get_channels() try: mediaID = data[unicode(channel)]['assetid'] except: pass if type == 'channel' and channel: if not pvr == 1 or settings.getBool( key='ask_start_from_beginning') or from_beginning == 1: session_post_data = { 'needChannel': '0', 'queryChannel': { 'channelIDs': [ channel, ], 'isReturnAllMedia': '1', }, 'queryPlaybill': { 'count': '1', 'endTime': militime, 'isFillProgram': '1', 'offset': '0', 'startTime': militime, 'type': '0', } } channel_url = '{base_url}/VSP/V3/QueryPlaybillListStcProps?SID=queryPlaybillListStcProps3&DEVICE=PC&DID={deviceID}&from=throughMSAAccess'.format( base_url=CONST_BASE_URL, deviceID=profile_settings['devicekey']) download = api_download(url=channel_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' or not check_key( data, 'channelPlaybills') or not check_key( data['channelPlaybills'][0], 'playbillLites') or not check_key( data['channelPlaybills'][0] ['playbillLites'][0], 'ID'): return playdata id = data['channelPlaybills'][0]['playbillLites'][0]['ID'] session_post_data = { 'playbillID': id, 'channelNamespace': '310303', 'isReturnAllMedia': '1', } program_url = '{base_url}/VSP/V3/QueryPlaybill?from=throughMSAAccess'.format( base_url=CONST_BASE_URL) download = api_download(url=program_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' or not check_key( data, 'playbillDetail'): info = {} else: info = data['playbillDetail'] if settings.getBool( key='ask_start_from_beginning') or from_beginning == 1: session_post_data = { "businessType": "PLTV", "channelID": channel, "checkLock": { "checkType": "0", }, "isHTTPS": "1", "isReturnProduct": "1", "mediaID": mediaID, 'playbillID': id, } play_url_path = '{base_url}/VSP/V3/PlayChannel?from=throughMSAAccess'.format( base_url=CONST_BASE_URL) download = api_download(url=play_url_path, 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' or not check_key( data, 'playURL'): pass else: alt_path = data['playURL'] if check_key(data, 'authorizeResult'): profile_settings = load_profile(profile_id=1) data['authorizeResult']['cookie'] = api_getCookies( load_file('stream_cookies'), '') alt_license = data['authorizeResult'] session_post_data = { "businessType": "BTV", "channelID": channel, "checkLock": { "checkType": "0", }, "isHTTPS": "1", "isReturnProduct": "1", "mediaID": mediaID, } elif type == 'program' and id: if not test and not pvr == 1: session_post_data = { 'playbillID': id, 'channelNamespace': '310303', 'isReturnAllMedia': '1', } program_url = '{base_url}/VSP/V3/QueryPlaybill?from=throughMSAAccess'.format( base_url=CONST_BASE_URL) download = api_download(url=program_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' or not check_key( data, 'playbillDetail'): info = {} else: info = data['playbillDetail'] session_post_data = { "businessType": "CUTV", "channelID": channel, "checkLock": { "checkType": "0", }, "isHTTPS": "1", "isReturnProduct": "1", "mediaID": mediaID, "playbillID": id, } elif type == 'vod' and id: session_post_data = {'VODID': id} program_url = '{base_url}/VSP/V3/QueryVOD?from=throughMSAAccess'.format( base_url=CONST_BASE_URL) download = api_download(url=program_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' or not check_key( data, 'VODDetail') or not check_key( data['VODDetail'], 'VODType'): return playdata info = data['VODDetail'] session_post_data = { "VODID": id, "checkLock": { "checkType": "0", }, "isHTTPS": "1", "isReturnProduct": "1", "mediaID": '', } if not check_key(info, 'mediaFiles') or not check_key( info['mediaFiles'][0], 'ID'): return playdata if check_key(info, 'series') and check_key(info['series'][0], 'VODID'): session_post_data["seriesID"] = info['series'][0]['VODID'] session_post_data["mediaID"] = info['mediaFiles'][0]['ID'] if not len(unicode(session_post_data["mediaID"])) > 0: return playdata if type == 'vod': play_url_path = '{base_url}/VSP/V3/PlayVOD?from=throughMSAAccess'.format( base_url=CONST_BASE_URL) else: play_url_path = '{base_url}/VSP/V3/PlayChannel?from=throughMSAAccess'.format( base_url=CONST_BASE_URL) download = api_download(url=play_url_path, 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' or not check_key( data, 'playURL'): return playdata path = data['playURL'] if check_key(data, 'authorizeResult'): profile_settings = load_profile(profile_id=1) data['authorizeResult']['cookie'] = api_getCookies( load_file('stream_cookies'), '') license = data['authorizeResult'] playdata = { 'path': path, 'license': license, 'info': info, 'alt_path': alt_path, 'alt_license': alt_license } return playdata
def plugin_process_info(playdata): info = { 'label1': '', 'label2': '', 'description': '', 'image': '', 'image_large': '', 'duration': 0, 'credits': [], 'cast': [], 'director': [], 'writer': [], 'genres': [], 'year': '', } if playdata['info']: if check_key(playdata['info'], 'params'): if check_key(playdata['info']['params'], 'start') and check_key(playdata['info']['params'], 'end'): startT = datetime.datetime.fromtimestamp(time.mktime(time.strptime(playdata['info']['params']['start'], "%Y-%m-%dT%H:%M:%SZ"))) endT = datetime.datetime.fromtimestamp(time.mktime(time.strptime(playdata['info']['params']['end'], "%Y-%m-%dT%H:%M:%SZ"))) write_file(file='stream_start', data=int(time.mktime(time.strptime(playdata['info']['params']['start'], "%Y-%m-%dT%H:%M:%SZ"))), isJSON=False) write_file(file='stream_end', data=int(time.mktime(time.strptime(playdata['info']['params']['end'], "%Y-%m-%dT%H:%M:%SZ"))), isJSON=False) 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 playdata['title']: info['label1'] += playdata['title'] + ' - ' if check_key(playdata['info'], 'title'): info['label1'] += playdata['info']['title'] if check_key(playdata['info'], 'descriptiondescription'): info['description'] = playdata['info']['description'] if check_key(playdata['info'], 'images') and check_key(playdata['info']['images'][0], 'url'): info['image'] = playdata['info']['images'][0]['url'] info['image_large'] = playdata['info']['images'][0]['url'] if check_key(playdata['info'], 'params'): if check_key(playdata['info']['params'], 'credits'): for castmember in playdata['info']['params']['credits']: if castmember['role'] == "Actor": info['cast'].append(castmember['person']) elif castmember['role'] == "Director": info['director'].append(castmember['person']) elif castmember['role'] == "Writer": info['writer'].append(castmember['person']) if check_key(playdata['info']['params'], 'genres'): for genre in playdata['info']['params']['genres']: if check_key(genre, 'title'): info['genres'].append(genre['title']) if check_key(playdata['info']['params'], 'duration'): info['duration'] = playdata['info']['params']['duration'] epcode = '' if check_key(playdata['info']['params'], 'seriesSeason'): epcode += 'S' + str(playdata['info']['params']['seriesSeason']) if check_key(playdata['info']['params'], 'seriesEpisode'): epcode += 'E' + str(playdata['info']['params']['seriesEpisode']) if check_key(playdata['info']['params'], 'episodeTitle'): info['label2'] = playdata['info']['params']['episodeTitle'] if len(epcode) > 0: info['label2'] += " (" + epcode + ")" elif check_key(playdata['info'], 'title'): info['label2'] = playdata['info']['title'] if check_key(playdata['info']['params'], 'channelId'): data = api_get_channels() try: info['label2'] += " - " + data[str(playdata['info']['params']['channelId'])]['name'] except: pass return info
def api_get_info(id, channel=''): profile_settings = load_profile(profile_id=1) info = {} headers = { 'Content-Type': 'application/json', 'X_CSRFToken': profile_settings['csrf_token'] } militime = int(time.time() * 1000) data = api_get_channels() session_post_data = { 'needChannel': '0', 'queryChannel': { 'channelIDs': [ id, ], 'isReturnAllMedia': '1', }, 'queryPlaybill': { 'count': '1', 'endTime': militime, 'isFillProgram': '1', 'offset': '0', 'startTime': militime, 'type': '0', } } channel_url = '{base_url}/VSP/V3/QueryPlaybillListStcProps?SID=queryPlaybillListStcProps3&DEVICE=PC&DID={deviceID}&from=throughMSAAccess'.format( base_url=CONST_BASE_URL, deviceID=profile_settings['devicekey']) download = api_download(url=channel_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' or not check_key( data, 'channelPlaybills') or not check_key( data['channelPlaybills'][0], 'playbillLites') or not check_key( data['channelPlaybills'][0]['playbillLites'][0], 'ID'): return info id = data['channelPlaybills'][0]['playbillLites'][0]['ID'] session_post_data = { 'playbillID': id, 'channelNamespace': '310303', 'isReturnAllMedia': '1', } program_url = '{base_url}/VSP/V3/QueryPlaybill?from=throughMSAAccess'.format( base_url=CONST_BASE_URL) download = api_download(url=program_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' or not check_key( data, 'playbillDetail'): return info else: info = data['playbillDetail'] info = plugin_process_info({'title': '', 'channel': channel, 'info': info}) return info
def api_play_url(type, channel=None, id=None, video_data=None, from_beginning=0, pvr=0): playdata = { 'path': '', 'license': '', 'info': '', 'alt_path': '', 'alt_license': '' } if not api_get_session(): return playdata from_beginning = int(from_beginning) pvr = int(pvr) profile_settings = load_profile(profile_id=1) headers = { 'authorization': 'Bearer {id_token}'.format(id_token=profile_settings['access_token']) } alt_path = '' alt_license = '' found_alt = False friendly = '' info = {} data = api_get_channels() try: friendly = data[unicode(channel)]['assetid'] except: pass if not type == 'vod' and (pvr == 0 or settings.getBool( key='ask_start_from_beginning') or from_beginning == 1): if type == 'channel' and friendly: channel_url = '{base_url}/v6/epg/locations/{friendly}/live/1?fromDate={date}'.format( base_url=CONST_API_URL, 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 playdata for row in data: if not check_key(row, 'Channel') or not check_key( row, 'Locations'): return playdata for row2 in row['Locations']: id = row2['LocationId'] if not id: return playdata location_url = '{base_url}/v6/epg/location/{location}'.format( base_url=CONST_API_URL, location=id) download = api_download(url=location_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 playdata info = data timeshift = '' if check_key( info, 'VodContentId') and len(unicode(info['VodContentId'])) > 0: timeshift = info['VodContentId'] play_url = '{base_url}/v6/stream/handshake/Widevine/dash/VOD/{id}?playerName=NLZIET%20Meister%20Player%20Web&profile=default&maxResolution=×hift={timeshift}'.format( base_url=CONST_API_URL, id=info['VodContentId'], timeshift=timeshift) 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, 'uri'): pass else: alt_license = data alt_path = data['uri'] found_alt = True elif type == 'channel' and channel and friendly: timeshift = 'false' play_url = '{base_url}/v6/stream/handshake/Widevine/dash/Restart/{id}?playerName=NLZIET%20Meister%20Player%20Web&profile=default&maxResolution=×hift={timeshift}'.format( base_url=CONST_API_URL, id=id, timeshift=timeshift) 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, 'uri'): pass else: alt_license = data alt_path = data['uri'] found_alt = True if type == 'vod': play_url = '{base_url}/v6/playnow/ondemand/0/{location}'.format( base_url=CONST_API_URL, location=id) 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, 'VideoInformation'): return playdata info = data['VideoInformation'] url_base = '{base_url}/v6/stream/handshake/Widevine/dash/VOD/{id}'.format( base_url=CONST_API_URL, id=info['Id']) timeshift = info['Id'] elif type == 'channel' and channel and friendly: url_base = '{base_url}/v6/stream/handshake/Widevine/dash/Live/{friendly}'.format( base_url=CONST_API_URL, friendly=friendly) timeshift = 'false' else: if len(unicode(alt_path)) == 0: url_base = '{base_url}/v6/stream/handshake/Widevine/dash/Replay/{id}'.format( base_url=CONST_API_URL, id=id) timeshift = id else: license = alt_license = data path = alt_path alt_license = '' alt_path = '' if not type == 'program' or found_alt == False: play_url = '{url_base}?playerName=NLZIET%20Meister%20Player%20Web&profile=default&maxResolution=×hift={timeshift}'.format( url_base=url_base, timeshift=timeshift) 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, 'uri'): return playdata license = data path = data['uri'] if not len(unicode(license)) > 0: return playdata playdata = { 'path': path, 'license': license, 'info': info, 'alt_path': alt_path, 'alt_license': alt_license } return playdata
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(int(playdata['info']['startTime']) // 1000)) startT = convert_datetime_timezone(startT, "UTC", "UTC") endT = datetime.datetime.fromtimestamp( int(int(playdata['info']['endTime']) // 1000)) endT = convert_datetime_timezone(endT, "UTC", "UTC") write_file(file='stream_start', data=int(int(playdata['info']['startTime']) // 1000), isJSON=False) write_file(file='stream_end', data=int(int(playdata['info']['endTime']) // 1000), isJSON=False) 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[str(playdata['channel'])]['name'] except: pass return info
def process_replaytv_list(character, start=0): now = datetime.datetime.now(pytz.timezone("Europe/Amsterdam")) sevendays = datetime.datetime.now(pytz.timezone("Europe/Amsterdam")) - datetime.timedelta(days=7) nowstamp = int((now - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds()) sevendaysstamp = int((sevendays - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds()) data = api_get_channels() prefs = load_prefs(profile_id=1) channels_ar = [] if prefs: for row in prefs: currow = prefs[row] if not check_key(data, unicode(row)): continue if int(currow['replay']) == 1: channels_ar.append(row) data = api_get_list_by_first(first=character, start=nowstamp, end=sevendaysstamp, channels=channels_ar) start = int(start) items = [] count = 0 item_count = 0 if not data: return {'items': items, 'count': item_count, 'count2': count, 'total': 0} for currow in data: row = data[currow] if item_count == 51: break count += 1 if count < start + 1: continue item_count += 1 label = unicode(row['title']) idtitle = unicode(currow) icon = unicode(row['icon']) items.append(plugin.Item( label = label, info = { 'sorttitle': label.upper(), }, art = { 'thumb': icon, 'fanart': icon }, path = plugin.url_for(func_or_url=replaytv_item, label=label, idtitle=idtitle, start=0), )) returnar = {'items': items, 'count': item_count, 'count2': count, 'total': len(data)} return returnar
def disable_prefs_menu(type, **kwargs): disable_prefs(type=type, channels=api_get_channels()) xbmc.executeJSONRPC('{"jsonrpc":"2.0","id":1,"method":"GUI.ActivateWindow","params":{"window":"videos","parameters":["plugin://' + unicode(ADDON_ID) + '/?_=channel_picker_menu"]}}')
def process_replaytv_list_content(label, idtitle, start=0): start = int(start) now = datetime.datetime.now(pytz.timezone("Europe/Amsterdam")) sevendays = datetime.datetime.now(pytz.timezone("Europe/Amsterdam")) - datetime.timedelta(days=7) nowstamp = int((now - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds()) sevendaysstamp = int((sevendays - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds()) data = api_get_channels() prefs = load_prefs(profile_id=1) channels_ar = [] channels_ar2 = {} if prefs: for row in prefs: currow = prefs[row] if not check_key(data, unicode(row)): continue channels_ar2[unicode(row)] = data[unicode(row)]['name'] if int(currow['replay']) == 1: channels_ar.append(row) data = api_get_epg_by_idtitle(idtitle=idtitle, start=nowstamp, end=sevendaysstamp, channels=channels_ar) items = [] count = 0 item_count = 0 if not data: return {'items': items, 'count': item_count, 'count2': count, 'total': 0} for currow in data: row = data[currow] if item_count == 51: break count += 1 if count < start + 1: continue context = [] item_count += 1 channel = unicode(row['channel']) startT = datetime.datetime.fromtimestamp(int(row['start'])) startT = convert_datetime_timezone(startT, "Europe/Amsterdam", "Europe/Amsterdam") endT = datetime.datetime.fromtimestamp(int(row['end'])) endT = convert_datetime_timezone(endT, "Europe/Amsterdam", "Europe/Amsterdam") if xbmc.getLanguage(xbmc.ISO_639_1) == 'nl': itemlabel = '{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: itemlabel = startT.strftime("%A %d %B %Y %H:%M ").capitalize() itemlabel += unicode(row['title']) try: itemlabel += " (" + unicode(channels_ar2[channel]) + ")" except: pass description = unicode(row['description']) duration = int((endT - startT).total_seconds()) program_image = unicode(row['icon']) program_image_large = unicode(row['icon']) program_id = unicode(row['program_id']) if CONST_WATCHLIST: context.append((_.ADD_TO_WATCHLIST, 'RunPlugin({context_url})'.format(context_url=plugin.url_for(func_or_url=add_to_watchlist, id=program_id, type='item')), )) items.append(plugin.Item( label = itemlabel, info = { 'plot': description, 'duration': duration, 'mediatype': 'video', 'sorttitle': itemlabel.upper(), }, art = { 'thumb': program_image, 'fanart': program_image_large }, path = plugin.url_for(func_or_url=play_video, type='program', channel=channel, id=program_id), playable = True, context = context )) returnar = {'items': items, 'count': item_count, 'count2': count, 'total': len(data)} return returnar
def api_play_url(type, channel=None, id=None, video_data=None, from_beginning=0, pvr=0, change_audio=0): playdata = {'path': '', 'license': '', '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) headers = { 'authorization': 'Bearer {id_token}'.format(id_token=profile_settings['access_token']) } friendly = '' info = {} properties = {} data = api_get_channels() try: friendly = data[str(channel)]['assetid'] except: pass if type == 'channel' and friendly: 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 playdata for row in data: if not check_key(row, 'Channel') or not check_key( row, 'Locations'): return playdata for row2 in row['Locations']: id = row2['LocationId'] elif not type == 'vod': detail_url = '{base_url}/v7/content/detail/{id}'.format( base_url=CONST_URLS['api'], id=id) download = api_download(url=detail_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: if check_key(data, 'assets'): if check_key(data['assets'], 'epg') and check_key( data['assets']['epg'][0], 'locationId'): id = data['assets']['epg'][0]['locationId'] if not id: return playdata if type == 'vod': url_base = '{base_url}/v7/stream/handshake/Widevine/dash/VOD/{id}'.format( base_url=CONST_URLS['api'], id=id) elif type == 'channel' and channel and friendly: url_base = '{base_url}/v7/stream/handshake/Widevine/dash/Live/{id}'.format( base_url=CONST_URLS['api'], id=id) else: url_base = '{base_url}/v7/stream/handshake/Widevine/dash/Replay/{id}'.format( base_url=CONST_URLS['api'], id=id) play_url = '{url_base}?playerName=BitmovinWeb'.format(url_base=url_base) 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, 'uri'): return playdata license = data path = data['uri'] if not type == 'vod' and (pvr == 0): 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=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: return playdata info = data if not len(str(license)) > 0: return playdata mpd = '' if change_audio == 1: download = api_download(url=path, type='get', headers=headers, data=None, json_data=False, return_json=False) data = download['data'] code = download['code'] if code and code == 200: mpd = data playdata = { 'path': path, 'mpd': mpd, 'license': license, 'info': info, 'properties': properties } return playdata