Ricerche salvate: supporto cerca film/serie/attore
Possibile fix freeze kodi alla chiusura
This commit is contained in:
@@ -8,6 +8,7 @@ from core import channeltools, servertools, scrapertools
|
||||
from platformcode import platformtools, config, logger
|
||||
from platformcode.launcher import run
|
||||
from threading import Thread
|
||||
from specials.search import save_search
|
||||
|
||||
if sys.version_info[0] >= 3:
|
||||
PY3 = True
|
||||
@@ -28,10 +29,12 @@ def busy(state):
|
||||
if state: xbmc.executebuiltin('ActivateWindow(busydialognocancel)')
|
||||
else: xbmc.executebuiltin('Dialog.Close(busydialognocancel)')
|
||||
|
||||
|
||||
def set_workers():
|
||||
workers = config.get_setting('thread_number') if config.get_setting('thread_number') > 0 else None
|
||||
return workers
|
||||
|
||||
|
||||
def Search(*args):
|
||||
xbmc.executebuiltin('Dialog.Close(all)')
|
||||
w = SearchWindow('GlobalSearch.xml', config.get_runtime_path())
|
||||
@@ -119,9 +122,11 @@ class SearchWindow(xbmcgui.WindowXML):
|
||||
if not self.item.text: self.item.text = platformtools.dialog_input(default=last_search, heading='')
|
||||
if self.item.text:
|
||||
channeltools.set_channel_setting('Last_searched', self.item.text, 'search')
|
||||
from specials.search import save_search
|
||||
save_search(self.item.text)
|
||||
|
||||
if self.item.mode == 'all':
|
||||
save_search(self.item.text)
|
||||
else:
|
||||
del self.item.context # needed for preventing same content twice in saved search
|
||||
save_search(self.item.__dict__)
|
||||
|
||||
def getActionsThread(self):
|
||||
logger.debug()
|
||||
@@ -186,7 +191,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
||||
rating = str(result.get('vote_average', ''))
|
||||
|
||||
new_item = Item(channel='globalsearch',
|
||||
action=True,
|
||||
action="Search",
|
||||
title=title,
|
||||
thumbnail=thumbnail,
|
||||
fanart=fanart,
|
||||
@@ -246,8 +251,8 @@ class SearchWindow(xbmcgui.WindowXML):
|
||||
discovery = {'url': 'person/%s/combined_credits' % cast_id, 'page': '1', 'sort_by': 'primary_release_date.desc', 'language': def_lang}
|
||||
self.persons.append(discovery)
|
||||
|
||||
new_item = Item(channel='search',
|
||||
action=True,
|
||||
new_item = Item(channel='globalsearch',
|
||||
action="Search",
|
||||
title=name,
|
||||
thumbnail=thumb,
|
||||
mode='search')
|
||||
@@ -641,7 +646,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
||||
self.page -= 1
|
||||
self.actors()
|
||||
elif search == 'persons':
|
||||
item = self.item.clone(mode='person_', discovery=self.persons[pos])
|
||||
item = Item().fromurl(self.RESULTS.getSelectedItem().getProperty('item')).clone(mode='person_', discovery=self.persons[pos], text=True, folder=False)
|
||||
Search(item, self.thActions)
|
||||
if close_action:
|
||||
self.close()
|
||||
@@ -649,6 +654,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
||||
item = Item().fromurl(self.RESULTS.getSelectedItem().getProperty('item'))
|
||||
if self.item.mode == 'movie': item.contentTitle = self.RESULTS.getSelectedItem().getLabel()
|
||||
else: item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
|
||||
item.folder = False
|
||||
|
||||
Search(item, self.thActions)
|
||||
if close_action:
|
||||
@@ -790,7 +796,6 @@ class SearchWindow(xbmcgui.WindowXML):
|
||||
busy(False)
|
||||
self.close()
|
||||
|
||||
|
||||
def context(self):
|
||||
focus = self.getFocusId()
|
||||
if focus == EPISODESLIST: # context on episode
|
||||
|
||||
@@ -77,21 +77,9 @@ def sub_menu(item):
|
||||
def saved_search(item):
|
||||
logger.debug()
|
||||
|
||||
itemlist = list()
|
||||
saved_searches_list = get_saved_searches()
|
||||
itemlist = get_saved_searches()
|
||||
|
||||
|
||||
for saved_search_text in saved_searches_list:
|
||||
itemlist.append(
|
||||
Item(channel=item.channel if not config.get_setting('new_search') else 'globalsearch',
|
||||
action="new_search" if not config.get_setting('new_search') else 'Search',
|
||||
title=typo(saved_search_text.split('{}')[0], 'bold'),
|
||||
search_text=saved_search_text.split('{}')[0],
|
||||
text=saved_search_text.split('{}')[0],
|
||||
mode='all',
|
||||
thumbnail=get_thumb('search.png')))
|
||||
|
||||
if len(saved_searches_list) > 0:
|
||||
if len(itemlist) > 0:
|
||||
itemlist.append(
|
||||
Item(channel=item.channel,
|
||||
action="clear_saved_searches",
|
||||
@@ -807,11 +795,9 @@ def save_search(text):
|
||||
if text:
|
||||
saved_searches_limit = config.get_setting("saved_searches_limit")
|
||||
|
||||
current_saved_searches_list = config.get_setting("saved_searches_list", "search")
|
||||
if current_saved_searches_list is None:
|
||||
saved_searches_list = config.get_setting("saved_searches_list", "search")
|
||||
if not saved_searches_list:
|
||||
saved_searches_list = []
|
||||
else:
|
||||
saved_searches_list = list(current_saved_searches_list)
|
||||
|
||||
if text in saved_searches_list:
|
||||
saved_searches_list.remove(text)
|
||||
@@ -824,13 +810,25 @@ def save_search(text):
|
||||
def clear_saved_searches(item):
|
||||
config.set_setting("saved_searches_list", list(), "search")
|
||||
platformtools.dialog_ok(config.get_localized_string(60423), config.get_localized_string(60424))
|
||||
platformtools.itemlist_refresh()
|
||||
|
||||
|
||||
def get_saved_searches():
|
||||
current_saved_searches_list = config.get_setting("saved_searches_list", "search")
|
||||
if current_saved_searches_list is None:
|
||||
saved_searches_list = []
|
||||
else:
|
||||
saved_searches_list = list(current_saved_searches_list)
|
||||
if not current_saved_searches_list:
|
||||
current_saved_searches_list = []
|
||||
saved_searches_list = []
|
||||
for saved_search_item in current_saved_searches_list:
|
||||
if type(saved_search_item) == str:
|
||||
saved_searches_list.append(
|
||||
Item(channel='search' if not config.get_setting('new_search') else 'globalsearch',
|
||||
action="new_search" if not config.get_setting('new_search') else 'Search',
|
||||
title=typo(saved_search_item.split('{}')[0], 'bold'),
|
||||
search_text=saved_search_item.split('{}')[0],
|
||||
text=saved_search_item.split('{}')[0],
|
||||
mode='all',
|
||||
thumbnail=get_thumb('search.png')))
|
||||
else:
|
||||
saved_searches_list.append(Item().fromjson(json.dumps(saved_search_item)))
|
||||
|
||||
return saved_searches_list
|
||||
|
||||
Reference in New Issue
Block a user