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

View File

@@ -55,21 +55,31 @@ def find_and_set_infoLabels(item):
import traceback
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
scraper_result = scraper.find_and_set_infoLabels(item)
if item.exit: return False
# Check if there is a 'code'
elif scraper_result and item.infoLabels['code']:
if scraper_result and item.infoLabels['code']:
# correct code
logger.info("Identifier found: %s " % item.infoLabels['code'])
logger.info("Identificador encontrado: %s" % item.infoLabels['code'])
scraper.completar_codigos(item)
return True
elif scraper_result:
# Content found but no 'code'
msg = config.get_localized_string(60227) % title
else:
# Content not found
logger.info(logger.info("Identifier not found for: %s " % title))
item = platformtools.dialog_info(item, scraper_actual)
if item.exit: return False
msg = config.get_localized_string(60228) % title
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):

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
#if item.tmdb_stat:
# del item.tmdb_stat # We clean the status so that it is not recorded in the Video Library
if item:
new_item = item.clone(action="findvideos")
insertados, sobreescritos, fallidos, path = save_movie(new_item)
# if item:
new_item = item.clone(action="findvideos")
insertados, sobreescritos, fallidos, path = save_movie(new_item)
if fallidos == 0:
platformtools.dialog_ok(config.get_localized_string(30131),
config.get_localized_string(30135) % new_item.contentTitle) # 'has been added to the video library'
else:
filetools.rmdirtree(path)
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")
if fallidos == 0:
platformtools.dialog_ok(config.get_localized_string(30131),
config.get_localized_string(30135) % new_item.contentTitle) # 'has been added to the video library'
else:
filetools.rmdirtree(path)
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")
def add_tvshow(item, channel=None):

View File

@@ -1,17 +1,15 @@
# -*- 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.item import Item
from core import channeltools, servertools, scrapertools
from platformcode import platformtools, config, logger
from platformcode.launcher import run, start
from platformcode.launcher import run
from threading import Thread
if sys.version_info[0] >= 3:
from concurrent import futures
else:
from concurrent_py2 import futures
if sys.version_info[0] >= 3: from concurrent import futures
else: from concurrent_py2 import futures
info_language = ["de", "en", "es", "fr", "it", "pt"] # from videolibrary.json
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
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):
xbmc.executebuiltin('Dialog.Close(all,true)')
SearchWindow('GlobalSearch.xml', config.get_runtime_path()).start(item)
xbmc.sleep(700)
@@ -62,12 +56,10 @@ BACK = 503
# Servers
EPISODESLIST = 200
SERVERLIST = 300
SELECTLIST = 400
class SearchWindow(xbmcgui.WindowXML):
def start(self, item):
logger.info()
xbmc.executebuiltin('Dialog.Close(all,true)')
self.exit = False
self.item = item
self.lastSearch()
@@ -85,6 +77,7 @@ class SearchWindow(xbmcgui.WindowXML):
self.page = 1
self.moduleDict = {}
self.searchActions = []
self.thread = None
self.doModal()
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', '')
else: last_search = ''
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):
logger.info()
@@ -108,12 +101,12 @@ class SearchWindow(xbmcgui.WindowXML):
for result in results:
result = tmdb_info.get_infoLabels(result, origen=result)
self.find.append(result)
movie = result.get('title','')
tvshow = result.get('name','')
title = movie if movie else name
result.mode = 'movie' if movie else 'tvshow'
thumb = 'Infoplus/' + ('movie' if movie else 'tv') + '.png'
title = tvshow if tvshow else movie
result['mode'] = 'tvshow' if tvshow else 'movie'
self.find.append(result)
thumb = 'Infoplus/' + result['mode'].replace('show','') + '.png'
it = xbmcgui.ListItem(title)
it.setProperty('thumb', result.get('thumbnail', thumb))
it.setProperty('fanart', result.get('fanart',''))
@@ -202,10 +195,12 @@ class SearchWindow(xbmcgui.WindowXML):
n = list_cat.index('anime')
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):
channels_list.append(channel)
logger.info('search in channels:',channels_list)
return channels_list
def getModule(self, channel):
@@ -213,7 +208,8 @@ class SearchWindow(xbmcgui.WindowXML):
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'])]
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
except:
import traceback
@@ -248,7 +244,6 @@ class SearchWindow(xbmcgui.WindowXML):
other = []
module = module_dict[channel]
searched_id = item.infoLabels['tmdb_id']
verified = False
try:
results.extend(module.search(search_action, item.text))
@@ -271,14 +266,14 @@ class SearchWindow(xbmcgui.WindowXML):
pass
self.count += 1
if self.item.mode == 'search': self.update(channel, valid + other)
elif self.item.mode == 'all': self.update(channel, results)
else: self.channels.remove(channel)
if self.item.mode == 'all': self.update(channel, results)
else: self.update(channel, valid + other)
def makeItem(self, item):
logger.info()
thumb = item.thumbnail if item.thumbnail else 'Infoplus/' + item.contentType.replace('show','')
it = xbmcgui.ListItem(item.title)
it.setProperty('thumb', item.thumbnail)
it.setProperty('thumb', thumb)
it.setProperty('fanart', item.fanart)
it.setProperty('plot', item.plot)
it.setProperty('verified', item.verified)
@@ -350,6 +345,7 @@ class SearchWindow(xbmcgui.WindowXML):
if self.type:
self.type = None
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.start()
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)]
index = xbmcgui.Dialog().contextmenu(context)
if index > 0: xbmc.executebuiltin(context_commands[index])
elif action in [LEFT, RIGHT] and focus in [CHANNELS]:
items = []
name = self.CHANNELS.getSelectedItem().getLabel()
@@ -407,45 +404,24 @@ class SearchWindow(xbmcgui.WindowXML):
self.RESULTS.addItems(items)
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':
pos = self.RESULTS.getSelectedPosition()
self.CHANNELS.getSelectedItem().setProperty('position', str(pos))
elif action in [BACKSPACE]:
logger.info('ACTION',self.item.mode,self.persons)
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()
self.Back()
elif action in [EXIT]:
self.exit = True
if self.item.mode in ['all', 'search']:
busy(True)
while self.thread.is_alive(): xbmc.sleep(200)
busy(False)
self.close()
self.Close()
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]:
items = []
name = self.CHANNELS.getSelectedItem().getLabel()
@@ -456,6 +432,13 @@ class SearchWindow(xbmcgui.WindowXML):
self.RESULTS.addItems(items)
self.RESULTS.selectItem(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:
pos = self.RESULTS.getSelectedPosition()
@@ -471,11 +454,9 @@ class SearchWindow(xbmcgui.WindowXML):
else:
result = self.find[pos]
name = self.RESULTS.getSelectedItem().getLabel()
item = Item(mode='search', type=result.mode, contentType=result.mode, infoLabels=result, selected = True, text=name)
if self.item.mode == 'movie':
item.contentTitle = self.RESULTS.getSelectedItem().getLabel()
else:
item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
item = Item(mode='search', type=result['mode'], contentType=result['mode'], infoLabels=result, selected = True, text=name)
if self.item.mode == 'movie': item.contentTitle = self.RESULTS.getSelectedItem().getLabel()
else: item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
return Search(item)
elif control_id in [RESULTS, EPISODESLIST]:
@@ -554,4 +535,31 @@ class SearchWindow(xbmcgui.WindowXML):
elif control_id in [SERVERLIST]:
index = int(self.getControl(control_id).getSelectedItem().getProperty('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()

View File

@@ -99,6 +99,7 @@
<width>100%</width>
<height>570</height>
<ondown>101</ondown>
<onup>503</onup>
<orientation>horizontal</orientation>
<scrolltime tween="cubic" easing="out">300</scrolltime>
<itemlayout height="570" width="180">
@@ -146,7 +147,6 @@
</control>
</control> <!-- END Search Result Group -->
<control type="group"> <!-- Chennels Group-->
<description>Chennels Group</description>
<bottom>-100</bottom>
@@ -302,6 +302,8 @@
<left>520</left>
<width>700</width>
<height>570</height>
<onleft>503</onleft>
<onright>503</onright>
<scrolltime tween="cubic" easing="out">300</scrolltime>
<itemlayout height="60" width="700">
<control type="textbox">
@@ -341,7 +343,6 @@
</control> <!-- END Episodes List -->
</control> <!-- END EPISODES GROUP -->
<control type="group"> <!-- SERVERS GROUP-->
<description>Servers Group</description>
<visible allowhiddenfocus="true">Control.IsVisible(3)</visible>
@@ -375,6 +376,8 @@
<left>520</left>
<width>700</width>
<height>570</height>
<onleft>503</onleft>
<onright>503</onright>
<scrolltime tween="cubic" easing="out">300</scrolltime>
<itemlayout height="140" width="700">
<control type="image">
@@ -489,7 +492,7 @@
<shadowcolor>00000000</shadowcolor>
<align>right</align>
<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>
</control>
@@ -523,5 +526,29 @@
<visible allowhiddenfocus="true">Control.IsVisible(5)</visible>
</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>
</window>