def plugin_process_vod_season(series, id, data): season = [] if not data or not check_key(data, 'mediaItems'): return None data['mediaItems'] = list(data['mediaItems']) for row in data['mediaItems']: desc = '' image = '' label = '' if not check_key(row, 'title') or not check_key(row, 'id'): continue if check_key(row, 'description'): desc = row['description'] if check_key(row, 'duration'): duration = int(row['duration']) if check_key(row, 'images'): program_image = get_image("boxart", row['images']) image = get_image("HighResLandscape", row['images']) if image == '': image = program_image else: image += '?w=1920&mode=box' if check_key(row, 'earliestBroadcastStartTime'): startsplit = int(row['earliestBroadcastStartTime']) // 1000 startT = datetime.datetime.fromtimestamp(startsplit) startT = convert_datetime_timezone(startT, "UTC", "UTC") if xbmc.getLanguage(xbmc.ISO_639_1) == 'nl': label = date_to_nl_dag(startT) + startT.strftime( " %d ") + date_to_nl_maand(startT) + startT.strftime( " %Y %H:%M ") + row['title'] else: label = (startT.strftime("%A %d %B %Y %H:%M ") + row['title']).capitalize() else: label = row['title'] season.append({ 'label': label, 'id': row['id'], 'start': '', 'duration': duration, 'title': row['title'], 'seasonNumber': '', 'episodeNumber': '', 'description': desc, 'image': image }) return season
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 plugin_process_info(playdata): info = { 'label1': '', 'label2': '', 'description': '', 'image': '', 'image_large': '', 'duration': 0, 'credits': [], 'cast': [], 'director': [], 'writer': [], 'genres': [], 'year': '', } if check_key(playdata['info'], 'Start') and check_key( playdata['info'], 'End'): startT = datetime.datetime.fromtimestamp( time.mktime( time.strptime(playdata['info']['Start'], "%Y-%m-%dT%H:%M:%S"))) startT = convert_datetime_timezone(startT, "UTC", "UTC") endT = datetime.datetime.fromtimestamp( time.mktime( time.strptime(playdata['info']['End'], "%Y-%m-%dT%H:%M:%S"))) endT = convert_datetime_timezone(endT, "UTC", "UTC") write_file(file='stream_start', data=int( time.mktime( time.strptime(playdata['info']['Start'], "%Y-%m-%dT%H:%M:%S"))), isJSON=False) write_file(file='stream_end', data=int( time.mktime( time.strptime(playdata['info']['End'], "%Y-%m-%dT%H:%M:%S"))), isJSON=False) if check_key(playdata['info'], 'DurationInSeconds'): info['duration'] = playdata['info']['DurationInSeconds'] elif check_key(playdata['info'], 'Duur'): info['duration'] = playdata['info']['Duur'] else: 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() if check_key(playdata['info'], 'Duur'): info['duration'] = playdata['info']['Duur'] if check_key(playdata['info'], 'Title'): if len(str(info['label1'])) > 0: info['label1'] += " - " if len(str(info['label2'])) > 0: info['label2'] += " - " info['label1'] += playdata['info']['Title'] info['label2'] += playdata['info']['Title'] elif check_key(playdata['info'], 'Serie') and check_key( playdata['info']['Serie'], 'Titel') and len( playdata['info']['Serie']['Titel']): if len(str(info['label1'])) > 0: info['label1'] += " - " if len(str(info['label2'])) > 0: info['label2'] += " - " info['label1'] += playdata['info']['Serie']['Titel'] info['label2'] += playdata['info']['Serie']['Titel'] if check_key( playdata['info'], 'Titel') and len(playdata['info']['Titel']) > 0 and playdata[ 'info']['Titel'] != playdata['info']['Serie']['Titel']: if len(str(info['label1'])) > 0: info['label1'] += ": " if len(str(info['label2'])) > 0: info['label2'] += ": " info['label1'] += playdata['info']['Titel'] info['label2'] += playdata['info']['Titel'] if check_key(playdata['info'], 'LongDescription'): info['description'] = playdata['info']['LongDescription'] elif check_key(playdata['info'], 'Omschrijving'): info['description'] = playdata['info']['Omschrijving'] if check_key(playdata['info'], 'CoverUrl'): info['image'] = playdata['info']['CoverUrl'] info['image_large'] = playdata['info']['CoverUrl'] elif check_key(playdata['info'], 'AfbeeldingUrl'): info['image'] = playdata['info']['AfbeeldingUrl'] info['image_large'] = playdata['info']['AfbeeldingUrl'] if check_key(playdata['info'], 'ChannelTitle'): if len(str(info['label2'])) > 0: info['label2'] += " - " info['label2'] += playdata['info']['ChannelTitle'] elif check_key(playdata['info'], 'Zender'): if len(str(info['label2'])) > 0: info['label2'] += " - " info['label2'] += playdata['info']['Zender'] return info
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 plugin_process_info(playdata): info = { 'label1': '', 'label2': '', 'description': '', 'image': '', 'image_large': '', 'duration': 0, 'credits': [], 'cast': [], 'director': [], 'writer': [], 'genres': [], 'year': '', } if playdata['info'] and check_key(playdata['info'], 'resultObj'): for row in playdata['info']['resultObj']['containers']: if check_key(row, 'metadata'): if check_key(row['metadata'], 'airingStartTime') and check_key( row['metadata'], 'airingEndTime'): startT = datetime.datetime.fromtimestamp( int(int(row['metadata']['airingStartTime']) // 1000)) startT = convert_datetime_timezone(startT, "UTC", "UTC") endT = datetime.datetime.fromtimestamp( int(int(row['metadata']['airingEndTime']) // 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'] += " - " write_file(file='stream_start', data=int( int(row['metadata']['airingStartTime']) // 1000), isJSON=False) write_file(file='stream_end', data=int( int(row['metadata']['airingEndTime']) // 1000), isJSON=False) if check_key(playdata, 'title') and len(str(playdata['title'])) > 0: info['label1'] += playdata['title'] if len(str(info['label2'])) > 0: info['label2'] += " - " info['label2'] += playdata['title'] if check_key( row['metadata'], 'title') and len(str(row['metadata']['title'])) > 0: info['label1'] += row['metadata']['title'] if len(str(info['label2'])) > 0: info['label2'] += " - " info['label2'] += row['metadata']['title'] if check_key(row['metadata'], 'longDescription'): info['description'] = row['metadata']['longDescription'] if check_key(row['metadata'], 'pictureUrl'): info[ 'image'] = "{image_url}/{image}?w=1920&h=1080&q=HI&o=L".format( image_url=CONST_URLS['image'], image=row['metadata']['pictureUrl']) info[ 'image_large'] = "{image_url}/{image}?w=1920&h=1080&q=HI&o=L".format( image_url=CONST_URLS['image'], image=row['metadata']['pictureUrl']) if check_key(row['metadata'], 'actors'): for castmember in row['metadata']['actors']: info['cast'].append(castmember) if check_key(row['metadata'], 'directors'): for directormember in row['metadata']['directors']: info['director'].append(directormember) if check_key(row['metadata'], 'authors'): for writermember in row['metadata']['authors']: info['writer'].append(writermember) if check_key(row['metadata'], 'genres'): for genre in row['metadata']['genres']: info['genres'].append(genre) if check_key(row['metadata'], 'duration'): info['duration'] = row['metadata']['duration'] if check_key(row['metadata'], 'objectSubtype'): info['type'] = row['metadata']['objectSubtype'] epcode = '' if check_key(row['metadata'], 'season'): epcode += 'S' + str(row['metadata']['season']) if check_key(row['metadata'], 'episodeNumber'): epcode += 'E' + str(row['metadata']['episodeNumber']) if check_key(row['metadata'], 'episodeTitle'): if len(str(info['label2'])) > 0: info['label2'] += " - " info['label2'] += str(row['metadata']['episodeTitle']) if len(epcode) > 0: info['label2'] += " (" + epcode + ")" if check_key(row, 'channel'): if check_key(row['channel'], 'channelName'): if len(str(info['label2'])) > 0: info['label2'] += " - " info['label2'] += str(row['channel']['channelName']) return info
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 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"))) 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']: 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' + unicode( playdata['info']['params']['seriesSeason']) if check_key(playdata['info']['params'], 'seriesEpisode'): epcode += 'E' + unicode( 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'): query = "SELECT name FROM `channels` WHERE id='{channel}'".format( channel=playdata['info']['params']['channelId']) data = query_epg(query=query, return_result=True, return_insert=False, commit=False) if data: for row in data: info['label2'] += " - " + row['name'] return info
def api_vod_season(series, id): if not api_get_session(): return None season = [] program_url = '{base_url}/v6/series/{series}/seizoenItems?seizoenId={id}&count=99999999&expand=true&expandlist=true&maxResults=99999999&offset=0'.format( base_url=CONST_API_URL, series=series, id=id) type = "vod_series_" + unicode(series) + "_season_" + 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: write_file(file=file, data=data, isJSON=True) if not data: return None for row in data: duration = 0 ep_id = '' desc = '' image = '' label = '' if check_key(row, 'AfleveringTitel') and len(row['AfleveringTitel']) > 0: episodeTitle = row['AfleveringTitel'] else: episodeTitle = row['ProgrammaTitel'] if check_key(row, 'Duur'): duration = row['Duur'] if check_key(row, 'ContentId'): ep_id = row['ContentId'] if check_key(row, 'ProgrammaOmschrijving'): desc = row['ProgrammaOmschrijving'] if check_key(row, 'ProgrammaAfbeelding'): image = row['ProgrammaAfbeelding'] if not 'http' in image: image_split = image.rsplit('/', 1) if len(image_split) == 2: image = '{image_url}/thumbnails/hd1080/{image}'.format( image_url=CONST_IMAGE_URL, image=image.rsplit('/', 1)[1]) else: image = '{image_url}/{image}'.format( image_url=CONST_IMAGE_URL, image=image) if check_key(row, 'Uitzenddatum'): start = row['Uitzenddatum'] startT = datetime.datetime.fromtimestamp( time.mktime(time.strptime(start, "%Y-%m-%dT%H:%M:%S"))) startT = convert_datetime_timezone(startT, "UTC", "UTC") 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() if check_key(row, 'SeizoenVolgnummer'): label += unicode(row['SeizoenVolgnummer']) if check_key(row, 'AfleveringVolgnummer'): if len(label) > 0: label += "." label += unicode(row['AfleveringVolgnummer']) if len(label) > 0: label += " - " label += episodeTitle season.append({ 'label': label, 'id': ep_id, 'start': start, 'duration': duration, 'title': episodeTitle, 'seasonNumber': row['SeizoenVolgnummer'], 'episodeNumber': row['AfleveringVolgnummer'], 'description': desc, 'image': image }) season[:] = sorted(season, key=api_sort_episodes) return season
def plugin_process_info(playdata): info = { 'label1': '', 'label2': '', 'description': '', 'image': '', 'image_large': '', 'duration': 0, 'credits': [], 'cast': [], 'director': [], 'writer': [], 'genres': [], 'year': '', } if playdata['info'] and check_key(playdata['info'], 'resultObj'): for row in playdata['info']['resultObj']['containers']: if check_key(row, 'metadata'): if check_key(row['metadata'], 'airingStartTime') and check_key( row['metadata'], 'airingEndTime'): startT = datetime.datetime.fromtimestamp( int(int(row['metadata']['airingStartTime']) / 1000)) startT = convert_datetime_timezone(startT, "UTC", "UTC") endT = datetime.datetime.fromtimestamp( int(int(row['metadata']['airingEndTime']) / 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 playdata['title']: info['label1'] += playdata['title'] + ' - ' if check_key(row['metadata'], 'title'): info['label1'] += row['metadata']['title'] if check_key(row['metadata'], 'longDescription'): info['description'] = row['metadata']['longDescription'] if playdata['type'] == 'VOD': imgtype = 'vod' else: imgtype = 'epg' if check_key(row['metadata'], 'pictureUrl'): info[ 'image'] = "{image_url}/{imgtype}/{image}/1920x1080.jpg?blurred=false".format( image_url=CONST_IMAGE_URL, imgtype=imgtype, image=row['metadata']['pictureUrl']) info[ 'image_large'] = "{image_url}/{imgtype}/{image}/1920x1080.jpg?blurred=false".format( image_url=CONST_IMAGE_URL, imgtype=imgtype, image=row['metadata']['pictureUrl']) if check_key(row['metadata'], 'actors'): for castmember in row['metadata']['actors']: info['cast'].append(castmember) if check_key(row['metadata'], 'directors'): for directormember in row['metadata']['directors']: info['director'].append(directormember) if check_key(row['metadata'], 'authors'): for writermember in row['metadata']['authors']: info['writer'].append(writermember) if check_key(row['metadata'], 'genres'): for genre in row['metadata']['genres']: info['genres'].append(genre) if check_key(row['metadata'], 'duration'): info['duration'] = row['metadata']['duration'] epcode = '' if check_key(row['metadata'], 'season'): epcode += 'S' + unicode(row['metadata']['season']) if check_key(row['metadata'], 'episodeNumber'): epcode += 'E' + unicode(row['metadata']['episodeNumber']) if check_key(row['metadata'], 'episodeTitle'): info['label2'] = row['metadata']['episodeTitle'] if len(epcode) > 0: info['label2'] += " (" + epcode + ")" elif check_key(row['metadata'], 'title'): info['label2'] = row['metadata']['title'] if check_key(row, 'channel'): if check_key(row['channel'], 'channelName'): info['label2'] += " - " + row['channel']['channelName'] else: nowstamp = int(time.time()) query = "SELECT a.*, b.name FROM `epg` as a JOIN `channels` as b ON a.channel=b.id WHERE a.channel='{channel}' AND a.start < {nowstamp} AND a.end > {nowstamp}".format( channel=playdata['channel'], nowstamp=nowstamp) data = query_epg(query=query, return_result=True, return_insert=False, commit=False) for row in data: startT = datetime.datetime.fromtimestamp(int(row['start'])) startT = convert_datetime_timezone(startT, "UTC", "UTC") endT = datetime.datetime.fromtimestamp(int(row['end'])) 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 playdata['title']: info['label1'] += playdata['title'] + ' - ' info['label1'] += row['title'] info['description'] = row['description'] info['image'] = row['icon'] info['image_large'] = row['icon'] info['label2'] = row['title'] info['label2'] += " - " + row['name'] return info
def api_get_info(id, channel=''): profile_settings = load_profile(profile_id=1) info = {} militime = int(time.time() * 1000) program_id = None program_url = '{api_url}/TRAY/SEARCH/PROGRAM?maxResults=1&filter_airingEndTime=now&filter_channelIds={channel}'.format( api_url=CONST_URLS['api'], channel=id) 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'): for row in data['resultObj']['containers']: program_id = row['id'] if not program_id: return info info_url = '{api_url}/CONTENT/DETAIL/PROGRAM/{id}'.format( api_url=CONST_URLS['api'], id=program_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 info info = data playdata = {'title': '', 'channel': channel, 'info': info} info = { 'label1': '', 'label2': '', 'description': '', 'image': '', 'image_large': '', 'duration': 0, 'credits': [], 'cast': [], 'director': [], 'writer': [], 'genres': [], 'year': '', } if playdata['info'] and check_key(playdata['info'], 'resultObj'): for row in playdata['info']['resultObj']['containers']: if check_key(row, 'metadata'): if check_key(row['metadata'], 'airingStartTime') and check_key( row['metadata'], 'airingEndTime'): startT = datetime.datetime.fromtimestamp( int(int(row['metadata']['airingStartTime']) // 1000)) startT = convert_datetime_timezone(startT, "UTC", "UTC") endT = datetime.datetime.fromtimestamp( int(int(row['metadata']['airingEndTime']) // 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'] += " - " write_file(file='stream_start', data=int( int(row['metadata']['airingStartTime']) // 1000), isJSON=False) write_file(file='stream_end', data=int( int(row['metadata']['airingEndTime']) // 1000), isJSON=False) if check_key(playdata, 'title') and len(str(playdata['title'])) > 0: info['label1'] += playdata['title'] if len(str(info['label2'])) > 0: info['label2'] += " - " info['label2'] += playdata['title'] if check_key( row['metadata'], 'title') and len(str(row['metadata']['title'])) > 0: info['label1'] += row['metadata']['title'] if len(str(info['label2'])) > 0: info['label2'] += " - " info['label2'] += row['metadata']['title'] if check_key(row['metadata'], 'longDescription'): info['description'] = row['metadata']['longDescription'] if check_key(row['metadata'], 'pictureUrl'): info[ 'image'] = "{image_url}/epg/{image}/1920x1080.jpg?blurred=false".format( image_url=CONST_URLS['image'], image=row['metadata']['pictureUrl']) info[ 'image_large'] = "{image_url}/epg/{image}/1920x1080.jpg?blurred=false".format( image_url=CONST_URLS['image'], image=row['metadata']['pictureUrl']) if check_key(row['metadata'], 'actors'): for castmember in row['metadata']['actors']: info['cast'].append(castmember) if check_key(row['metadata'], 'directors'): for directormember in row['metadata']['directors']: info['director'].append(directormember) if check_key(row['metadata'], 'authors'): for writermember in row['metadata']['authors']: info['writer'].append(writermember) if check_key(row['metadata'], 'genres'): for genre in row['metadata']['genres']: info['genres'].append(genre) if check_key(row['metadata'], 'duration'): info['duration'] = row['metadata']['duration'] epcode = '' if check_key(row['metadata'], 'season'): epcode += 'S' + str(row['metadata']['season']) if check_key(row['metadata'], 'episodeNumber'): epcode += 'E' + str(row['metadata']['episodeNumber']) if check_key(row['metadata'], 'episodeTitle'): if len(str(info['label2'])) > 0: info['label2'] += " - " info['label2'] += str(row['metadata']['episodeTitle']) if len(epcode) > 0: info['label2'] += " (" + epcode + ")" if check_key(row, 'channel'): if check_key(row['channel'], 'channelName'): if len(str(info['label2'])) > 0: info['label2'] += " - " info['label2'] += str(row['channel']['channelName']) return info
def replaytv_by_day(label='', image='', description='', station='', **kwargs): folder = plugin.Folder(title=label) for x in range(0, 7): curdate = datetime.date.today() - datetime.timedelta(days=x) itemlabel = '' if x == 0: itemlabel = _.TODAY + " - " elif x == 1: itemlabel = _.YESTERDAY + " - " if xbmc.getLanguage(xbmc.ISO_639_1) == 'nl': itemlabel += date_to_nl_dag(curdate=curdate) + curdate.strftime(" %d ") + date_to_nl_maand(curdate=curdate) + curdate.strftime(" %Y") else: itemlabel += curdate.strftime("%A %d %B %Y").capitalize() folder.add_item( label = itemlabel, info = {'plot': description}, art = {'thumb': image}, path = plugin.url_for(func_or_url=replaytv_content, label=itemlabel, day=x, station=station), ) return folder
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 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] query = "SELECT name FROM `channels` WHERE id='{channel}'".format( channel=playdata['channel']) data = query_epg(query=query, return_result=True, return_insert=False, commit=False) if data: for row in data: info['label2'] += " - " + row['name'] return info