def radio_select(num, **kwargs): num = int(num) profile_settings = load_profile(profile_id=1) for x in range(num, 6): profile_settings['addon' + unicode(x)] = '' save_profile(profile_id=1, profile=profile_settings) folder = plugin.Folder(title=_.ADD_RADIO) desc = _.ADD_RADIO_DESC folder.add_item(label=_.YES, info={'plot': desc}, path=plugin.url_for(func_or_url=channel_picker_menu, type_tv_radio='live', save_all=1, radio=1)) folder.add_item(label=_.NO, info={'plot': desc}, path=plugin.url_for(func_or_url=channel_picker_menu, type_tv_radio='live', save_all=1, radio=0)) return folder
def radio_order_picker_menu(double=None, primary=None, **kwargs): save_all_radio_order(double=double, primary=primary) folder = plugin.Folder(title=_.SELECT_ORDER) desc2 = _.NEXT_SETUP_IPTV folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) prefs = load_radio_prefs(profile_id=1) order = load_radio_order(profile_id=1) if order: for currow in order: row = prefs[currow] if int(row['radio']) == 0: continue label = _(row['name'] + ": " + unicode(order[unicode(currow)]), _bold=True) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_radio_order, id=currow), playable=False, ) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) return folder
def alternative(num, addon, addons, **kwargs): num = int(num) profile_settings = load_profile(profile_id=1) profile_settings['addon' + unicode(num)] = addon save_profile(profile_id=1, profile=profile_settings) folder = plugin.Folder(title=_.SELECT_SECONDARY) addons = json.loads(addons) addons2 = [] desc = _.SELECT_SECONDARY_DESC for entry in addons: if not entry['addonid'] == addon: addons2.append(entry) for entry in addons2: folder.add_item(label=_(entry['label'], _bold=True), info={'plot': desc}, path=plugin.url_for(func_or_url=alternative, num=num + 1, addon=entry['addonid'], addons=json.dumps(addons2))) folder.add_item(label=_.DONE, info={'plot': desc}, path=plugin.url_for(func_or_url=radio_select, num=num + 1)) return folder
def primary(addons, **kwargs): folder = plugin.Folder(title=_.SELECT_PRIMARY) addons = json.loads(addons) desc = _.SELECT_PRIMARY_DESC desc2 = _.SKIP_DESC for entry in addons: folder.add_item(label=_(entry['label'], _bold=True), info={'plot': desc}, path=plugin.url_for(func_or_url=alternative, num=1, addon=entry['addonid'], addons=json.dumps(addons))) profile_settings = load_profile(profile_id=1) try: if len(profile_settings['addon1']) > 0: folder.add_item(label=_(_.SKIP, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=radio_select, num=6)) except: pass return folder
def simple_iptv_menu(**kwargs): folder = plugin.Folder(title=_.SETUP_IPTV) desc = _.SETUP_IPTV_FINISH_DESC desc2 = _.SKIP_IPTV_FINISH_DESC folder.add_item(label=_(_.SETUP_IPTV_FINISH, _bold=True), info={'plot': desc}, path=plugin.url_for(func_or_url=finish_setup, setup=1)) folder.add_item(label=_(_.SKIP_IPTV_FINISH, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=finish_setup, setup=0)) return folder
def live_channel_picker_menu(save_all=0, radio=None, **kwargs): save_all = int(save_all) if not radio == None: radio = int(radio) profile_settings = load_profile(profile_id=1) profile_settings['radio'] = radio save_profile(profile_id=1, profile=profile_settings) if save_all == 1: save_all_live_prefs() folder = plugin.Folder(title=_.SELECT_LIVE) desc2 = _.NEXT_SETUP_REPLAY folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=replay_channel_picker_menu, save_all=1)) prefs = load_prefs(profile_id=1) if prefs: for currow in prefs: row = prefs[currow] if row['live'] == 1: color = 'green' addon_type = row['live_addonid'].replace('plugin.video.', '') else: color = 'red' addon_type = _.DISABLED label = _(row['name'] + ": " + addon_type, _bold=True, _color=color) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_live_channel, id=currow), playable=False, ) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=replay_channel_picker_menu, save_all=1)) return folder
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 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 channel_picker(type, **kwargs): if type=='live': title = _.LIVE_TV rows = get_live_channels(all=True) elif type=='replay': title = _.CHANNELS rows = get_replay_channels(all=True) folder = plugin.Folder(title=title) prefs = load_prefs(profile_id=1) type = unicode(type) for row in rows: id = unicode(row['channel']) if not prefs or not check_key(prefs, id) or prefs[id][type] == 1: color = 'green' else: color = 'red' label = _(unicode(row['label']), _bold=True, _color=color) folder.add_item( label = label, art = {'thumb': unicode(row['image'])}, path = plugin.url_for(func_or_url=change_channel, type=type, id=id, change=0), playable = False, ) return folder
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 get_replay_channels(all=False): channels = [] data = api_get_channels() prefs = load_prefs(profile_id=1) if data: for currow in data: row = data[currow] id = unicode(row['id']) if all or not prefs or not check_key(prefs, id) or int(prefs[id]['replay']) == 1: channels.append({ 'label': unicode(row['name']), 'channel': id, 'chno': unicode(row['channelno']), 'description': unicode(row['description']), 'image': unicode(row['icon']), 'path': plugin.url_for(func_or_url=replaytv_by_day, image=unicode(row['icon']), description=unicode(row['description']), label=unicode(row['name']), station=id), 'playable': False, 'context': [], }) return channels
def get_live_channels(all=False): global backend channels = [] data = api_get_channels() prefs = load_prefs(profile_id=1) if data: for currow in data: row = data[currow] path = plugin.url_for(func_or_url=play_video, type='channel', channel=row['id'], id=row['assetid'], _is_live=True) playable = True id = unicode(row['id']) if all or not prefs or not check_key(prefs, id) or prefs[id]['live'] == 1: channels.append({ 'label': unicode(row['name']), 'channel': id, 'chno': unicode(row['channelno']), 'description': unicode(row['description']), 'image': unicode(row['icon']), 'path': path, 'playable': playable, 'context': [ (_.START_BEGINNING, 'RunPlugin({context_url})'.format(context_url=plugin.url_for(func_or_url=play_video, type='channel', channel=id, id=unicode(row['assetid']), from_beginning=1, _is_live=True)), ), ], }) return channels
def vod_season(label, series, id, **kwargs): folder = plugin.Folder(title=label) items = [] season = api_vod_season(series=series, id=id) for episode in season: 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']), data=json.dumps(episode)), playable = True, )) folder.add_items(items) return folder
def process_replaytv_search(search): 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()) search = unicode(search) 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(start=nowstamp, end=sevendaysstamp, channels=channels_ar) items = [] if not data: return {'items': items} for currow in data: row = data[currow] title = unicode(row['title']) icon = unicode(row['icon']) fuzz_set = fuzz.token_set_ratio(title, search) fuzz_partial = fuzz.partial_ratio(title, search) fuzz_sort = fuzz.token_sort_ratio(title, search) if (fuzz_set + fuzz_partial + fuzz_sort) > 160: label = title + ' (ReplayTV)' idtitle = unicode(currow) items.append(plugin.Item( label = label, info = { 'sorttitle': label.upper(), }, art = { 'thumb': icon, 'fanart': icon }, properties = {"fuzz_set": fuzz_set, "fuzz_sort": fuzz_sort, "fuzz_partial": fuzz_partial, "fuzz_total": fuzz_set + fuzz_partial + fuzz_sort}, path = plugin.url_for(func_or_url=replaytv_item, label=label, idtitle=idtitle, start=0), )) returnar = {'items': items} return returnar
def home(**kwargs): clear_old() check_first() profile_settings = load_profile(profile_id=1) folder = plugin.Folder() if profile_settings and check_key(profile_settings, 'pswd') and len(profile_settings['pswd']) > 0: folder.add_item(label=_(_.LIVE_TV, _bold=True), path=plugin.url_for(func_or_url=live_tv)) folder.add_item(label=_(_.CHANNELS, _bold=True), path=plugin.url_for(func_or_url=replaytv)) if settings.getBool('showMoviesSeries'): for vod_entry in CONST_VOD_CAPABILITY: folder.add_item(label=_(vod_entry['label'], _bold=True), path=plugin.url_for(func_or_url=vod, file=vod_entry['file'], label=vod_entry['label'], start=vod_entry['start'], online=vod_entry['online'], split=vod_entry['split'])) if CONST_WATCHLIST: folder.add_item(label=_(_.WATCHLIST, _bold=True), path=plugin.url_for(func_or_url=watchlist)) folder.add_item(label=_(_.SEARCH, _bold=True), path=plugin.url_for(func_or_url=search_menu)) folder.add_item(label=_(_.LOGIN, _bold=True), path=plugin.url_for(func_or_url=login)) folder.add_item(label=_.SETTINGS, path=plugin.url_for(func_or_url=settings_menu)) return folder
def order_picker_menu(type_tv_radio, double=None, primary=None, **kwargs): type_tv_radio = str(type_tv_radio) save_all_order(type_tv_radio=type_tv_radio, double=double, primary=primary) folder = plugin.Folder(title=_.SELECT_ORDER) desc2 = _.NEXT_SETUP_GROUPS folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=group_picker_menu, type_tv_radio=type_tv_radio)) if type_tv_radio == 'live': prefs = load_prefs(profile_id=1) order = load_order(profile_id=1) else: prefs = load_radio_prefs(profile_id=1) order = load_radio_order(profile_id=1) if order: for currow in order: row = prefs[currow] if int(row[type_tv_radio]) == 0: continue label = _(row['name'] + ": " + str(order[str(currow)]), _bold=True) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_order, id=currow, type_tv_radio=type_tv_radio), playable=False, ) desc2 = _.NEXT_SETUP_GROUPS folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=group_picker_menu, type_tv_radio=type_tv_radio)) return folder
def replay_channel_picker_menu(save_all=0, **kwargs): save_all = int(save_all) if save_all == 1: save_all_replay_prefs() folder = plugin.Folder(title=_.SELECT_REPLAY) desc2 = _.NEXT_SETUP_ORDER folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=tv_order_picker_menu)) prefs = load_prefs(profile_id=1) if prefs: for currow in prefs: row = prefs[currow] if row['replay'] == 1: color = 'green' addon_type = row['replay_addonid'].replace('plugin.video.', '') else: color = 'red' addon_type = _.DISABLED label = _(row['name'] + ": " + addon_type, _bold=True, _color=color) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_replay_channel, id=currow), playable=False, ) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=tv_order_picker_menu)) return folder
def replaytv_alphabetical(**kwargs): folder = plugin.Folder(title=_.PROGSAZ) label = _.OTHERTITLES folder.add_item( label = label, info = {'plot': _.OTHERTITLESDESC}, path = plugin.url_for(func_or_url=replaytv_list, label=label, start=0, character='other'), ) for character in string.ascii_uppercase: label = _.TITLESWITH + character folder.add_item( label = label, info = {'plot': _.TITLESWITHDESC + character}, path = plugin.url_for(func_or_url=replaytv_list, label=label, start=0, character=character), ) return folder
def vod(file, label, start=0, character=None, online=0, split=0, **kwargs): start = int(start) online = int(online) split = int(split) if split == 1: folder = plugin.Folder(title=_.PROGSAZ) label = _.OTHERTITLES folder.add_item( label = label, info = {'plot': _.OTHERTITLESDESC}, path = plugin.url_for(func_or_url=vod, file=file, label=label, start=start, character='other', online=online, split=0), ) for character in string.ascii_uppercase: label = _.TITLESWITH + character folder.add_item( label = label, info = {'plot': _.TITLESWITHDESC + character}, path = plugin.url_for(func_or_url=vod, file=file, label=label, start=start, character=character, online=online, split=0), ) return folder else: folder = plugin.Folder(title=label) processed = process_vod_content(data=file, start=start, type=label, character=character, online=online) if check_key(processed, 'items'): folder.add_items(processed['items']) if check_key(processed, 'total') and check_key(processed, 'count2') and processed['total'] > processed['count2']: folder.add_item( label = _(_.NEXT_PAGE, _bold=True), properties = {'SpecialSort': 'bottom'}, path = plugin.url_for(func_or_url=vod, file=file, label=label, start=processed['count2'], character=character, online=online, split=split), ) return folder
def radio_channel_picker_menu(save_all=0, **kwargs): save_all = int(save_all) if save_all == 1: save_all_radio_prefs() folder = plugin.Folder(title=_.SELECT_RADIO) desc2 = _.NEXT_SETUP_ORDER folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=radio_order_picker_menu)) prefs = load_radio_prefs(profile_id=1) if prefs: for currow in prefs: row = prefs[currow] if row['radio'] == 1: color = 'green' else: color = 'red' label = _(row['name'], _bold=True, _color=color) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_radio_channel, id=currow), playable=False, ) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=radio_order_picker_menu)) return folder
def home(**kwargs): api_get_channels() folder = plugin.Folder(title='Installed Addons') installed = False loggedin = False addons = [] desc = _.ADDON_NOT_INSTALLED_DESC desc2 = _.NO_ADDONS_ENABLED_DESC desc3 = _.RESET_SETTINGS_DESC desc4 = _.ADDON_NOT_LOGGEDIN_DESC desc5 = _.ADDON_ENABLED_DESC desc6 = _.ADDONS_CONTINUE_DESC for entry in CONST_ADDONS: if check_addon(addon=entry['addonid']): if check_loggedin(addon=entry['addonid']): color = 'green' loggedin = True addons.append(entry) folder.add_item(label=_(entry['label'], _bold=True, _color=color), info={'plot': desc5}, path=plugin.url_for(func_or_url=home)) else: color = 'orange' folder.add_item(label=_(entry['label'], _bold=True, _color=color), info={'plot': desc4}, path=plugin.url_for(func_or_url=home)) installed = True else: color = 'red' folder.add_item(label=_(entry['label'], _bold=True, _color=color), info={'plot': desc}, path=plugin.url_for(func_or_url=home)) if installed == True and loggedin == True: folder.add_item(label=_.NEXT, info={'plot': desc6}, path=plugin.url_for(func_or_url=primary, addons=json.dumps(addons))) else: folder.add_item(label=_.NO_ADDONS_ENABLED, info={'plot': desc2}, path=plugin.url_for(func_or_url=home)) folder.add_item(label=_.RESET_SETTINGS, info={'plot': desc3}, path=plugin.url_for(func_or_url=reset_settings)) return folder
def settings_menu(**kwargs): folder = plugin.Folder(title=_.SETTINGS) folder.add_item(label=_.CHANNEL_PICKER, path=plugin.url_for(func_or_url=channel_picker_menu)) folder.add_item(label=_.SET_KODI, path=plugin.url_for(func_or_url=plugin._set_settings_kodi)) folder.add_item(label=_.INSTALL_WV_DRM, path=plugin.url_for(func_or_url=plugin._ia_install)) folder.add_item(label=_.RESET_SESSION, path=plugin.url_for(func_or_url=login, ask=0)) folder.add_item(label=_.RESET, path=plugin.url_for(func_or_url=reset_addon)) folder.add_item(label=_.LOGOUT, path=plugin.url_for(func_or_url=logout)) folder.add_item(label="Addon " + _.SETTINGS, path=plugin.url_for(func_or_url=plugin._settings)) return folder
def replaytv_item(label=None, idtitle=None, start=0, **kwargs): start = int(start) folder = plugin.Folder(title=label) processed = process_replaytv_list_content(label=label, idtitle=idtitle, start=start) if check_key(processed, 'items'): folder.add_items(processed['items']) if check_key(processed, 'total') and check_key(processed, 'count2') and processed['total'] > processed['count2']: folder.add_item( label = _(_.NEXT_PAGE, _bold=True), properties = {'SpecialSort': 'bottom'}, path = plugin.url_for(func_or_url=replaytv_item, label=label, idtitle=idtitle, start=processed['count2']), ) return folder
def channel_picker_menu(**kwargs): folder = plugin.Folder(title=_.CHANNEL_PICKER) folder.add_item(label=_.LIVE_TV, path=plugin.url_for(func_or_url=channel_picker, type='live')) folder.add_item(label=_.CHANNELS, path=plugin.url_for(func_or_url=channel_picker, type='replay')) folder.add_item(label=_.DISABLE_EROTICA, path=plugin.url_for(func_or_url=disable_prefs_menu, type='erotica')) folder.add_item(label=_.DISABLE_MINIMAL, path=plugin.url_for(func_or_url=disable_prefs_menu, type='minimal')) folder.add_item(label=_.DISABLE_REGIONAL2, path=plugin.url_for(func_or_url=disable_prefs_menu, type='regional')) if PROVIDER_NAME == 'kpn': folder.add_item(label=_.DISABLE_HOME_CONNECTION, path=plugin.url_for(func_or_url=disable_prefs_menu, type='home_only')) return folder
def replaytv(**kwargs): folder = plugin.Folder(title=_.CHANNELS) folder.add_item( label = _.PROGSAZ, info = {'plot': _.PROGSAZDESC}, path = plugin.url_for(func_or_url=replaytv_alphabetical), ) for row in get_replay_channels(): folder.add_item( label = row['label'], info = {'plot': row['description']}, art = {'thumb': row['image']}, path = row['path'], playable = row['playable'], ) return folder
def channel_picker_menu(type_tv_radio, save_all=0, radio=None, **kwargs): type_tv_radio = str(type_tv_radio) save_all = int(save_all) if not radio == None: radio = int(radio) profile_settings = load_profile(profile_id=1) profile_settings['radio'] = radio save_profile(profile_id=1, profile=profile_settings) if save_all == 1: save_all_prefs(type_tv_radio) if type_tv_radio == 'live': folder = plugin.Folder(title=_.SELECT_LIVE) desc2 = _.NEXT_SETUP_REPLAY folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=channel_picker_menu, type_tv_radio='replay', save_all=1)) prefs = load_prefs(profile_id=1) elif type_tv_radio == 'replay': folder = plugin.Folder(title=_.SELECT_REPLAY) desc2 = _.NEXT_SETUP_ORDER prefs = load_prefs(profile_id=1) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=order_picker_menu, type_tv_radio='live')) else: folder = plugin.Folder(title=_.SELECT_RADIO) desc2 = _.NEXT_SETUP_ORDER folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=order_picker_menu, type_tv_radio='radio')) prefs = load_radio_prefs(profile_id=1) if prefs: for currow in prefs: row = prefs[currow] if not check_key(row, type_tv_radio): continue if row[type_tv_radio] == 1: color = 'green' if not type_tv_radio == 'radio': addon_type = row[type_tv_radio + '_addonid'].replace( 'plugin.video.', '') else: color = 'red' if not type_tv_radio == 'radio': addon_type = _.DISABLED if not type_tv_radio == 'radio': label = _(row['name'] + ": " + addon_type, _bold=True, _color=color) else: label = _(row['name'], _bold=True, _color=color) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_channel, id=currow, type_tv_radio=type_tv_radio), playable=False, ) if type_tv_radio == 'live': folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=channel_picker_menu, type_tv_radio='replay', save_all=1)) elif type_tv_radio == 'replay': folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=order_picker_menu, type_tv_radio='live')) else: folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=order_picker_menu, type_tv_radio='radio')) return folder
def order_picker_menu(type_tv_radio, double=None, primary=None, **kwargs): type_tv_radio = unicode(type_tv_radio) save_all_order(type_tv_radio=type_tv_radio, double=double, primary=primary) folder = plugin.Folder(title=_.SELECT_ORDER) if type_tv_radio == 'live': profile_settings = load_profile(profile_id=1) if int(profile_settings['radio']) == 1: desc2 = _.NEXT_SETUP_RADIO path = plugin.url_for(func_or_url=channel_picker_menu, type_tv_radio='radio', save_all=1) else: desc2 = _.NEXT_SETUP_IPTV path = plugin.url_for(func_or_url=simple_iptv_menu) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=path) prefs = load_prefs(profile_id=1) order = load_order(profile_id=1) else: desc2 = _.NEXT_SETUP_IPTV folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) prefs = load_radio_prefs(profile_id=1) order = load_radio_order(profile_id=1) if order: for currow in order: row = prefs[currow] if int(row[type_tv_radio]) == 0: continue label = _(row['name'] + ": " + unicode(order[unicode(currow)]), _bold=True) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_order, id=currow, type_tv_radio=type_tv_radio), playable=False, ) if type_tv_radio == 'live': folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=path) else: folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) return folder
def group_picker_menu(type_tv_radio, **kwargs): type_tv_radio = str(type_tv_radio) folder = plugin.Folder(title=_.SELECT_GROUP) if type_tv_radio == 'live': profile_settings = load_profile(profile_id=1) if int(profile_settings['radio']) == 1: desc2 = _.NEXT_SETUP_RADIO path = plugin.url_for(func_or_url=channel_picker_menu, type_tv_radio='radio', save_all=1) else: desc2 = _.NEXT_SETUP_IPTV path = plugin.url_for(func_or_url=simple_iptv_menu) folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=path) prefs = load_prefs(profile_id=1) groups = load_file('tv_groups.json', ext=False, isJSON=True) else: desc2 = _.NEXT_SETUP_IPTV folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) prefs = load_radio_prefs(profile_id=1) groups = load_file('radio_groups.json', ext=False, isJSON=True) if not groups: groups = [] else: groups = list(groups) if prefs: for currow in prefs: row = prefs[currow] if int(row[type_tv_radio]) == 0: continue if check_key(row, 'group'): label = _(row['name'] + ": " + str(row['group']), _bold=True) else: if type_tv_radio == 'live': label = _(row['name'] + ": TV", _bold=True) else: label = _(row['name'] + ": Radio", _bold=True) folder.add_item( label=label, path=plugin.url_for(func_or_url=change_group, id=currow, type_tv_radio=type_tv_radio), playable=False, ) if type_tv_radio == 'live': folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=path) else: folder.add_item(label=_(_.NEXT, _bold=True), info={'plot': desc2}, path=plugin.url_for(func_or_url=simple_iptv_menu)) return folder
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 process_replaytv_content(station, day=0, start=0): day = int(day) start = int(start) curdate = datetime.date.today() - datetime.timedelta(days=day) startDate = convert_datetime_timezone(datetime.datetime(curdate.year, curdate.month, curdate.day, 0, 0, 0), "Europe/Amsterdam", "UTC") endDate = convert_datetime_timezone(datetime.datetime(curdate.year, curdate.month, curdate.day, 23, 59, 59), "Europe/Amsterdam", "UTC") startTimeStamp = int((startDate - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds()) endTimeStamp = int((endDate - datetime.datetime(1970, 1, 1, tzinfo=pytz.utc)).total_seconds()) data = api_get_epg_by_date_channel(date=curdate.strftime('%Y') + curdate.strftime('%m') + curdate.strftime('%d'), channel=station) 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 endT < (datetime.datetime.now(pytz.timezone("Europe/Amsterdam")) - datetime.timedelta(days=7)): continue label = startT.strftime("%H:%M") + " - " + unicode(row['title']) 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 = 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=program_id), context = context, playable = True, )) returnar = {'items': items, 'count': item_count, 'count2': count, 'total': len(data)} return returnar