Community Channels, Fix e Migliorie
This commit is contained in:
@@ -13,8 +13,8 @@ from channelselector import get_thumb
|
|||||||
from specials import shortcuts
|
from specials import shortcuts
|
||||||
CONTEXT = shortcuts.context()
|
CONTEXT = shortcuts.context()
|
||||||
|
|
||||||
addon = xbmcaddon.Addon('metadata.themoviedb.org')
|
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
||||||
lang = addon.getSetting('language')
|
lang = info_language[config.get_setting("info_language", "videolibrary")]
|
||||||
|
|
||||||
defpage = ["", "20", "40", "60", "80", "100"]
|
defpage = ["", "20", "40", "60", "80", "100"]
|
||||||
defp = defpage[config.get_setting('pagination','community')]
|
defp = defpage[config.get_setting('pagination','community')]
|
||||||
@@ -114,7 +114,7 @@ def show_menu(item):
|
|||||||
|
|
||||||
|
|
||||||
def search(item, text):
|
def search(item, text):
|
||||||
support.log(text)
|
support.log('Search:', text)
|
||||||
itemlist = []
|
itemlist = []
|
||||||
|
|
||||||
if item.custom_search:
|
if item.custom_search:
|
||||||
@@ -171,7 +171,7 @@ def peliculas(item, json='', key='', itemlist=[]):
|
|||||||
itlist = filterkey = []
|
itlist = filterkey = []
|
||||||
action = 'findvideos'
|
action = 'findvideos'
|
||||||
|
|
||||||
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'search']:
|
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'search'] and not item.filterkey:
|
||||||
Pagination = int(defp) if defp.isdigit() else ''
|
Pagination = int(defp) if defp.isdigit() else ''
|
||||||
else: Pagination = ''
|
else: Pagination = ''
|
||||||
pag = item.page if item.page else 1
|
pag = item.page if item.page else 1
|
||||||
@@ -446,7 +446,8 @@ def get_sub_menu(item, json, key, itemlist=[]):
|
|||||||
action = 'show_menu',
|
action = 'show_menu',
|
||||||
menu = level2 if not item.menu else None,
|
menu = level2 if not item.menu else None,
|
||||||
filterkey = filterkey,
|
filterkey = filterkey,
|
||||||
context = CONTEXT)
|
context = CONTEXT,
|
||||||
|
description = extra.description)
|
||||||
itemlist.append(it)
|
itemlist.append(it)
|
||||||
|
|
||||||
if 'search' in option:
|
if 'search' in option:
|
||||||
@@ -468,7 +469,6 @@ def get_search_menu(item, json='', itemlist=[], channel_name=''):
|
|||||||
else:
|
else:
|
||||||
title = 'Cerca ' + item.fulltitle + '...'
|
title = 'Cerca ' + item.fulltitle + '...'
|
||||||
extra = set_extra_values(item, json, item.path)
|
extra = set_extra_values(item, json, item.path)
|
||||||
support.log('EXTRA',extra)
|
|
||||||
|
|
||||||
itemlist.append(Item(channel=item.channel,
|
itemlist.append(Item(channel=item.channel,
|
||||||
title=support.typo(title,'submenu bold'),
|
title=support.typo(title,'submenu bold'),
|
||||||
@@ -487,30 +487,59 @@ def get_search_menu(item, json='', itemlist=[], channel_name=''):
|
|||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
def submenu(item, json, key, itemlist = []):
|
def submenu(item, json, key, itemlist = [], filter_list = []):
|
||||||
|
support.log()
|
||||||
import sys
|
import sys
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
from concurrent import futures
|
from concurrent import futures
|
||||||
else:
|
else:
|
||||||
from concurrent_py2 import futures
|
from concurrent_py2 import futures
|
||||||
|
|
||||||
filter_list = []
|
if item.description:
|
||||||
for option in json[key]:
|
if type(item.description) == dict:
|
||||||
if item.filterkey in option and option[item.filterkey]:
|
description = item.description
|
||||||
if type(option[item.filterkey]) == str and option[item.filterkey] not in filter_list:
|
else:
|
||||||
filter_list.append(option[item.filterkey])
|
if ':/' in item.description: url = item.description
|
||||||
elif type(option[item.filterkey]) == list:
|
else: url = filetools.join(item.path, item.description)
|
||||||
for f in option[item.filterkey]:
|
description = load_json(url)
|
||||||
if f not in filter_list:
|
else:
|
||||||
filter_list.append(f)
|
description = None
|
||||||
|
|
||||||
filter_list.sort()
|
if item.thumb: item.thumbnail = item.thumb
|
||||||
|
|
||||||
|
if not filter_list:
|
||||||
|
for option in json[key]:
|
||||||
|
if item.filterkey in option and option[item.filterkey]:
|
||||||
|
if type(option[item.filterkey]) == str and option[item.filterkey] not in filter_list:
|
||||||
|
filter_list.append(option[item.filterkey])
|
||||||
|
elif type(option[item.filterkey]) == list:
|
||||||
|
for f in option[item.filterkey]:
|
||||||
|
if f not in filter_list:
|
||||||
|
filter_list.append(f)
|
||||||
|
|
||||||
|
filter_list.sort()
|
||||||
|
|
||||||
|
Pagination = int(defp) if defp.isdigit() else ''
|
||||||
|
pag = item.page if item.page else 1
|
||||||
|
filters = []
|
||||||
|
for i, filter in enumerate(filter_list):
|
||||||
|
if Pagination and (pag - 1) * Pagination > i: continue # pagination
|
||||||
|
if Pagination and i >= pag * Pagination: break
|
||||||
|
filters.append(filter)
|
||||||
|
|
||||||
with futures.ThreadPoolExecutor() as executor:
|
with futures.ThreadPoolExecutor() as executor:
|
||||||
List = [executor.submit(filter_thread, filter, key, item) for filter in filter_list]
|
List = [executor.submit(filter_thread, filter, key, item, description) for filter in filters]
|
||||||
for res in futures.as_completed(List):
|
for res in futures.as_completed(List):
|
||||||
if res.result():
|
if res.result():
|
||||||
itemlist.append(res.result())
|
itemlist.append(res.result())
|
||||||
|
|
||||||
|
if Pagination and len(itemlist) >= Pagination:
|
||||||
|
item.title = support.typo(config.get_localized_string(30992), 'color kod bold')
|
||||||
|
item.page = pag + 1
|
||||||
|
item.thumb = item.thumbnail
|
||||||
|
item.thumbnail = support.thumb()
|
||||||
|
itemlist.append(item)
|
||||||
|
|
||||||
itemlist = sorted(itemlist, key=lambda it: it.title)
|
itemlist = sorted(itemlist, key=lambda it: it.title)
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
@@ -518,12 +547,12 @@ def submenu(item, json, key, itemlist = []):
|
|||||||
################################ Filter results ################################
|
################################ Filter results ################################
|
||||||
|
|
||||||
# filter results
|
# filter results
|
||||||
def filter_thread(filter, key, item):
|
def filter_thread(filter, key, item, description):
|
||||||
thumbnail = ''
|
thumbnail = plot = fanart = ''
|
||||||
plot = ''
|
|
||||||
if item.filterkey in ['actors', 'director']:
|
if item.filterkey in ['actors', 'director']:
|
||||||
dict_ = {'url': 'search/person', 'language': lang, 'query': filter, 'page': 1}
|
dict_ = {'url': 'search/person', 'language': lang, 'query': filter, 'page': 1}
|
||||||
tmdb_inf = tmdb.discovery(item, dict_=dict_)
|
tmdb_inf = tmdb.discovery(item, dict_=dict_)
|
||||||
|
id = None
|
||||||
if tmdb_inf.results:
|
if tmdb_inf.results:
|
||||||
results = tmdb_inf.results[0]
|
results = tmdb_inf.results[0]
|
||||||
id = results['id']
|
id = results['id']
|
||||||
@@ -532,13 +561,21 @@ def filter_thread(filter, key, item):
|
|||||||
json_file = httptools.downloadpage('http://api.themoviedb.org/3/person/'+ str(id) + '?api_key=' + tmdb_api + '&language=en', use_requests=True).data
|
json_file = httptools.downloadpage('http://api.themoviedb.org/3/person/'+ str(id) + '?api_key=' + tmdb_api + '&language=en', use_requests=True).data
|
||||||
plot += jsontools.load(json_file)['biography']
|
plot += jsontools.load(json_file)['biography']
|
||||||
|
|
||||||
|
if description:
|
||||||
|
if filter in description:
|
||||||
|
extra = set_extra_values(item, description[filter], item.path)
|
||||||
|
thumbnail = extra.thumb if extra.thumb else item.thumbnail
|
||||||
|
fanart = extra.fanart if extra.fanart else item.fanart
|
||||||
|
plot = extra.plot if extra.plot else item.plot
|
||||||
|
|
||||||
item = Item(channel=item.channel,
|
item = Item(channel=item.channel,
|
||||||
title=support.typo(filter, 'bold'),
|
title=support.typo(filter, 'bold'),
|
||||||
url=item.url,
|
url=item.url,
|
||||||
media_type=item.media_type,
|
media_type=item.media_type,
|
||||||
action='peliculas',
|
action='peliculas',
|
||||||
thumbnail=thumbnail,
|
thumbnail=thumbnail if thumbnail else item.thumbnail,
|
||||||
plot=plot,
|
fanart=fanart if fanart else item.fanart,
|
||||||
|
plot=plot if plot else item.plot,
|
||||||
path=item.path,
|
path=item.path,
|
||||||
filterkey=item.filterkey,
|
filterkey=item.filterkey,
|
||||||
filter=filter,
|
filter=filter,
|
||||||
@@ -619,9 +656,10 @@ def set_extra_values(item, json, path):
|
|||||||
filterkey = json[key].keys()[0]
|
filterkey = json[key].keys()[0]
|
||||||
ret.filter = json[key][filterkey]
|
ret.filter = json[key][filterkey]
|
||||||
ret.filterkey = filterkey
|
ret.filterkey = filterkey
|
||||||
|
elif key == 'description':
|
||||||
|
ret.description = json[key]
|
||||||
|
|
||||||
if not ret.thumb:
|
if not ret.thumb:
|
||||||
support.log('STACK=',inspect.stack()[1][3])
|
|
||||||
if 'get_search_menu' in inspect.stack()[1][3]:
|
if 'get_search_menu' in inspect.stack()[1][3]:
|
||||||
ret.thumb = get_thumb('search.png')
|
ret.thumb = get_thumb('search.png')
|
||||||
else:
|
else:
|
||||||
@@ -729,6 +767,8 @@ def add_channel(item):
|
|||||||
elif result==1:
|
elif result==1:
|
||||||
url = platformtools.dialog_input("", config.get_localized_string(70681), False)
|
url = platformtools.dialog_input("", config.get_localized_string(70681), False)
|
||||||
try:
|
try:
|
||||||
|
if url[:4] != 'http':
|
||||||
|
url = 'http://' + url
|
||||||
channel_to_add['path'] = url
|
channel_to_add['path'] = url
|
||||||
json_file = jsontools.load(httptools.downloadpage(url).data)
|
json_file = jsontools.load(httptools.downloadpage(url).data)
|
||||||
except:
|
except:
|
||||||
@@ -756,6 +796,9 @@ def add_channel(item):
|
|||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(70683) % json_file['channel_name'])
|
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(70683) % json_file['channel_name'])
|
||||||
|
import xbmc
|
||||||
|
xbmc.sleep(1000)
|
||||||
|
platformtools.itemlist_refresh()
|
||||||
return
|
return
|
||||||
|
|
||||||
def remove_channel(item):
|
def remove_channel(item):
|
||||||
|
|||||||
Reference in New Issue
Block a user