Ricerca globale Test
This commit is contained in:
@@ -92,6 +92,10 @@ def run(item=None):
|
|||||||
if not config.get_setting('tmdb_active'):
|
if not config.get_setting('tmdb_active'):
|
||||||
config.set_setting('tmdb_active', True)
|
config.set_setting('tmdb_active', True)
|
||||||
|
|
||||||
|
if config.get_setting('new_search') and item.channel == "search" and item.action == 'new_search':
|
||||||
|
item.channel = 'globalsearch'
|
||||||
|
item.action = 'Search'
|
||||||
|
|
||||||
# If item has no action, stops here
|
# If item has no action, stops here
|
||||||
if item.action == "":
|
if item.action == "":
|
||||||
logger.debug("Item without action")
|
logger.debug("Item without action")
|
||||||
@@ -135,12 +139,6 @@ def run(item=None):
|
|||||||
from platformcode import infoplus
|
from platformcode import infoplus
|
||||||
return infoplus.Main(item)
|
return infoplus.Main(item)
|
||||||
|
|
||||||
elif config.get_setting('new_search') and item.channel == "search" and item.action == 'new_search':
|
|
||||||
from platformcode.globalsearch import Search
|
|
||||||
item.contextual = True
|
|
||||||
Search(item)
|
|
||||||
return
|
|
||||||
|
|
||||||
elif item.channel == "backup":
|
elif item.channel == "backup":
|
||||||
from platformcode import backup
|
from platformcode import backup
|
||||||
return getattr(backup, item.action)(item)
|
return getattr(backup, item.action)(item)
|
||||||
|
|||||||
@@ -28,8 +28,7 @@ def Search(*args):
|
|||||||
w = SearchWindow('GlobalSearch.xml', config.get_runtime_path())
|
w = SearchWindow('GlobalSearch.xml', config.get_runtime_path())
|
||||||
w.start(*args)
|
w.start(*args)
|
||||||
del w
|
del w
|
||||||
gc.collect()
|
xbmc.sleep(1000)
|
||||||
# xbmc.sleep(600)
|
|
||||||
|
|
||||||
# Actions
|
# Actions
|
||||||
LEFT = 1
|
LEFT = 1
|
||||||
@@ -132,7 +131,6 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
results = tmdb_info.results
|
results = tmdb_info.results
|
||||||
|
|
||||||
for result in results:
|
for result in results:
|
||||||
logger.info(result)
|
|
||||||
result = tmdb_info.get_infoLabels(result, origen=result)
|
result = tmdb_info.get_infoLabels(result, origen=result)
|
||||||
if self.item.mode == 'movie':
|
if self.item.mode == 'movie':
|
||||||
title = result['title']
|
title = result['title']
|
||||||
@@ -284,26 +282,25 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
with futures.ThreadPoolExecutor(max_workers=set_workers()) as executor:
|
with futures.ThreadPoolExecutor(max_workers=set_workers()) as executor:
|
||||||
for searchAction in self.searchActions:
|
for searchAction in self.searchActions:
|
||||||
if self.exit: return
|
if self.exit: return
|
||||||
executor.submit(self.get_channel_results, self.item, self.moduleDict, searchAction)
|
executor.submit(self.get_channel_results, searchAction)
|
||||||
|
logger.debug('end search for:', searchAction.channel)
|
||||||
|
|
||||||
def get_channel_results(self, item, module_dict, search_action):
|
def get_channel_results(self, searchAction):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
channel = search_action.channel
|
channel = searchAction.channel
|
||||||
results = []
|
results = []
|
||||||
valid = []
|
valid = []
|
||||||
other = []
|
other = []
|
||||||
module = module_dict[channel]
|
|
||||||
searched_id = item.infoLabels['tmdb_id']
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
results.extend(module.search(search_action, item.text))
|
results = self.moduleDict[channel].search(searchAction, self.item.text)
|
||||||
if len(results) == 1:
|
if len(results) == 1:
|
||||||
if not results[0].action or config.get_localized_string(70006).lower() in results[0].title.lower():
|
if not results[0].action or config.get_localized_string(70006).lower() in results[0].title.lower():
|
||||||
results = []
|
results = []
|
||||||
|
|
||||||
if self.item.mode != 'all':
|
if self.item.mode != 'all':
|
||||||
for elem in results:
|
for elem in results:
|
||||||
if elem.infoLabels['tmdb_id'] == searched_id:
|
if elem.infoLabels['tmdb_id'] == self.item.infoLabels['tmdb_id']:
|
||||||
elem.from_channel = channel
|
elem.from_channel = channel
|
||||||
elem.verified = 1
|
elem.verified = 1
|
||||||
valid.append(elem)
|
valid.append(elem)
|
||||||
@@ -313,7 +310,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
self.count += 1
|
self.count += 1
|
||||||
self.update(channel, valid, other if other else results)
|
return self.update(channel, valid, other if other else results)
|
||||||
|
|
||||||
def makeItem(self, url):
|
def makeItem(self, url):
|
||||||
item = Item().fromurl(url)
|
item = Item().fromurl(url)
|
||||||
Reference in New Issue
Block a user