Test ricerca globale
This commit is contained in:
+25
-22
@@ -72,7 +72,7 @@ EPISODESLIST = 200
|
|||||||
SERVERLIST = 300
|
SERVERLIST = 300
|
||||||
|
|
||||||
class SearchWindow(xbmcgui.WindowXML):
|
class SearchWindow(xbmcgui.WindowXML):
|
||||||
def start(self, item, moduleDict={}, searchActions=[]):
|
def start(self, item, moduleDict={}, searchActions=[], thActions=None):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
self.exit = False
|
self.exit = False
|
||||||
self.item = item
|
self.item = item
|
||||||
@@ -95,7 +95,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
self.thActions = Thread(target=self.getActions)
|
self.thActions = Thread(target=self.getActions)
|
||||||
self.thActions.start()
|
self.thActions.start()
|
||||||
else:
|
else:
|
||||||
self.thActions = None
|
self.thActions = thActions
|
||||||
|
|
||||||
self.lastSearch()
|
self.lastSearch()
|
||||||
if not self.item.text: return
|
if not self.item.text: return
|
||||||
@@ -293,7 +293,23 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
|
|
||||||
def timer(self):
|
def timer(self):
|
||||||
while self.searchActions:
|
while self.searchActions:
|
||||||
|
percent = (float(self.count) / len(self.searchActions)) * 100
|
||||||
|
self.LOADING.setVisible(False)
|
||||||
|
self.PROGRESS.setPercent(percent)
|
||||||
self.COUNT.setText('%s/%s [%s"]' % (self.count, len(self.searchActions), int(time.time() - self.time)))
|
self.COUNT.setText('%s/%s [%s"]' % (self.count, len(self.searchActions), int(time.time() - self.time)))
|
||||||
|
if percent == 100:
|
||||||
|
self.channels = []
|
||||||
|
self.moduleDict = {}
|
||||||
|
self.searchActions = []
|
||||||
|
|
||||||
|
# if no results
|
||||||
|
total = 0
|
||||||
|
for num in self.results.values():
|
||||||
|
total += num
|
||||||
|
if not total:
|
||||||
|
self.PROGRESS.setVisible(False)
|
||||||
|
self.NORESULTS.setVisible(True)
|
||||||
|
self.setFocusId(CLOSE)
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|
||||||
def search(self):
|
def search(self):
|
||||||
@@ -304,6 +320,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
self.thActions.join()
|
self.thActions.join()
|
||||||
Thread(target=self.timer).start()
|
Thread(target=self.timer).start()
|
||||||
|
|
||||||
|
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.searchActions:
|
||||||
if self.exit: return
|
if self.exit: return
|
||||||
@@ -314,6 +331,10 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
self.count += 1
|
self.count += 1
|
||||||
channel, valid, other = ch.result()
|
channel, valid, other = ch.result()
|
||||||
self.update(channel, valid, other)
|
self.update(channel, valid, other)
|
||||||
|
except:
|
||||||
|
import traceback
|
||||||
|
logger.error(traceback.format_exc())
|
||||||
|
self.count = len(self.searchActions)
|
||||||
|
|
||||||
def get_channel_results(self, searchAction):
|
def get_channel_results(self, searchAction):
|
||||||
def search(text):
|
def search(text):
|
||||||
@@ -446,24 +467,6 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
self.RESULTS.reset()
|
self.RESULTS.reset()
|
||||||
self.RESULTS.addItems(items)
|
self.RESULTS.addItems(items)
|
||||||
|
|
||||||
percent = (float(self.count) / len(self.searchActions)) * 100
|
|
||||||
self.LOADING.setVisible(False)
|
|
||||||
self.PROGRESS.setPercent(percent)
|
|
||||||
self.COUNT.setText('%s/%s [%s"]' % (self.count, len(self.searchActions), int(time.time() - self.time) ))
|
|
||||||
if percent == 100:
|
|
||||||
self.channels = []
|
|
||||||
self.moduleDict = {}
|
|
||||||
self.searchActions = []
|
|
||||||
|
|
||||||
# if no results
|
|
||||||
total = 0
|
|
||||||
for num in self.results.values():
|
|
||||||
total += num
|
|
||||||
if not total:
|
|
||||||
self.PROGRESS.setVisible(False)
|
|
||||||
self.NORESULTS.setVisible(True)
|
|
||||||
self.setFocusId(CLOSE)
|
|
||||||
|
|
||||||
def onInit(self):
|
def onInit(self):
|
||||||
self.time = time.time()
|
self.time = time.time()
|
||||||
|
|
||||||
@@ -601,7 +604,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
self.actors()
|
self.actors()
|
||||||
elif search == 'persons':
|
elif search == 'persons':
|
||||||
item = self.item.clone(mode='person_', discovery=self.persons[pos])
|
item = self.item.clone(mode='person_', discovery=self.persons[pos])
|
||||||
Search(item, self.moduleDict, self.searchActions)
|
Search(item, self.moduleDict, self.searchActions, self.thActions)
|
||||||
if close_action:
|
if close_action:
|
||||||
self.close()
|
self.close()
|
||||||
else:
|
else:
|
||||||
@@ -609,7 +612,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
if self.item.mode == 'movie': item.contentTitle = self.RESULTS.getSelectedItem().getLabel()
|
if self.item.mode == 'movie': item.contentTitle = self.RESULTS.getSelectedItem().getLabel()
|
||||||
else: item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
|
else: item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
|
||||||
|
|
||||||
Search(item, self.moduleDict, self.searchActions)
|
Search(item, self.moduleDict, self.searchActions, self.thActions)
|
||||||
if close_action:
|
if close_action:
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user