Fix nuova ricerca globale

This commit is contained in:
Alhaziel01
2020-11-23 12:33:21 +01:00
parent 096f8dbfe1
commit 9df29b6113
4 changed files with 126 additions and 81 deletions
+17 -7
View File
@@ -55,21 +55,31 @@ def find_and_set_infoLabels(item):
import traceback import traceback
logger.error(traceback.format_exc()) logger.error(traceback.format_exc())
while scraper or not item.exit: while scraper:
# We call the find_and_set_infoLabels function of the selected scraper # We call the find_and_set_infoLabels function of the selected scraper
scraper_result = scraper.find_and_set_infoLabels(item) scraper_result = scraper.find_and_set_infoLabels(item)
if item.exit: return False
# Check if there is a 'code' # Check if there is a 'code'
elif scraper_result and item.infoLabels['code']: if scraper_result and item.infoLabels['code']:
# correct code # correct code
logger.info("Identifier found: %s " % item.infoLabels['code']) logger.info("Identificador encontrado: %s" % item.infoLabels['code'])
scraper.completar_codigos(item) scraper.completar_codigos(item)
return True return True
elif scraper_result:
# Content found but no 'code'
msg = config.get_localized_string(60227) % title
else: else:
# Content not found # Content not found
logger.info(logger.info("Identifier not found for: %s " % title)) msg = config.get_localized_string(60228) % title
item = platformtools.dialog_info(item, scraper_actual)
if item.exit: return False logger.info(msg)
# Show box with other options:
item = platformtools.dialog_info(item, scraper_actual)
if item.exit:
logger.debug("You have clicked 'cancel' in the window '%s'" % msg)
return False
logger.error("Error importing the scraper module %s" % scraper_actual)
def cuadro_completar(item): def cuadro_completar(item):
+10 -10
View File
@@ -1006,17 +1006,17 @@ def add_movie(item):
item = generictools.update_title(item) # We call the method that updates the title with tmdb.find_and_set_infoLabels item = generictools.update_title(item) # We call the method that updates the title with tmdb.find_and_set_infoLabels
#if item.tmdb_stat: #if item.tmdb_stat:
# del item.tmdb_stat # We clean the status so that it is not recorded in the Video Library # del item.tmdb_stat # We clean the status so that it is not recorded in the Video Library
if item: # if item:
new_item = item.clone(action="findvideos") new_item = item.clone(action="findvideos")
insertados, sobreescritos, fallidos, path = save_movie(new_item) insertados, sobreescritos, fallidos, path = save_movie(new_item)
if fallidos == 0: if fallidos == 0:
platformtools.dialog_ok(config.get_localized_string(30131), platformtools.dialog_ok(config.get_localized_string(30131),
config.get_localized_string(30135) % new_item.contentTitle) # 'has been added to the video library' config.get_localized_string(30135) % new_item.contentTitle) # 'has been added to the video library'
else: else:
filetools.rmdirtree(path) filetools.rmdirtree(path)
platformtools.dialog_ok(config.get_localized_string(30131), platformtools.dialog_ok(config.get_localized_string(30131),
config.get_localized_string(60066) % new_item.contentTitle) # "ERROR, the movie has NOT been added to the video library") config.get_localized_string(60066) % new_item.contentTitle) # "ERROR, the movie has NOT been added to the video library")
def add_tvshow(item, channel=None): def add_tvshow(item, channel=None):
+69 -61
View File
@@ -1,17 +1,15 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import xbmc, xbmcgui, xbmcplugin, sys, channelselector, time import xbmc, xbmcgui, sys, channelselector, time
from core.support import dbg, typo, tmdb from core.support import dbg, typo, tmdb
from core.item import Item from core.item import Item
from core import channeltools, servertools, scrapertools from core import channeltools, servertools, scrapertools
from platformcode import platformtools, config, logger from platformcode import platformtools, config, logger
from platformcode.launcher import run, start from platformcode.launcher import run
from threading import Thread from threading import Thread
if sys.version_info[0] >= 3: if sys.version_info[0] >= 3: from concurrent import futures
from concurrent import futures else: from concurrent_py2 import futures
else:
from concurrent_py2 import futures
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")]
@@ -25,12 +23,8 @@ def set_workers():
workers = config.get_setting('thread_number') if config.get_setting('thread_number') > 0 else None workers = config.get_setting('thread_number') if config.get_setting('thread_number') > 0 else None
return workers return workers
def imagepath(image):
if len(image.split('.')) == 1: image += '.png'
path = filetools.join(config.get_runtime_path(), 'resources', 'skins' , 'Default', 'media', 'Infoplus', image)
return path
def Search(item): def Search(item):
xbmc.executebuiltin('Dialog.Close(all,true)')
SearchWindow('GlobalSearch.xml', config.get_runtime_path()).start(item) SearchWindow('GlobalSearch.xml', config.get_runtime_path()).start(item)
xbmc.sleep(700) xbmc.sleep(700)
@@ -62,12 +56,10 @@ BACK = 503
# Servers # Servers
EPISODESLIST = 200 EPISODESLIST = 200
SERVERLIST = 300 SERVERLIST = 300
SELECTLIST = 400
class SearchWindow(xbmcgui.WindowXML): class SearchWindow(xbmcgui.WindowXML):
def start(self, item): def start(self, item):
logger.info() logger.info()
xbmc.executebuiltin('Dialog.Close(all,true)')
self.exit = False self.exit = False
self.item = item self.item = item
self.lastSearch() self.lastSearch()
@@ -85,6 +77,7 @@ class SearchWindow(xbmcgui.WindowXML):
self.page = 1 self.page = 1
self.moduleDict = {} self.moduleDict = {}
self.searchActions = [] self.searchActions = []
self.thread = None
self.doModal() self.doModal()
def lastSearch(self): def lastSearch(self):
@@ -93,7 +86,7 @@ class SearchWindow(xbmcgui.WindowXML):
if config.get_setting('last_search'): last_search = channeltools.get_channel_setting('Last_searched', 'search', '') if config.get_setting('last_search'): last_search = channeltools.get_channel_setting('Last_searched', 'search', '')
else: last_search = '' else: last_search = ''
if not self.item.text: self.item.text = platformtools.dialog_input(default=last_search, heading='') 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') if self.item.text: channeltools.set_channel_setting('Last_searched', self.item.text, 'search')
def select(self): def select(self):
logger.info() logger.info()
@@ -108,12 +101,12 @@ class SearchWindow(xbmcgui.WindowXML):
for result in results: for result in results:
result = tmdb_info.get_infoLabels(result, origen=result) result = tmdb_info.get_infoLabels(result, origen=result)
self.find.append(result)
movie = result.get('title','') movie = result.get('title','')
tvshow = result.get('name','') tvshow = result.get('name','')
title = movie if movie else name title = tvshow if tvshow else movie
result.mode = 'movie' if movie else 'tvshow' result['mode'] = 'tvshow' if tvshow else 'movie'
thumb = 'Infoplus/' + ('movie' if movie else 'tv') + '.png' self.find.append(result)
thumb = 'Infoplus/' + result['mode'].replace('show','') + '.png'
it = xbmcgui.ListItem(title) it = xbmcgui.ListItem(title)
it.setProperty('thumb', result.get('thumbnail', thumb)) it.setProperty('thumb', result.get('thumbnail', thumb))
it.setProperty('fanart', result.get('fanart','')) it.setProperty('fanart', result.get('fanart',''))
@@ -202,10 +195,12 @@ 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 in ['all', 'search'] or (self.item.type in list_cat): if 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)
logger.info('search in channels:',channels_list)
return channels_list return channels_list
def getModule(self, channel): def getModule(self, channel):
@@ -213,7 +208,8 @@ class SearchWindow(xbmcgui.WindowXML):
try: try:
module = __import__('channels.%s' % channel, fromlist=["channels.%s" % channel]) module = __import__('channels.%s' % channel, fromlist=["channels.%s" % channel])
mainlist = getattr(module, 'mainlist')(Item(channel=channel, global_search=True)) 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'])] logger.info('TYPE= ', self.item.type)
action = [elem for elem in mainlist if elem.action == "search" and (self.item.mode == 'all' or elem.contentType in [self.item.type, 'undefined'])]
return module, action return module, action
except: except:
import traceback import traceback
@@ -248,7 +244,6 @@ class SearchWindow(xbmcgui.WindowXML):
other = [] other = []
module = module_dict[channel] module = module_dict[channel]
searched_id = item.infoLabels['tmdb_id'] searched_id = item.infoLabels['tmdb_id']
verified = False
try: try:
results.extend(module.search(search_action, item.text)) results.extend(module.search(search_action, item.text))
@@ -271,14 +266,14 @@ class SearchWindow(xbmcgui.WindowXML):
pass pass
self.count += 1 self.count += 1
if self.item.mode == 'search': self.update(channel, valid + other) if self.item.mode == 'all': self.update(channel, results)
elif self.item.mode == 'all': self.update(channel, results) else: self.update(channel, valid + other)
else: self.channels.remove(channel)
def makeItem(self, item): def makeItem(self, item):
logger.info() logger.info()
thumb = item.thumbnail if item.thumbnail else 'Infoplus/' + item.contentType.replace('show','')
it = xbmcgui.ListItem(item.title) it = xbmcgui.ListItem(item.title)
it.setProperty('thumb', item.thumbnail) it.setProperty('thumb', thumb)
it.setProperty('fanart', item.fanart) it.setProperty('fanart', item.fanart)
it.setProperty('plot', item.plot) it.setProperty('plot', item.plot)
it.setProperty('verified', item.verified) it.setProperty('verified', item.verified)
@@ -350,6 +345,7 @@ class SearchWindow(xbmcgui.WindowXML):
if self.type: if self.type:
self.type = None self.type = None
if self.item.mode in ['all', 'search']: if self.item.mode in ['all', 'search']:
if self.item.type: self.item.mode = self.item.type
self.thread = Thread(target=self.search) self.thread = Thread(target=self.search)
self.thread.start() self.thread.start()
elif self.item.mode in ['movie', 'tvshow']: elif self.item.mode in ['movie', 'tvshow']:
@@ -397,6 +393,7 @@ class SearchWindow(xbmcgui.WindowXML):
"RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel +'&from_action=' + item.action)] "RunPlugin(%s?%s&%s)" % (sys.argv[0], item.tourl(), 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel +'&from_action=' + item.action)]
index = xbmcgui.Dialog().contextmenu(context) index = xbmcgui.Dialog().contextmenu(context)
if index > 0: xbmc.executebuiltin(context_commands[index]) if index > 0: xbmc.executebuiltin(context_commands[index])
elif action in [LEFT, RIGHT] and focus in [CHANNELS]: elif action in [LEFT, RIGHT] and focus in [CHANNELS]:
items = [] items = []
name = self.CHANNELS.getSelectedItem().getLabel() name = self.CHANNELS.getSelectedItem().getLabel()
@@ -407,45 +404,24 @@ class SearchWindow(xbmcgui.WindowXML):
self.RESULTS.addItems(items) self.RESULTS.addItems(items)
self.RESULTS.selectItem(subpos) self.RESULTS.selectItem(subpos)
elif action in [DOWN] and focus in [BACK, CLOSE]:
if self.EPISODES.isVisible(): self.setFocusId(EPISODES)
if self.SERVERS.isVisible(): self.setFocusId(SERVERS)
else: self.setFocusId(RESULTS)
elif focus in [RESULTS] and self.item.mode == 'all': elif focus in [RESULTS] and self.item.mode == 'all':
pos = self.RESULTS.getSelectedPosition() pos = self.RESULTS.getSelectedPosition()
self.CHANNELS.getSelectedItem().setProperty('position', str(pos)) self.CHANNELS.getSelectedItem().setProperty('position', str(pos))
elif action in [BACKSPACE]: elif action in [BACKSPACE]:
logger.info('ACTION',self.item.mode,self.persons) self.Back()
if self.SERVERS.isVisible():
if self.episodes:
self.Focus(EPISODES)
self.setFocusId(EPISODESLIST)
else:
self.Focus(SEARCH)
self.setFocusId(RESULTS)
self.RESULTS.selectItem(self.pos)
elif self.EPISODES.isVisible():
self.Focus(SEARCH)
self.setFocusId(RESULTS)
self.RESULTS.selectItem(self.pos)
elif self.item.mode in ['person'] and self.find:
self.find = []
self.actors()
else:
self.exit = True
if self.item.mode in ['all', 'search']:
busy(True)
while self.thread.is_alive(): xbmc.sleep(200)
busy(False)
self.close()
elif action in [EXIT]: elif action in [EXIT]:
self.exit = True self.Close()
if self.item.mode in ['all', 'search']:
busy(True)
while self.thread.is_alive(): xbmc.sleep(200)
busy(False)
self.close()
def onClick(self, control_id): def onClick(self, control_id):
search = self.RESULTS.getSelectedItem().getProperty('search') if self.RESULTS.getSelectedItem(): search = self.RESULTS.getSelectedItem().getProperty('search')
else: search = None
if control_id in [CHANNELS]: if control_id in [CHANNELS]:
items = [] items = []
name = self.CHANNELS.getSelectedItem().getLabel() name = self.CHANNELS.getSelectedItem().getLabel()
@@ -456,6 +432,13 @@ class SearchWindow(xbmcgui.WindowXML):
self.RESULTS.addItems(items) self.RESULTS.addItems(items)
self.RESULTS.selectItem(subpos) self.RESULTS.selectItem(subpos)
self.CHANNELS.getSelectedItem().setProperty('position', str(subpos)) self.CHANNELS.getSelectedItem().setProperty('position', str(subpos))
self.setFocusId(RESULTS)
elif control_id in [BACK]:
self.Back()
elif control_id in [CLOSE]:
self.Close()
elif search: elif search:
pos = self.RESULTS.getSelectedPosition() pos = self.RESULTS.getSelectedPosition()
@@ -471,11 +454,9 @@ class SearchWindow(xbmcgui.WindowXML):
else: else:
result = self.find[pos] result = self.find[pos]
name = self.RESULTS.getSelectedItem().getLabel() name = self.RESULTS.getSelectedItem().getLabel()
item = Item(mode='search', type=result.mode, contentType=result.mode, infoLabels=result, selected = True, text=name) item = Item(mode='search', type=result['mode'], contentType=result['mode'], infoLabels=result, selected = True, text=name)
if self.item.mode == 'movie': if self.item.mode == 'movie': item.contentTitle = self.RESULTS.getSelectedItem().getLabel()
item.contentTitle = self.RESULTS.getSelectedItem().getLabel() else: item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
else:
item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
return Search(item) return Search(item)
elif control_id in [RESULTS, EPISODESLIST]: elif control_id in [RESULTS, EPISODESLIST]:
@@ -554,4 +535,31 @@ class SearchWindow(xbmcgui.WindowXML):
elif control_id in [SERVERLIST]: elif control_id in [SERVERLIST]:
index = int(self.getControl(control_id).getSelectedItem().getProperty('index')) index = int(self.getControl(control_id).getSelectedItem().getProperty('index'))
server = self.servers[index] server = self.servers[index]
run(server) run(server)
def Back(self):
if self.SERVERS.isVisible():
if self.episodes:
self.Focus(EPISODES)
self.setFocusId(EPISODESLIST)
else:
self.Focus(SEARCH)
self.setFocusId(RESULTS)
self.RESULTS.selectItem(self.pos)
elif self.EPISODES.isVisible():
self.Focus(SEARCH)
self.setFocusId(RESULTS)
self.RESULTS.selectItem(self.pos)
elif self.item.mode in ['person'] and self.find:
self.find = []
self.actors()
else:
self.Close()
def Close(self):
self.exit = True
if self.thread:
busy(True)
while self.thread.is_alive(): xbmc.sleep(200)
busy(False)
self.close()
+30 -3
View File
@@ -99,6 +99,7 @@
<width>100%</width> <width>100%</width>
<height>570</height> <height>570</height>
<ondown>101</ondown> <ondown>101</ondown>
<onup>503</onup>
<orientation>horizontal</orientation> <orientation>horizontal</orientation>
<scrolltime tween="cubic" easing="out">300</scrolltime> <scrolltime tween="cubic" easing="out">300</scrolltime>
<itemlayout height="570" width="180"> <itemlayout height="570" width="180">
@@ -146,7 +147,6 @@
</control> </control>
</control> <!-- END Search Result Group --> </control> <!-- END Search Result Group -->
<control type="group"> <!-- Chennels Group--> <control type="group"> <!-- Chennels Group-->
<description>Chennels Group</description> <description>Chennels Group</description>
<bottom>-100</bottom> <bottom>-100</bottom>
@@ -302,6 +302,8 @@
<left>520</left> <left>520</left>
<width>700</width> <width>700</width>
<height>570</height> <height>570</height>
<onleft>503</onleft>
<onright>503</onright>
<scrolltime tween="cubic" easing="out">300</scrolltime> <scrolltime tween="cubic" easing="out">300</scrolltime>
<itemlayout height="60" width="700"> <itemlayout height="60" width="700">
<control type="textbox"> <control type="textbox">
@@ -341,7 +343,6 @@
</control> <!-- END Episodes List --> </control> <!-- END Episodes List -->
</control> <!-- END EPISODES GROUP --> </control> <!-- END EPISODES GROUP -->
<control type="group"> <!-- SERVERS GROUP--> <control type="group"> <!-- SERVERS GROUP-->
<description>Servers Group</description> <description>Servers Group</description>
<visible allowhiddenfocus="true">Control.IsVisible(3)</visible> <visible allowhiddenfocus="true">Control.IsVisible(3)</visible>
@@ -375,6 +376,8 @@
<left>520</left> <left>520</left>
<width>700</width> <width>700</width>
<height>570</height> <height>570</height>
<onleft>503</onleft>
<onright>503</onright>
<scrolltime tween="cubic" easing="out">300</scrolltime> <scrolltime tween="cubic" easing="out">300</scrolltime>
<itemlayout height="140" width="700"> <itemlayout height="140" width="700">
<control type="image"> <control type="image">
@@ -489,7 +492,7 @@
<shadowcolor>00000000</shadowcolor> <shadowcolor>00000000</shadowcolor>
<align>right</align> <align>right</align>
<aligny>center</aligny> <aligny>center</aligny>
<animation effect="slide" tween="linear" center="auto" end="90,-320" time="200" condition="Integer.IsGreater(Container(101).NumItems, 0)">Conditional</animation> <animation effect="slide" tween="linear" center="auto" end="0,-311" time="200" condition="Integer.IsGreater(Container(101).NumItems, 0)">Conditional</animation>
<visible allowhiddenfocus="true">Control.IsVisible(500)</visible> <visible allowhiddenfocus="true">Control.IsVisible(500)</visible>
</control> </control>
@@ -523,5 +526,29 @@
<visible allowhiddenfocus="true">Control.IsVisible(5)</visible> <visible allowhiddenfocus="true">Control.IsVisible(5)</visible>
</control> </control>
<control type="button" id="503">
<description>Back</description>
<top>30</top>
<right>70</right>
<height>40</height>
<width>40</width>
<onleft>502</onleft>
<onright>502</onright>
<texturefocus colordiffuse="FFFFFFFF">left.png</texturefocus>
<texturenofocus colordiffuse="80FFFFFF">left.png</texturenofocus>
</control>
<control type="button" id="502">
<description>Close</description>
<top>30</top>
<right>30</right>
<height>40</height>
<width>40</width>
<onleft>503</onleft>
<onright>503</onright>
<texturefocus colordiffuse="FFFFFFFF">close.png</texturefocus>
<texturenofocus colordiffuse="80FFFFFF">close.png</texturenofocus>
</control>
</controls> </controls>
</window> </window>