# -*- coding: utf-8 -*- # ------------------------------------------------------------ # infoplus ventana con información del Item # ------------------------------------------------------------ import re from threading import Thread import xbmc import xbmcaddon import xbmcgui from core import httptools from core import scrapertools from core import tmdb from core.item import Item from core.scrapertools import decodeHtmlentities as dhe from platformcode import config, logger from platformcode import platformtools addon = xbmcaddon.Addon('metadata.themoviedb.org') def_lang = addon.getSetting('language') global mainWindow mainWindow = list() ActoresWindow = None TrailerWindow = None relatedWindow = None imagesWindow = None ActorInfoWindow = None BusquedaWindow = None SearchWindows = list() exit_loop = False ACTION_SHOW_FULLSCREEN = 36 ACTION_GESTURE_SWIPE_LEFT = 511 ACTION_SELECT_ITEM = 7 ACTION_PREVIOUS_MENU = 10 ACTION_MOVE_LEFT = 1 ACTION_MOVE_RIGHT = 2 ACTION_MOVE_DOWN = 4 ACTION_MOVE_UP = 3 set_animation = False xinfoplus_set = config.get_setting("infoplus_set") if xinfoplus_set == config.get_localized_string(70129): set_animation = False if xinfoplus_set == config.get_localized_string(70130): set_animation = True def start(item, recomendaciones=[], from_window=False): if from_window: global relatedWindow, ActorInfoWindow, ActoresWindow, BusquedaWindow, TrailerWindow, imagesWindow create = [relatedWindow, ActorInfoWindow, ActoresWindow, BusquedaWindow, TrailerWindow, imagesWindow] for window in create: window = None global exit_loop exit_loop = False global SearchWindows SearchWindows = list() dialog = platformtools.dialog_progress(config.get_localized_string(60469), config.get_localized_string(60470)) principal_window = main(item=item, recomendaciones=recomendaciones, dialog=dialog, from_window=from_window) try: mainWindow.append(principal_window) principal_window.doModal() except: return class main(xbmcgui.WindowDialog): def __init__(self, *args, **kwargs): self.item = kwargs.get('item') self.recomendaciones = kwargs.get('recomendaciones') self.dialog = kwargs.get('dialog') self.from_window = kwargs.get('from_window') if self.item.contentType == "movie": tipo = "película" tipo_busqueda = "movie" icono = "http://imgur.com/SenkyxF.png" else: tipo = "serie" tipo_busqueda = "tv" icono = "http://s6.postimg.cc/hzcjag975/tvdb.png" if self.item.rating_filma: if "|" in self.item.show: self.item.show = "" self.infoLabels = self.item.info icono = self.item.icon rating_fa = self.item.rating_filma if tipo == "película": self.infoLabels["tmdb_id"] = self.item.extra.split("|")[1] else: self.infoLabels["tmdb_id"] = self.item.extra.split("|")[2] rating = self.infoLabels.get("rating") titulo = self.infoLabels["title"] self.images = [] thread1 = None else: info_copy = dict(self.item.infoLabels) self.item.infoLabels.pop("season", None) self.item.infoLabels.pop("episode", None) if not self.item.infoLabels["year"]: self.dialog.close() platformtools.dialog_notification(config.get_localized_string(60471), config.get_localized_string(60472) % tipo) global mainWindow self.close() del mainWindow return tmdb.set_infoLabels_item(self.item, True) self.infoLabels = self.item.infoLabels self.infoLabels["season"] = info_copy.get("season", None) self.infoLabels["episode"] = info_copy.get("episode", None) if not self.infoLabels["tmdb_id"]: self.dialog.close() platformtools.dialog_notification(config.get_localized_string(60473), config.get_localized_string(60474) % tipo) global mainWindow self.close() del mainWindow return titulo = "[COLOR olive][B]%s[/B][/COLOR]" % self.infoLabels.get("title") try: if not self.infoLabels.get("rating"): rating = "[COLOR crimson][B]N/A[/B][/COLOR]" elif self.infoLabels.get("rating") >= 5 and self.infoLabels.get("rating") < 8: rating = "[COLOR springgreen][B]%s[/B][/COLOR]" % self.infoLabels["rating"] elif self.infoLabels.get("rating") >= 8: rating = "[COLOR yellow][B]%s[/B][/COLOR]" % self.infoLabels["rating"] else: rating = "[COLOR crimson][B]%s[/B][/COLOR]" % self.infoLabels["rating"] except: rating = "[COLOR crimson][B]%s[/B][/COLOR]" % self.infoLabels["rating"] self.dialog.update(40, config.get_localized_string(60475)) rating_fa, plot_fa = get_filmaf(self.item, self.infoLabels) if not self.infoLabels.get("plot") and plot_fa: self.infoLabels["plot"] = "[COLOR moccasin][B]%s[/B][/COLOR]" % plot_fa elif not self.infoLabels["plot"]: self.infoLabels["plot"] = config.get_localized_string(60476) else: self.infoLabels["plot"] = "[COLOR moccasin][B]%s[/B][/COLOR]" % self.infoLabels.get("plot") self.dialog.update(60, config.get_localized_string(60477)) thread1 = Thread(target=get_recomendations, args=[self.item, self.infoLabels, self.recomendaciones]) thread1.setDaemon(True) thread1.start() if self.infoLabels.get("status") == "Ended" and tipo == "serie": status = config.get_localized_string(60478) elif self.infoLabels.get("status") and tipo == "serie": status = config.get_localized_string(60479) else: status = "[COLOR aquamarine][B]%s[/B][/COLOR]" if self.infoLabels.get("tagline") and tipo == "serie": self.infoLabels["tagline"] = status % "(" + self.infoLabels["tagline"] + ")" elif not self.infoLabels.get("tagline") and tipo == "serie": self.infoLabels["tagline"] = status % config.get_localized_string(60480) % self.infoLabels.get("number_of_seasons", "---") else: self.infoLabels["tagline"] = status % self.infoLabels.get("tagline", "") self.images = {} thread2 = Thread(target=fanartv, args=[self.item, self.infoLabels, self.images]) thread2.setDaemon(True) thread2.start() if self.infoLabels["tmdb_id"]: otmdb = tmdb.Tmdb(id_Tmdb=self.infoLabels["tmdb_id"], tipo=tipo_busqueda) self.infoLabels["images"] = otmdb.result.get("images", {}) for key, value in self.infoLabels["images"].items(): if not value: self.infoLabels["images"].pop(key) if not self.infoLabels.get("originaltitle"): self.infoLabels["originaltitle"] = otmdb.result.get("original_title", otmdb.result.get("original_name", "")) self.trailers = otmdb.get_videos() if otmdb.result.get("runtime", 0): self.infoLabels["duration"] = int(otmdb.result.get("runtime", 0)) else: self.trailers = [] if self.item.contentType != "movie": self.dialog.update(60, config.get_localized_string(60481)) try: ###Busca música serie titulo = re.sub('\[.*?\]', '', titulo) titulo = self.infoLabels.get("originaltitle", titulo) titulo = re.sub("'", "", titulo) url_tvthemes = "http://televisiontunes.com/search.php?q=%s" % titulo.replace(' ', '+') data = httptools.downloadpage(url_tvthemes).data page_theme = scrapertools.find_single_match(data, '.*?
(.*?)
') if info: bio = dhe(scrapertools.htmlclean(info.strip())) try: info_list = [] while bio: info_list.append(bio[:1900]) bio = bio[1900:] bio = [] threads = {} for i, info_ in enumerate(info_list): t = Thread(target=translate, args=[info_, "es", "en", i, bio]) t.setDaemon(True) t.start() threads[i] = t while threads: for key, t in threads.items(): if not t.isAlive(): threads.pop(key) xbmc.sleep(100) if bio: bio.sort(key=lambda x: x[0]) biography = "" for i, b in bio: biography += b actor_tmdb.result["biography"] = dhe(biography) else: bio = dhe(scrapertools.htmlclean(info.strip())) actor_tmdb.result["biography"] = dhe(bio) except: bio = dhe(scrapertools.htmlclean(info.strip())) actor_tmdb.result["biography"] = bio else: actor_tmdb.result["biography"] = config.get_localized_string(60504) elif not actor_tmdb.result.get("biography"): actor_tmdb.result["biography"] = "Sin información" #### Compatibilidad con Kodi 18 #### if config.get_platform(True)['num_version'] < 18: self.setCoordinateResolution(2) self.background = xbmcgui.ControlImage(30, -5, 1250, 730, 'http://imgur.com/7ccBX3g.png') self.addControl(self.background) if set_animation: self.background.setAnimations( [('conditional', 'effect=fade start=0% end=100% delay=2000 time=1500 condition=true',), ('WindowClose', 'effect=slide end=0,-700% time=1000 condition=true',)]) self.filmo = xbmcgui.ControlImage(330, 470, 230, 45, 'http://s6.postimg.cc/rlktamqhd/filmography1.png') self.addControl(self.filmo) if set_animation: self.filmo.setAnimations([('conditional', 'effect=zoom start=0,700 end=100% center=auto delay=5500 time=1000 condition=true tween=elastic',), ('WindowClose', 'effect=zoom start=100% end=0% time=1000 condition=true',)]) self.title = xbmcgui.ControlTextBox(470, 30, 730, 250) self.addControl(self.title) if set_animation: self.title.setAnimations( [('conditional', 'effect=slide start=-1500% end=0% delay=3000 time=1500 condition=true',), ('WindowClose', 'effect=slide end=1500% time=1000 condition=true',)]) self.title.setText(self.nombre) self.info_actor = xbmcgui.ControlTextBox(470, 70, 750, 400) self.addControl(self.info_actor) if set_animation: self.info_actor.setAnimations( [('conditional', 'effect=slide start=2000% end=-10% delay=5300 time=1500 tween=bounce condition=true',), ('WindowClose', 'effect=slide end=-2000% time=1000 condition=true',)]) try: self.info_actor.autoScroll(7000, 6000, 30000) except: xbmc.executebuiltin( config.get_localized_string(70500)) self.info_actor.setText( "[COLOR coral][B]%s[/B][/COLOR]" % actor_tmdb.result.get("biography", config.get_localized_string(60504))) self.titulos = [] tipo_busqueda = "cast" if self.job != "actor": tipo_busqueda = "crew" ids = [] for entradas in actor_tmdb.result.get("%s_credits" % tipo, {}).get(tipo_busqueda, []): if entradas["id"] in ids: continue else: ids.append(entradas["id"]) thumb = "https://image.tmdb.org/t/p/original" if entradas["poster_path"]: thumb += entradas["poster_path"] else: thumb = "http://s6.postimg.cc/tw1vhymj5/noposter.png" if self.item.contentType == "movie": self.titulos.append([entradas["id"], entradas.get("title", entradas.get("original_title", "")), thumb]) else: self.titulos.append([entradas["id"], entradas.get("title", entradas.get("original_title", "")), thumb]) self.dialog.update(40, config.get_localized_string(60505)) self.mas_pelis = 8 self.idps = [] self.botones = [] self.botones_maspelis = [] self.focus = -1 i = 0 count = 0 self.btn_left = xbmcgui.ControlButton(90, 490, 70, 29, '', "http://s6.postimg.cc/i3pnobu6p/redarrow.png", "http://s6.postimg.cc/i3pnobu6p/redarrow.png") self.addControl(self.btn_left) if set_animation: self.btn_left.setAnimations([('conditional', 'effect=zoom start=720,642,70,29 end=640,642,69,29 time=1000 loop=true tween=bounce condition=Control.HasFocus(' + str( self.btn_left.getId()) + ')',), ('WindowClose', 'effect=fade end=0% time=1000 condition=true',)]) self.btn_left.setVisible(False) self.botones.append(self.btn_left) for idp, peli, foto in self.titulos: if count % 8 == 0: i = 0 self.image = xbmcgui.ControlButton(65 + i, 538, 135, 160, '', foto, foto) self.neon = xbmcgui.ControlImage(60 + i, 525, 145, 186, "http://s6.postimg.cc/x0jspnxch/buttons.png") fadelabel = xbmcgui.ControlFadeLabel(67 + i, 698, 135, 50) self.botones.append(self.image) if count < 8: self.addControl(self.image) if set_animation: self.image.setAnimations([('conditional', 'effect=rotatey start=200 end=0 delay=2000 time=900 tween=elastic condition=true',), ('unfocus', 'effect=zoom center=auto start=70% end=100% time=700 reversible=false',), ( 'focus', 'effect=rotate center=auto start=0% end=360% time=650 tween=bounce',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',), ]) self.addControl(self.neon) self.neon.setVisibleCondition('[Control.HasFocus(' + str(self.image.getId()) + ')]') if set_animation: self.neon.setAnimations([('conditional', 'effect=rotate center=auto start=0% end=360% time=650 tween=bounce condition=Control.HasFocus(' + str( self.image.getId()) + ')',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',), ]) self.addControl(fadelabel) fadelabel.addLabel(peli) if set_animation: fadelabel.setAnimations([('conditional', 'effect=rotatey start=200 end=0 delay=6200 time=900 tween=elastic condition=true',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',)]) self.idps.append([self.image, peli, idp, foto]) self.botones_maspelis.append([self.image, self.neon, fadelabel, peli]) i += 150 count += 1 xbmc.sleep(200) if len(self.titulos) > 8: self.btn_right = xbmcgui.ControlButton(1150, 495, 60, 27, '', "http://s6.postimg.cc/j4uhr70k1/greenarrow.png", "http://s6.postimg.cc/j4uhr70k1/greenarrow.png") self.addControl(self.btn_right) if set_animation: self.btn_right.setAnimations( [('conditional', 'effect=slide start=-3000 end=0 delay=5000 time=2000 condition=true tween=bounce',), ( 'conditional', 'effect=zoom start=230,490, 60, 27, 29 end=1230,642,61,27 time=1000 loop=true tween=bounce condition=Control.HasFocus(' + str( self.btn_right.getId()) + ')',), ('WindowClose', 'effect=fade end=0% time=1000 condition=true',)]) self.botones.append(self.btn_right) xbmc.sleep(200) self.dialog.update(80, config.get_localized_string(60506)) self.images = [] for images in actor_tmdb.result.get("images", {}).get("profiles", []): imagen = "https://image.tmdb.org/t/p/original" + images["file_path"] self.images.append(imagen) if len(self.images) <= 1 or (len(self.images) == 2 and self.images[0] == self.images[1]): self.marco = xbmcgui.ControlImage(100, 23, 330, 425, 'http://s6.postimg.cc/nkmk7b8nl/marco_foto2_copia.png') self.addControl(self.marco) if set_animation: self.marco.setAnimations( [('conditional', 'effect=rotatey start=100% end=0% delay=2400 time=1500 condition=true',), ('WindowClose', 'effect=fade end=0% time=1000 condition=true',)]) self.thumb = xbmcgui.ControlImage(115, 40, 294, 397, self.thumbnail) self.addControl(self.thumb) if set_animation: self.thumb.setAnimations( [('conditional', 'effect=rotatey start=100% end=0% delay=2380 time=1500 condition=true',), ('WindowClose', 'effect=fade end=0% time=1000 condition=true',)]) xbmc.sleep(300) else: self.start_change = False self.th = Thread(target=self.change_image) self.th.setDaemon(True) self.th.start() self.dialog.close() def change_image(self): global exit_loop imagenes = [] while True: xbmc.sleep(100) for i, image in enumerate(self.images): xbmc.sleep(400) if i == 0: xbmc.sleep(300) self.marco = xbmcgui.ControlImage(100, 23, 330, 425, 'http://s6.postimg.cc/nkmk7b8nl/marco_foto2_copia.png') self.thumb = xbmcgui.ControlImage(115, 40, 294, 397, "") xbmc.sleep(500) self.addControl(self.marco) if set_animation: self.marco.setAnimations( [('conditional', 'effect=rotatey start=100% end=0% delay=2300 time=1500 condition=true',), ('WindowClose', 'effect=fade end=0% time=1000 condition=true',)]) self.addControl(self.thumb) self.thumb.setImage(self.thumbnail) if set_animation: self.thumb.setAnimations( [('conditional', 'effect=rotatey start=100% end=0% delay=2280 time=1500 condition=true',), ('WindowClose', 'effect=fade end=0% time=1000 condition=true',)]) xbmc.sleep(4000) for img in imagenes: self.removeControls([img[0], img[1]]) imagenes = [] imagenes.append([self.thumb, self.marco]) if exit_loop: break if exit_loop: break if i > 0: if exit_loop: break xbmc.sleep(5200) self.marco = xbmcgui.ControlImage(100, 23, 330, 425, 'http://s6.postimg.cc/4syg4krkh/marco_foto.png') self.addControl(self.marco) if set_animation: self.marco.setAnimations( [('conditional', 'effect=rotatey start=100% end=0% delay=300 time=1500 condition=true',), ('WindowClose', 'effect=fade end=0% time=1000 condition=true',)]) self.thumb = xbmcgui.ControlImage(115, 40, 294, 397, "") self.addControl(self.thumb) self.thumb.setImage(image, True) if set_animation: self.thumb.setAnimations( [('conditional', 'effect=rotatey start=100% end=0% delay=285 time=1500 condition=true',), ('WindowClose', 'effect=fade end=0% time=1000 condition=true',)]) imagenes.append([self.thumb, self.marco]) xbmc.sleep(400) if exit_loop: break logger.info("salimos carajo xD") def onAction(self, action): global exit_loop if exit_loop: exit_loop = False if action == ACTION_MOVE_RIGHT or action == ACTION_MOVE_DOWN: if self.focus < len(self.botones) - 1: self.focus += 1 while True: id_focus = str(self.botones[self.focus].getId()) if xbmc.getCondVisibility('[Control.IsVisible(' + id_focus + ')]'): self.setFocus(self.botones[self.focus]) break self.focus += 1 if self.focus == len(self.botones): break if action == ACTION_MOVE_LEFT or action == ACTION_MOVE_UP: if self.focus > 0: self.focus -= 1 while True: id_focus = str(self.botones[self.focus].getId()) if xbmc.getCondVisibility('[Control.IsVisible(' + id_focus + ')]'): self.setFocus(self.botones[self.focus]) break self.focus -= 1 if self.focus == len(self.botones): break if action == ACTION_PREVIOUS_MENU or action == ACTION_GESTURE_SWIPE_LEFT or action == 110 or action == 92: exit_loop = True self.close() if action == 105 or action == 6: for boton, peli, id, poster2 in self.idps: try: if self.getFocusId() == boton.getId() and self.btn_right: self.focus = len(self.botones) - 1 xbmc.executebuiltin('SendClick(%s)' % self.btn_right.getId()) except: pass if action == 104 or action == 5: for boton, peli, id, poster2 in self.idps: try: if self.getFocusId() == boton.getId() and self.btn_left: self.setFocus(self.btn_left) xbmc.executebuiltin('SendClick(%s)' % self.btn_left.getId()) except: pass def onControl(self, control): try: if control == self.btn_right: i = 1 count = 0 for afoto, neon, fadelabel, peli in self.botones_maspelis: if i > self.mas_pelis - 8 and i <= self.mas_pelis and count < 8: self.removeControls([afoto, neon, fadelabel]) count += 1 elif i > self.mas_pelis and count < 16: self.addControl(afoto) if set_animation: afoto.setAnimations([('conditional', 'effect=rotatey start=200 end=0 time=900 delay=200 tween=elastic condition=true',), ('unfocus', 'effect=zoom center=auto start=70% end=100% time=700 reversible=false',), ('focus', 'effect=rotate center=auto start=0% end=360% time=650 tween=bounce',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',), ]) self.addControl(neon) neon.setVisibleCondition('[Control.HasFocus(' + str(afoto.getId()) + ')]') if set_animation: neon.setAnimations([('conditional', 'effect=rotate center=auto start=0% end=360% time=650 tween=bounce condition=Control.HasFocus(' + str( afoto.getId()) + ')',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',), ]) self.addControl(fadelabel) fadelabel.addLabel(peli) if set_animation: fadelabel.setAnimations( [('conditional', 'effect=rotatey start=200 end=0 time=900 tween=elastic condition=true',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',)]) count += 1 self.mas_pelis += 1 xbmc.sleep(120) i += 1 if self.mas_pelis > 8 and self.mas_pelis < 17: self.btn_left.setVisible(True) if len(self.botones_maspelis) < self.mas_pelis + 1: self.btn_right.setVisible(False) self.btn_right.setVisible(False) self.setFocus(self.btn_left) self.focus = 4 else: self.focus = len(self.botones) - 1 self.setFocus(self.btn_right) xbmc.sleep(300) except: pass try: if control == self.btn_left: i = 1 count = 0 if self.mas_pelis == len(self.botones_maspelis): self.btn_right.setVisible(True) len_pelis = self.mas_pelis for afoto, neon, fadelabel, peli in self.botones_maspelis: resta = 8 + (len_pelis % 8) if resta == 8: resta = 16 resta2 = len_pelis % 8 if not resta2: resta2 = 8 if i > len_pelis - resta and count < 8: self.addControl(afoto) if set_animation: afoto.setAnimations( [('conditional', 'effect=rotatey start=200 end=0 time=900 tween=elastic condition=true',), ('unfocus', 'effect=zoom center=auto start=70% end=100% time=700 reversible=false',), ('focus', 'effect=rotate center=auto start=0% end=360% time=650 tween=bounce',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',), ]) self.addControl(neon) neon.setVisibleCondition('[Control.HasFocus(' + str(afoto.getId()) + ')]') if set_animation: neon.setAnimations([('conditional', 'effect=rotate center=auto start=0% end=360% time=650 tween=bounce condition=Control.HasFocus(' + str( afoto.getId()) + ')',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',), ]) self.addControl(fadelabel) fadelabel.addLabel(peli) if set_animation: fadelabel.setAnimations( [('conditional', 'effect=rotatey start=200 end=0 time=900 tween=elastic condition=true',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',)]) count += 1 elif i > len_pelis - resta2 and i <= len_pelis and count < 16: self.removeControls([afoto, neon, fadelabel]) count += 1 self.mas_pelis -= 1 i += 1 if self.mas_pelis == 8: self.btn_left.setVisible(False) except: pass for boton, peli, id, poster2 in self.idps: if control == boton: dialog = platformtools.dialog_progress(config.get_localized_string(60486), config.get_localized_string(60487)) tipo = self.item.contentType if tipo != "movie": tipo = "tv" new_tmdb = tmdb.Tmdb(id_Tmdb=id, tipo=tipo) new_infolabels = new_tmdb.get_infoLabels() new_infolabels["cast"] = new_tmdb.result.get("credits_cast", []) new_infolabels["crew"] = new_tmdb.result.get("credits_crew", []) new_infolabels["created_by"] = new_tmdb.result.get("created_by", []) global relatedWindow relatedWindow = related(item=self.item, infolabels=new_infolabels, fonts=self.fonts, dialog=dialog) relatedWindow.doModal() class images(xbmcgui.WindowDialog): def __init__(self, *args, **kwargs): self.fanartv = kwargs.get("fanartv", {}) self.tmdb = kwargs.get("tmdb", {}) self.imdb = kwargs.get("imdb", []) self.fa = kwargs.get("fa", []) self.mal = kwargs.get("mal", []) self.imagenes = [] for key, value in self.tmdb.iteritems(): for detail in value: self.imagenes.append('http://image.tmdb.org/t/p/w342' + detail["file_path"]) for tipo, child in self.fanartv.iteritems(): for imagen in child: self.imagenes.append(imagen["url"].replace("/fanart/", "/preview/")) for imagen, title in self.fa: self.imagenes.append(imagen) for imagen in self.imdb: self.imagenes.append(imagen["src"]) for imagen, title in self.mal: self.imagenes.append(imagen) #### Compatibilidad con Kodi 18 #### if config.get_platform(True)['num_version'] < 18: self.setCoordinateResolution(2) self.shadow = xbmcgui.ControlImage(245, 10, 1011, 700, 'http://imgur.com/66VSLTo.png') self.addControl(self.shadow) if set_animation: self.shadow.setAnimations( [('conditional', 'effect=slide start=1000% delay=672 time=2500 condition=true',), ('WindowClose', 'effect=slide end=0 time=1000 condition=true',)]) imagen_inicial = self.imagenes[0].replace("/preview/", "/fanart/").replace("-s200", "-large").replace("/w342/", "/original/") self.background = xbmcgui.ControlImage(248, 17, 1003, 560, imagen_inicial, 2) self.addControl(self.background) if set_animation: self.background.setAnimations( [('conditional', 'effect=slide start=1000% delay=670 time=2500 condition=true',), ('WindowClose', 'effect=slide end=0 time=1000 condition=true',)]) self.botones = [] self.imgcount = 8 self.urls = [] self.botones_imgs = [] self.focus = -1 i = 0 count = 0 self.btn_left = xbmcgui.ControlButton(293, 550, 70, 29, '', "http://s6.postimg.cc/i3pnobu6p/redarrow.png", "http://s6.postimg.cc/i3pnobu6p/redarrow.png") self.addControl(self.btn_left) if set_animation: self.btn_left.setAnimations( [('conditional', 'effect=zoom start=-100 end=100 delay=5000 time=2000 condition=true tween=bounce',), ( 'conditional', 'effect=zoom start=293,642,70,29 end=243,642,69,29 time=1000 loop=true tween=bounce condition=Control.HasFocus(' + str( self.btn_left.getId()) + ')',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',)]) self.btn_left.setVisible(False) self.botones.append(self.btn_left) for img in self.imagenes: img = img.replace(" ", "%20") if count % 8 == 0: i = 0 self.image = xbmcgui.ControlButton(280 + i, 590, 100, 98, '', img, img) self.neon = xbmcgui.ControlImage(280 + i, 590, 100, 98, "http://s6.postimg.cc/x0jspnxch/buttons.png") self.botones.append(self.image) if count < 8: self.addControl(self.image) if set_animation: self.image.setAnimations([('conditional', 'effect=rotatey start=200 end=0 delay=3500 time=900 tween=elastic condition=true',), ('unfocus', 'effect=zoom center=auto start=70% end=100% time=700 reversible=false',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',)]) self.addControl(self.neon) self.neon.setVisibleCondition('[Control.HasFocus(' + str(self.image.getId()) + ')]') if set_animation: self.neon.setAnimations([('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',)]) self.urls.append([self.image, img]) self.botones_imgs.append([self.image, self.neon]) i += 120 count += 1 xbmc.sleep(200) if len(self.imagenes) > 8: self.btn_right = xbmcgui.ControlButton(1150, 550, 60, 27, '', "http://s6.postimg.cc/j4uhr70k1/greenarrow.png", "http://s6.postimg.cc/j4uhr70k1/greenarrow.png") self.addControl(self.btn_right) if set_animation: self.btn_right.setAnimations( [('conditional', 'effect=slide start=-3000 end=0 delay=3600 time=2000 condition=true tween=bounce',), ( 'conditional', 'effect=zoom start=230,490, 60, 27, 29 end=1190,642,61,27 time=1000 loop=true tween=bounce condition=Control.HasFocus(' + str( self.btn_right.getId()) + ')',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',)]) self.botones.append(self.btn_right) xbmc.sleep(200) def onAction(self, action): if action == ACTION_PREVIOUS_MENU or action == ACTION_GESTURE_SWIPE_LEFT or action == 110 or action == 92: self.close() if action == ACTION_MOVE_RIGHT or action == ACTION_MOVE_DOWN: if self.focus < len(self.botones) - 1: self.focus += 1 while True: id_focus = str(self.botones[self.focus].getId()) if xbmc.getCondVisibility('[Control.IsVisible(' + id_focus + ')]'): self.setFocus(self.botones[self.focus]) break self.focus += 1 if self.focus == len(self.botones): break if action == ACTION_MOVE_LEFT or action == ACTION_MOVE_UP: if self.focus > 0: self.focus -= 1 while True: id_focus = str(self.botones[self.focus].getId()) if xbmc.getCondVisibility('[Control.IsVisible(' + id_focus + ')]'): self.setFocus(self.botones[self.focus]) break self.focus -= 1 if self.focus == len(self.botones): break if action == 105 or action == 6: for image, neon in self.botones_imgs: try: if self.getFocusId() == image.getId() and self.btn_right: self.focus = len(self.botones) - 1 xbmc.executebuiltin('SendClick(%s)' % self.btn_right.getId()) except: pass if action == 104 or action == 5: for image, neon in self.botones_imgs: try: if self.getFocusId() == image.getId() and self.btn_left: self.focus = 0 xbmc.executebuiltin('SendClick(%s)' % self.btn_left.getId()) except: pass def onControl(self, control): try: if control == self.btn_right: i = 1 count = 0 for image, neon in self.botones_imgs: if i > self.imgcount - 8 and i <= self.imgcount and count < 8: self.removeControls([image, neon]) count += 1 elif i > self.imgcount and count < 16: self.addControl(image) if set_animation: image.setAnimations([('conditional', 'effect=rotatey start=200 end=0 delay=600 time=900 tween=elastic condition=true',), ('unfocus', 'effect=zoom center=auto start=70% end=100% time=700 reversible=false',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',)]) self.addControl(neon) neon.setVisibleCondition('[Control.HasFocus(' + str(image.getId()) + ')]') if set_animation: neon.setAnimations([('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',)]) count += 1 self.imgcount += 1 xbmc.sleep(120) i += 1 if self.imgcount > 8 and self.imgcount < 17: self.btn_left.setVisible(True) if len(self.botones_imgs) < self.imgcount + 1: self.btn_right.setVisible(False) self.focus = -1 xbmc.executebuiltin('Action(Right)') xbmc.sleep(300) except: pass try: if control == self.btn_left: i = 1 count = 0 if self.imgcount == len(self.botones_imgs): self.btn_right.setVisible(True) len_images = self.imgcount for image, neon in self.botones_imgs: resta = 8 + (len_images % 8) if resta == 8: resta = 16 resta2 = len_images % 8 if not resta2: resta2 = 8 if i > len_images - resta and count < 8: self.addControl(image) if set_animation: image.setAnimations([('conditional', 'effect=rotatey start=200 end=0 delay=600 time=900 tween=elastic condition=true',), ('unfocus', 'effect=zoom center=auto start=70% end=100% time=700 reversible=false',), ('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',)]) self.addControl(neon) neon.setVisibleCondition('[Control.HasFocus(' + str(image.getId()) + ')]') if set_animation: neon.setAnimations([('WindowClose', 'effect=slide end=0,700% time=1000 condition=true',)]) count += 1 elif i > len_images - resta2 and i <= len_images and count < 16: self.removeControls([image, neon]) count += 1 self.imgcount -= 1 i += 1 if self.imgcount == 8: self.btn_left.setVisible(False) self.setFocus(self.botones[1]) else: self.setFocus(self.btn_left) except: pass for boton, url in self.urls: if control == boton: if "fanart.tv" in url: url = url.replace("/preview/", "/fanart/") elif "filmaffinity" in url: url = url.replace("-s200", "-large") elif "image.tmdb" in url: url = url.replace("/w342/", "/original/") self.background.setImage(url.replace(" ", "%20")) class Trailer(xbmcgui.WindowXMLDialog): def Start(self, item, trailers): self.item = item from specials import trailertools self.video_url, self.windows = trailertools.buscartrailer(self.item.clone(), trailers=trailers) self.doModal() def onInit(self): #### Compatibilidad con Kodi 18 #### if config.get_platform(True)['num_version'] < 18: self.setCoordinateResolution(0) if not self.video_url: platformtools.dialog_notification(config.get_localized_string(60507), config.get_localized_string(60508), 2) self.close() elif self.video_url == "no_video": self.close() else: new_video = False while True: if new_video: self.doModal() xlistitem = xbmcgui.ListItem(path=self.video_url, thumbnailImage=self.item.thumbnail) pl = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) pl.clear() pl.add(self.video_url, xlistitem) self.player = xbmc.Player() self.player.play(pl, windowed=True) while xbmc.Player().isPlaying(): xbmc.sleep(1000) self.close() self.video_url = None new_video = True self.windows[-1].doModal() try: self.video_url = self.windows[-1].result if not self.video_url: break except: break def onAction(self, action): if action == ACTION_PREVIOUS_MENU or action == ACTION_GESTURE_SWIPE_LEFT or action == 110 or action == 92: self.player.stop() self.close() elif action == ACTION_MOVE_LEFT: xbmc.executebuiltin('PlayerControl(Rewind)') elif action == ACTION_MOVE_RIGHT: xbmc.executebuiltin('PlayerControl(Forward)') elif action == ACTION_SELECT_ITEM: xbmc.executebuiltin('PlayerControl(Play)') elif action == 199 or action == ACTION_SHOW_FULLSCREEN or action == 9: xbmc.log("tuprimalafachaaa") if action == 13: self.close() def onClick(self, control): if control == self.getControl(2): self.player.pause() def get_recomendations(item, infoLabels, recomendaciones): tipo = item.contentType if tipo != "movie": tipo = "tv" search = {'url': '%s/%s/recommendations' % (tipo, infoLabels['tmdb_id']), 'language': def_lang, 'page': 1} reco_tmdb = tmdb.Tmdb(discover=search, tipo=tipo, idioma_busqueda="es") for i in range(0, len(reco_tmdb.results)): titulo = reco_tmdb.results[i].get("title", reco_tmdb.results[i].get("original_title", "")) if not titulo: titulo = reco_tmdb.results[i].get("name", reco_tmdb.results[i].get("original_name", "")) idtmdb = str(reco_tmdb.results[i].get("id")) thumbnail = reco_tmdb.results[i].get("poster_path", "") if thumbnail: thumbnail = 'http://image.tmdb.org/t/p/original' + thumbnail recomendaciones.append([idtmdb, titulo, thumbnail]) def get_filmaf(item, infoLabels): title = infoLabels["title"].replace(" ", "+") year = str(infoLabels.get("year", "")) url = "http://www.filmaffinity.com/es/advsearch.php?stext={0}&stype%5B%5D=title&country=&genre=&fromyear={1}&toyear={1}".format( title, year) data = httptools.downloadpage(url).data tipo = "película" if item.contentType != "movie": tipo = "serie" url_filmaf = scrapertools.find_single_match(data, '