KoD 1.5
-Nuova Ricerca Globale\n-Nuova Rinumerazione\n-Messaggi di Errore più chiari\n-Fix var\n
This commit is contained in:
@@ -1,14 +1,21 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import xbmcgui
|
||||
import xbmcgui, sys
|
||||
|
||||
from core.tmdb import Tmdb
|
||||
from platformcode import config, logger
|
||||
from core import filetools
|
||||
if sys.version_info[0] >= 3:
|
||||
from concurrent import futures
|
||||
else:
|
||||
from concurrent_py2 import futures
|
||||
|
||||
BACKGROUND = 30000
|
||||
LOADING = 30001
|
||||
SELECT = 30002
|
||||
CLOSE = 30003
|
||||
EXIT = 10
|
||||
BACKSPACE = 92
|
||||
|
||||
def imagepath(image):
|
||||
if len(image.split('.')) == 1: image += '.png'
|
||||
@@ -25,23 +32,30 @@ class InfoWindow(xbmcgui.WindowXMLDialog):
|
||||
self.scraper = scraper
|
||||
|
||||
self.doModal()
|
||||
logger.info('RESPONSE',self.response)
|
||||
logger.debug('RESPONSE',self.response)
|
||||
return self.response
|
||||
|
||||
def make_items(self, i, result):
|
||||
infoLabels = self.scraper().get_infoLabels(origen=result)
|
||||
it = xbmcgui.ListItem(infoLabels['title'])
|
||||
it.setProperty('fanart', infoLabels.get('fanart', ''))
|
||||
it.setProperty('thumbnail', infoLabels.get('thumbnail', imagepath('movie' if infoLabels['mediatype'] == 'movie' else 'tv')))
|
||||
it.setProperty('genre', infoLabels.get('genre', 'N/A'))
|
||||
it.setProperty('rating', str(infoLabels.get('rating', 'N/A')))
|
||||
it.setProperty('plot', str(infoLabels.get('plot', '')))
|
||||
it.setProperty('year', str(infoLabels.get('year', '')))
|
||||
it.setProperty('position', str(i))
|
||||
return it
|
||||
|
||||
def onInit(self):
|
||||
if config.get_platform(True)['num_version'] < 18:
|
||||
self.setCoordinateResolution(2)
|
||||
|
||||
for result in self.results:
|
||||
infoLabels = self.scraper().get_infoLabels(origen=result)
|
||||
it = xbmcgui.ListItem(infoLabels['title'])
|
||||
it.setProperty('fanart', infoLabels.get('fanart', ''))
|
||||
it.setProperty('thumbnail', infoLabels.get('thumbnail', imagepath('movie' if infoLabels['mediatype'] == 'movie' else 'tv')))
|
||||
it.setProperty('genre', infoLabels.get('genre', 'N/A'))
|
||||
it.setProperty('rating', str(infoLabels.get('rating', 'N/A')))
|
||||
it.setProperty('plot', str(infoLabels.get('plot', '')))
|
||||
it.setProperty('year', str(infoLabels.get('year', '')))
|
||||
self.items.append(it)
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
for i, result in enumerate(self.results):
|
||||
logger.debug(result)
|
||||
if ('seriesName' in result and result['seriesName']) or ('name' in result and result['name']) or ('title' in result and result['title']):
|
||||
self.items += [executor.submit(self.make_items, i, result).result()]
|
||||
self.items.sort(key=lambda it: int(it.getProperty('position')))
|
||||
|
||||
self.getControl(SELECT).addItems(self.items)
|
||||
self.getControl(BACKGROUND).setImage(self.items[0].getProperty('fanart'))
|
||||
@@ -51,5 +65,16 @@ class InfoWindow(xbmcgui.WindowXMLDialog):
|
||||
def onClick(self, control_id):
|
||||
if control_id == SELECT:
|
||||
self.response = self.results[self.getControl(SELECT).getSelectedPosition()]
|
||||
self.close()
|
||||
self.close()
|
||||
elif control_id == CLOSE:
|
||||
self.close()
|
||||
|
||||
def onAction(self, action):
|
||||
if self.getFocusId() in [SELECT]:
|
||||
fanart = self.getControl(self.getFocusId()).getSelectedItem().getProperty('fanart')
|
||||
self.getControl(BACKGROUND).setImage(fanart)
|
||||
if action in [BACKSPACE]:
|
||||
self.close()
|
||||
elif action in [EXIT]:
|
||||
self.close()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user