From a8fe4b4a98a6ba78675264236b57c7c9ce64ef20 Mon Sep 17 00:00:00 2001 From: Alhaziel Date: Thu, 17 Oct 2019 12:10:55 +0200 Subject: [PATCH] Ricerca per i Community Channels --- specials/community.py | 68 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 60 insertions(+), 8 deletions(-) diff --git a/specials/community.py b/specials/community.py index 5eecc378..163ca25b 100644 --- a/specials/community.py +++ b/specials/community.py @@ -74,13 +74,14 @@ def show_channels(item): return itemlist def load_json(item): - logger.info() - if item.url: - if item.url.startswith('http'): - json_file = httptools.downloadpage(item.url).data + url= item if type(item) == str else item.url + + if url: + if url.startswith('http'): + json_file = httptools.downloadpage(url).data else: - json_file = open(item.url, "r").read() + json_file = open(url, "r").read() json_data = jsontools.load(json_file) else: @@ -91,7 +92,7 @@ def load_json(item): def show_menu(item): global list_data itemlist = [] - logger.info(item) + logger.info() json_data = load_json(item) @@ -111,6 +112,7 @@ def show_menu(item): plot = item.plot url = '' if not option['link'] else option['link'] if ':/' in option['link'] else item.path + option['link'] itemlist.append(Item(channel=item.channel, title=format_title(option['title']), thumbnail=thumbnail, fanart=fanart, plot=plot, action='show_menu', url=url, path=item.path)) + itemlist.append(Item(channel=item.channel, title=typo('Cerca...','color kod bold'), thumbnail=get_thumb('search.png'), action='search', url=item.url, path=item.path)) if 'channel_name' in json_data: autoplay.show_option(item.channel, itemlist) return itemlist @@ -167,7 +169,7 @@ def list_all(item): return itemlist def seasons(item): - logger.info('PATH= ' + item.path) + logger.info() itemlist = [] infoLabels = item.infoLabels list_seasons = item.url @@ -330,4 +332,54 @@ def format_title(title): t = scrapertoolsV2.find_single_match(title, r'\{([^\}]+)\}') if 'bold' not in t: t += ' bold' title = re.sub(r'(\{[^\}]+\})','',title) - return typo(title,t) \ No newline at end of file + return typo(title,t) + +def search(item, text): + logger.info('Search '+ text) + itemlist = [] + json_data = load_json(item) + + return load_links(item, itemlist, json_data, text) + +def load_links(item, itemlist, json_data, text): + for option in json_data['menu']: + json_data = load_json(option['link'] if option['link'].startswith('http') else item.path+option['link']) + if not 'menu' in json_data: + if "movies_list" in json_data: media_type= 'movies_list' + elif "tvshows_list" in json_data: media_type = 'tvshows_list' + elif "episodes_list" in json_data: media_type = 'episodes_list' + if "generic_list" in json_data: media_type= 'generic_list' + + if json_data: + for media in json_data[media_type]: + if text.lower() in media['title'].lower(): + quality, language, plot, poster = set_extra_values(media) + + title = media['title'] + title = set_title(title, language, quality) + + new_item = Item(channel=item.channel, title=format_title(title), quality=quality, + language=language, plot=plot, personal_plot=plot, thumbnail=poster, path=item.path) + + new_item.infoLabels['year'] = media['year'] if 'year' in media else '' + new_item.infoLabels['tmdb_id'] = media['tmdb_id'] if 'tmdb_id' in media else '' + + if 'movies_list' in json_data or 'generic_list' in json_data: + new_item.url = media + new_item.contentTitle = media['title'] + new_item.action = 'findvideos' + else: + new_item.url = media['seasons_list'] + new_item.contentSerieName = media['title'] + new_item.action = 'seasons' + + itemlist.append(new_item) + + if not 'generic_list' in json_data: + tmdb.set_infoLabels(itemlist, seekTmdb=True) + for item in itemlist: + if item.personal_plot != item.plot and item.personal_plot: + item.plot = '\n\n' + typo('','submenu') + '\n' + item.personal_plot + '\n' + typo('','submenu') + '\n\n' + item.plot + else: + load_links(item, itemlist, json_data, text) + return itemlist \ No newline at end of file