Migliorie ricerca globale
This commit is contained in:
@@ -75,7 +75,7 @@ def newest(categoria):
|
|||||||
|
|
||||||
def search(item, text):
|
def search(item, text):
|
||||||
logger.info("search", text)
|
logger.info("search", text)
|
||||||
if item.contentType == 'tvshow': item.url = host + '/serietv/'
|
if item.contentType == 'tvshow': item.url = host + '/serietv'
|
||||||
else: item.url = host
|
else: item.url = host
|
||||||
try:
|
try:
|
||||||
item.url = item.url + "/search/" + text.replace(' ', '+')
|
item.url = item.url + "/search/" + text.replace(' ', '+')
|
||||||
|
|||||||
@@ -602,7 +602,7 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
|||||||
if parent_item.channel == 'globalsearch':
|
if parent_item.channel == 'globalsearch':
|
||||||
context_commands.append( (config.get_localized_string(30155), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "favorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action}))))
|
context_commands.append( (config.get_localized_string(30155), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "favorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action}))))
|
||||||
# Search in other channels
|
# Search in other channels
|
||||||
if item.contentTitle and item.contentType in ['movie', 'tvshow'] and parent_item.channel != 'search' and item.action not in ['play'] and parent_item.action != 'mainlist':
|
if item.contentTitle and item.contentType in ['movie', 'tvshow'] and parent_item.channel not in ['search', 'globalsearch'] and item.action not in ['play'] and parent_item.action != 'mainlist':
|
||||||
|
|
||||||
# Search in other channels
|
# Search in other channels
|
||||||
if item.contentSerieName != '':
|
if item.contentSerieName != '':
|
||||||
|
|||||||
@@ -1838,7 +1838,7 @@ msgstr ""
|
|||||||
|
|
||||||
msgctxt "#60422"
|
msgctxt "#60422"
|
||||||
msgid "Channels search"
|
msgid "Channels search"
|
||||||
msgstr "Ricerca canali"
|
msgstr ""
|
||||||
|
|
||||||
msgctxt "#60423"
|
msgctxt "#60423"
|
||||||
msgid "Search"
|
msgid "Search"
|
||||||
|
|||||||
+40
-34
@@ -1,4 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import threading
|
||||||
|
|
||||||
import xbmc, xbmcgui, sys, channelselector, time, os
|
import xbmc, xbmcgui, sys, channelselector, time, os
|
||||||
from core.support import dbg, tmdb
|
from core.support import dbg, tmdb
|
||||||
@@ -18,6 +19,7 @@ else:
|
|||||||
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
|
||||||
def_lang = info_language[config.get_setting("info_language", "videolibrary")]
|
def_lang = info_language[config.get_setting("info_language", "videolibrary")]
|
||||||
close_action = False
|
close_action = False
|
||||||
|
update_lock = threading.Lock()
|
||||||
|
|
||||||
|
|
||||||
def busy(state):
|
def busy(state):
|
||||||
@@ -90,8 +92,8 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
self.items = []
|
self.items = []
|
||||||
self.search_threads = []
|
self.search_threads = []
|
||||||
|
|
||||||
if not searchActions:
|
if not thActions:
|
||||||
self.thActions = Thread(target=self.getActions)
|
self.thActions = Thread(target=self.getActionsThread)
|
||||||
self.thActions.start()
|
self.thActions.start()
|
||||||
else:
|
else:
|
||||||
self.thActions = thActions
|
self.thActions = thActions
|
||||||
@@ -119,17 +121,37 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
save_search(self.item.text)
|
save_search(self.item.text)
|
||||||
|
|
||||||
|
|
||||||
def getActions(self):
|
def getActionsThread(self):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
count = 0
|
|
||||||
self.channelsList = self.get_channels()
|
self.channelsList = self.get_channels()
|
||||||
for channel in self.channelsList:
|
for channel in self.channelsList:
|
||||||
self.getModule(channel)
|
logger.debug(channel)
|
||||||
count += 1
|
try:
|
||||||
percent = (float(count) / len(self.channelsList)) * 100
|
module = __import__('channels.%s' % channel, fromlist=["channels.%s" % channel])
|
||||||
if self.thread or self.selected: # window started
|
mainlist = getattr(module, 'mainlist')(Item(channel=channel, global_search=True))
|
||||||
self.PROGRESS.setPercent(percent)
|
action = [elem for elem in mainlist if elem.action == "search" and (
|
||||||
self.COUNT.setText('%s/%s' % (count, len(self.channelsList)))
|
self.item.mode in ['all', 'person'] or elem.contentType in [self.item.mode, 'undefined'])]
|
||||||
|
self.moduleDict[channel] = module
|
||||||
|
self.searchActions += action
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
logger.error('error importing/getting search items of ' + channel)
|
||||||
|
logger.error(traceback.format_exc())
|
||||||
|
|
||||||
|
def getActions(self):
|
||||||
|
# return immediately all actions that are already loadead
|
||||||
|
for action in self.searchActions:
|
||||||
|
yield action
|
||||||
|
|
||||||
|
# wait and return as getActionsThread load
|
||||||
|
lastLen = len(self.searchActions)
|
||||||
|
while self.thActions.is_alive():
|
||||||
|
while len(self.searchActions) == lastLen:
|
||||||
|
if not self.thActions.is_alive():
|
||||||
|
return
|
||||||
|
time.sleep(0.1)
|
||||||
|
yield self.searchActions[lastLen]
|
||||||
|
lastLen = len(self.searchActions)
|
||||||
|
|
||||||
def select(self):
|
def select(self):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
@@ -269,7 +291,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
n = list_cat.index('anime')
|
n = list_cat.index('anime')
|
||||||
list_cat[n] = 'tvshow'
|
list_cat[n] = 'tvshow'
|
||||||
|
|
||||||
if self.item.mode == 'all' or self.item.mode in list_cat or self.item.type in list_cat:
|
if self.item.mode in ['all', 'person'] or self.item.mode in list_cat or self.item.type in list_cat:
|
||||||
if config.get_setting("include_in_global_search", channel) and ch_param.get("active", False):
|
if config.get_setting("include_in_global_search", channel) and ch_param.get("active", False):
|
||||||
channels_list.append(channel)
|
channels_list.append(channel)
|
||||||
|
|
||||||
@@ -277,19 +299,6 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
|
|
||||||
return channels_list
|
return channels_list
|
||||||
|
|
||||||
def getModule(self, channel):
|
|
||||||
logger.debug()
|
|
||||||
try:
|
|
||||||
module = __import__('channels.%s' % channel, fromlist=["channels.%s" % channel])
|
|
||||||
mainlist = getattr(module, 'mainlist')(Item(channel=channel, global_search=True))
|
|
||||||
action = [elem for elem in mainlist if elem.action == "search" and (self.item.mode == 'all' or elem.contentType in [self.item.mode, 'undefined'])]
|
|
||||||
self.moduleDict[channel] = module
|
|
||||||
self.searchActions += action
|
|
||||||
except:
|
|
||||||
import traceback
|
|
||||||
logger.error('error importing/getting search items of ' + channel)
|
|
||||||
logger.error(traceback.format_exc())
|
|
||||||
|
|
||||||
def timer(self):
|
def timer(self):
|
||||||
while self.searchActions:
|
while self.searchActions:
|
||||||
if self.exit: return
|
if self.exit: return
|
||||||
@@ -316,21 +325,13 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
logger.debug()
|
logger.debug()
|
||||||
self.count = 0
|
self.count = 0
|
||||||
self.LOADING.setVisible(True)
|
self.LOADING.setVisible(True)
|
||||||
if self.thActions:
|
|
||||||
self.thActions.join()
|
|
||||||
Thread(target=self.timer).start()
|
Thread(target=self.timer).start()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
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.getActions():
|
||||||
if self.exit: return
|
if self.exit: return
|
||||||
self.search_threads.append(executor.submit(self.get_channel_results, searchAction))
|
self.search_threads.append(executor.submit(self.get_channel_results, searchAction))
|
||||||
for ch in futures.as_completed(self.search_threads):
|
|
||||||
self.count += 1
|
|
||||||
if self.exit: return
|
|
||||||
if ch.result():
|
|
||||||
channel, valid, other = ch.result()
|
|
||||||
self.update(channel, valid, other)
|
|
||||||
except:
|
except:
|
||||||
import traceback
|
import traceback
|
||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
@@ -379,7 +380,12 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
import traceback
|
import traceback
|
||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
|
|
||||||
return channel, valid, other if other else results
|
if self.exit:
|
||||||
|
return
|
||||||
|
update_lock.acquire()
|
||||||
|
self.count += 1
|
||||||
|
self.update(channel, valid, other if other else results)
|
||||||
|
update_lock.release()
|
||||||
|
|
||||||
def makeItem(self, url):
|
def makeItem(self, url):
|
||||||
item = Item().fromurl(url)
|
item = Item().fromurl(url)
|
||||||
|
|||||||
Reference in New Issue
Block a user