def save_to_file(content, filename, path=""): """ dump json and save to *filename in *path """ if not xbmcvfs.exists(path): xbmcvfs.mkdirs(path) text_file_path = os.path.join(path, filename + ".txt") now = time.time() text_file = xbmcvfs.File(text_file_path, "w") simplejson.dump(content, text_file) text_file.close() logMsg("saved textfile %s. Time: %f" % (text_file_path, time.time() - now)) return True
def get_JSON_response(url="", cache_days=7.0, folder=False, headers=False): """ get JSON response for *url, makes use of file cache. """ now = time.time() hashed_url = hashlib.md5(url).hexdigest() if folder: cache_path = xbmc.translatePath(os.path.join(ADDON_DATA_PATH, folder)) else: cache_path = xbmc.translatePath(os.path.join(ADDON_DATA_PATH)) path = os.path.join(cache_path, hashed_url + ".txt") cache_seconds = int(cache_days * 86400.0) if xbmcvfs.exists(path) and ( (now - os.path.getmtime(path)) < cache_seconds): results = read_from_file(path) logMsg("loaded file for %s. time: %f" % (url, time.time() - now)) else: response = get_http(url, headers) try: results = simplejson.loads(response) logMsg("download %s. time: %f" % (url, time.time() - now)) #save_to_file(results, hashed_url, cache_path) except: logMsg( "Exception: Could not get new JSON data from %s. Tryin to fallback to cache" % url) logMsg(response) if xbmcvfs.exists(path): results = read_from_file(path) else: results = [] if results: return results else: return []
def read_from_file(path="", raw=False): """ return data from file with *path """ if not xbmcvfs.exists(path): return False try: with open(path) as f: logMsg("opened textfile %s." % (path)) if raw: return f.read() else: return simplejson.load(f) except: logMsg("failed to load textfile: " + path) return False
def get_http(url=None, headers=False): """ fetches data from *url, returns it as a string """ succeed = 0 if not headers: headers = {'User-agent': 'XBMC/14.0 ( [email protected] )'} request = urllib2.Request(url) for (key, value) in headers.iteritems(): request.add_header(key, value) while (succeed < 2) and (not xbmc.abortRequested): try: response = urllib2.urlopen(request, timeout=3) data = response.read() return data except: logMsg("get_http: could not get data from %s" % url) xbmc.sleep(1000) succeed += 1 return None
def getyoutubeurl(YoutubeID=None): URLYoutube = None y = YTURL() videoID = y.stripYouTubeURL(YoutubeID) if not y.checkIsValidVideoID(videoID): return None #preferredItags = map(int, sys.argv[2:]) preferredItags = [] availableFormats = y.getVideoItags(videoID) logMsg("youturl availableFormats %s" % availableFormats) if availableFormats is not False: for itag in y.getPreferredItagOrder(preferredItags): if itag in availableFormats: #print availableFormats[itag] URLYoutube = availableFormats[itag] break else: return None return URLYoutube
def MiseAJour(self): saga = "" logMsg( "1 : %s - %s -%s" % (self.mettreajourID, self.mettreajourTYPE, self.mettreajourLABEL)) if not self.mettreajourID: self.mettreajourID = xbmc.getInfoLabel("ListItem.DBID") if not self.mettreajourLABEL: self.mettreajourLABEL = xbmc.getInfoLabel("ListItem.Label") if not self.mettreajourTYPE: self.mettreajourTYPE = xbmc.getInfoLabel("ListItem.DBTYPE") logMsg( "2: %s - %s -%s" % (self.mettreajourID, self.mettreajourTYPE, self.mettreajourLABEL)) if xbmc.getCondVisibility("Container.Content(artists)"): self.mettreajourTYPE = "artist" if (self.mettreajourTYPE == "set" or self.mettreajourTYPE == "movie" or self.mettreajourTYPE == "tvshow" or self.mettreajourTYPE == "artist" or self.mettreajourTYPE == "season" or saga != ""): if saga == "": Unique = "ok" else: Unique = "" if self.mettreajourTYPE != "season": dialog = xbmcgui.Dialog() if self.mettreajourTYPE == "movie": Titre = __skin_string__(342) if self.mettreajourTYPE == "set": Titre = __skin_string__(20434) if self.mettreajourTYPE == "tvshow": Titre = __skin_string__(20343) if self.mettreajourTYPE == "artist": Titre = __skin_string__(36917) if self.mettreajourTYPE != "movie": Choix = [ __language__(32502) + Titre, __language__(32503) + Titre ] else: Choix = [__language__(32510)] if Unique and self.mettreajourID and not self.mettreajourTYPE == "movie": Choix.append( __language__(32507) + " [COLOR=yellow]" + utils.try_decode(self.mettreajourLABEL) + "[/COLOR]") if self.mettreajourTYPE == "set" or self.mettreajourTYPE == "movie" or self.mettreajourTYPE == "tvshow": Choix.append( __language__(32514) + " [COLOR=yellow]" + utils.try_decode(self.mettreajourLABEL) + "[/COLOR]") if self.mettreajourTYPE == "tvshow": Choix.append(__language__(32511)) ret = dialog.select(Titre, Choix) else: ret = 0 if (ret >= 0): self.windowhome.setProperty("IconMixArt", "ok") if ret == 0: #tous if self.mettreajourTYPE == "set": utils.UpdateSagas(0, 1) if self.mettreajourTYPE == "tvshow": utils.UpdateSeries(0, 1) if self.mettreajourTYPE == "movie": utils.updateartworkall("Movies") if self.mettreajourTYPE == "artist": utils.UpdateArtistes(None, 1) if ret == 1: #que les nouveaux ou film unique if self.mettreajourTYPE == "set": utils.UpdateSagas() if self.mettreajourTYPE == "movie": utils.updatemovieartwork(self.mettreajourID) if self.mettreajourTYPE == "tvshow": utils.UpdateSeries() if self.mettreajourTYPE == "artist": utils.UpdateArtistes() if ret == 2 and Unique: #item en cours if self.mettreajourTYPE == "set": utils.UpdateSagas(self.mettreajourID) if self.mettreajourTYPE == "tvshow": utils.UpdateSeries(self.mettreajourID) if self.mettreajourTYPE == "artist": utils.UpdateArtistes(self.mettreajourID) if ret == 3 and Unique: #ArtWorks if self.mettreajourTYPE == "set": utils.UpdateSagas(self.mettreajourID, None, True) if self.mettreajourTYPE == "tvshow": utils.updatetvartwork(self.mettreajourID) if ret == 4 and Unique: #ArtWorks if self.mettreajourTYPE == "tvshow": utils.updateartworkall("TvShows") self.windowhome.clearProperty("IconMixArt")
def get_predictions(self, search_str): """ get dict list with autocomplete labels from locally saved lists """ self.listitems = [] json_result = "" json_result2 = "" Donnees = None MaxItems = 50 RecherchePartout = xbmc.getCondVisibility( "Skin.HasSetting(AutoCompleteTous)") if self.PurgeCache and SETTING("autocomplete_cache") == "true": logMsg("purge_cache ") self.create_cache() if len(search_str) > 3: if SETTING("autocomplete_cache") == "true": if not self.PurgeCache: self.create_cache() #logMsg("basetype (%s)" %self.basetype) #if self.basetype=="videos" or RecherchePartout: if not xbmc.getCondVisibility("Window.IsVisible(10040)"): if RecherchePartout or xbmc.getCondVisibility( "Skin.HasSetting(AutoCompleteFilms)"): json_result = utils.GetCache(search_str, cache_path + "films") if json_result: self.createlistitems(json_result, "movie") if RecherchePartout or xbmc.getCondVisibility( "Skin.HasSetting(AutoCompletetvshows)"): json_result = utils.GetCache(search_str, cache_path + "tvshows") if json_result: self.createlistitems(json_result, "tvshow") #http://127.0.0.1:8080/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.GetEpisodes","params":{"limits":{"end":2},"filter":{"field":"title","operator":"contains","value":"the"},"properties":["title","tvshowid"]},"id":"1"} json_result = utils.GetCache(search_str, cache_path + "episodes") if json_result: self.createlistitems(json_result, "episode") if RecherchePartout or xbmc.getCondVisibility( "Skin.HasSetting(AutoCompleteActeurs)"): #http://127.0.0.1:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"videodb://movies/actors","limits":{"end":4}},"id":1} json_result = utils.GetCache(search_str, cache_path + "acteurs") if json_result: ListeActorsMovie = [] ListeActorsTvShow = [] recherche = search_str.lower() for item in json_result: if recherche in item["label"].lower(): if item.get("actormovieid"): ListeActorsMovie.append({ "actormovieid": item.get("actormovieid"), "label": item["label"] }) if item.get("actortvshowid"): ListeActorsTvShow.append({ "actortvshowid": item.get("actortvshowid"), "label": item["label"] }) if len(ListeActorsMovie) > 0: self.createlistitems(ListeActorsMovie, "actormovie") if len(ListeActorsTvShow) > 0: self.createlistitems(ListeActorsTvShow, "actortvshow") #json_result = utils.getJSON("Files.GetDirectory", '{"directory":"videodb://tvshows/actors"}') """ json_result=utils.GetCache("") if json_result: ListeActors=[] recherche=search_str.lower() for item in json_result: if recherche in item["label"].lower(): ListeActors.append({"actortvshowid":item.get("id"),"label":item["label"]}) if len(ListeActors)>0: self.createlistitems(ListeActors,"actortvshow") """ if RecherchePartout or xbmc.getCondVisibility( "Skin.HasSetting(AutoCompleteRealisateurs)"): #http://127.0.0.1:8080/jsonrpc?request={"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"videodb://movies/directors","limits":{"end":4}},"id":1} json_result = utils.GetCache(search_str, cache_path + "realisateurs") if json_result: Listedirectors = [] recherche = search_str.lower() for item in json_result: if recherche in item["label"].lower(): Listedirectors.append({ "directormovieid": item.get("directormovieid"), "label": item["label"] }) if len(Listedirectors) > 0: self.createlistitems(Listedirectors, "directormovie") #json_result = utils.getJSON("Files.GetDirectory", '{"directory":"videodb://tvshows/directors"}') """ json_result=utils.GetCache(search_str,cache_path+"realisateurs") if json_result: Listedirectors=[] recherche=search_str.lower() for item in json_result: if recherche in item["label"].lower(): Listedirectors.append({"directortvshowid":item.get("id"),"label":item["label"]}) if len(Listedirectors)>0: self.createlistitems(Listedirectors,"directortvshow") """ #if self.basetype=="music" or RecherchePartout: #http://127.0.0.1:8080/jsonrpc?request={"jsonrpc":"2.0","method":"AudioLibrary.GetArtists","params":{"limits":{"end":2},"filter":{"field":"artist","operator":"contains","value":"madon"}},"id":"1"} #http://127.0.0.1:8080/jsonrpc?request={"jsonrpc":"2.0","method":"AudioLibrary.GetAlbums","params":{"limits":{"end":2},"filter":{"field":"album","operator":"contains","value":"Fear"}},"id":"1"} if RecherchePartout or xbmc.getCondVisibility( "Skin.HasSetting(AutoCompleteArtistes)"): json_result = utils.GetCache(search_str, cache_path + "artistes") if json_result: self.createlistitems(json_result, "artist") if RecherchePartout or xbmc.getCondVisibility( "Skin.HasSetting(AutoCompleteAlbums)"): json_result = utils.GetCache(search_str, cache_path + "albums") if json_result: self.createlistitems(json_result, "album") else: json_result = utils.GetCache(search_str, cache_path + "addons") if json_result: self.createlistitems(json_result, "addon") #logMsg("Items (%s)" %self.listitems) LL = [] #if (SETTING("autocomplete_tri")=="titre" or xbmc.getCondVisibility("Skin.HasSetting(AutoCompleteTriTitre)")) and not xbmc.getCondVisibility("Skin.HasSetting(AutoCompleteTriCategorie)"): if xbmc.getCondVisibility("Skin.HasSetting(AutoCompleteTriTitre)"): #LL=sorted(self.listitems,key=operator.itemgetter('label')) LL = sorted(self.listitems, key=lambda x: (x['label'])) #logMsg("tri par titre") else: #LL=sorted(self.listitems,key=operator.itemgetter('dbtype')) LL = sorted(self.listitems, key=lambda x: (x['dbtype'], x['label'])) #logMsg("tri par categorie") return LL
def GetTrailer(self): #xbmc.executebuiltin( "ActivateWindow(busydialog)" ) self.windowhome.setProperty('FenetreListeChoix', '1') dialog = xbmcgui.Dialog() self.TrailerType = "" self.ListeTrailer = [] ContainerID = None Saison = None TMDBID = '' TMDBIDListe = [] PanneauActeur = None TMDBIDListeAllocine = [] self.TrailerType = "" if self.trailerTitre: TypeVideo = self.trailerTypeVideo PanneauActeur = True Titre = self.trailerTitre Annee = self.trailerAnnee KODIID = self.trailerKODIID IMDBID = self.trailerIMDBID TMDBID = self.trailerTMDBID self.TrailerType = "dialogplus" if not TMDBID: TMDBID = utils.get_externalID(IMDBID, TypeVideo) else: TypeVideo = xbmc.getInfoLabel("ListItem.DBType") Annee = xbmc.getInfoLabel("ListItem.Year") Titre = xbmc.getInfoLabel("ListItem.Label").decode( 'utf-8', 'ignore') Saison = None if self.windowhome.getProperty('IconmixShowInfo') == "1": ContainerID = 1990 else: if self.windowhome.getProperty('IconmixShowInfo') == "2": if not xbmc.getCondVisibility( "ControlGroup(7003).HasFocus"): ContainerID = 5051 else: ContainerID = 1990 else: ContainerID = None if TypeVideo == "episode": Saison = str(xbmc.getInfoLabel("ListItem.Season")) if TypeVideo == "set": self.TrailerType = "videonavsaga" if xbmc.getCondVisibility("Control.HasFocus(7779)"): PanneauActeur = True TypeVideo = xbmc.getInfoLabel( "Container(5051).ListItem.Property(dbtype)") Titre = xbmc.getInfoLabel( "Container(5051).ListItem.Label").decode( 'utf-8', 'ignore') Annee = xbmc.getInfoLabel("Container(5051).ListItem.Year") KODIID = xbmc.getInfoLabel("Container(5051).ListItem.DBID") self.TrailerType = "Roles" if xbmc.getCondVisibility( "Control.HasFocus(2999)" ): #myvideonav elements (saga,acteurs,realisateurs) TypeVideo = xbmc.getInfoLabel( "Container(1999).ListItem.DBType") Titre = xbmc.getInfoLabel( "Container(1999).ListItem.Label").decode( 'utf-8', 'ignore') Annee = xbmc.getInfoLabel("Container(1999).ListItem.Year") self.TrailerType = "videonav" if xbmc.getCondVisibility( "Control.HasFocus(2008)"): #dialogvideoinfo TypeVideo = 'movie' Titre = xbmc.getInfoLabel( "Container(5002).ListItem.Label").decode( 'utf-8', 'ignore') Annee = xbmc.getInfoLabel("Container(5002).ListItem.Year") self.TrailerType = "saga" if xbmc.getCondVisibility("ControlGroup(442).HasFocus" ): #dialogvideoinfo cherche trailer logMsg("ContainerID (%s)" % (ContainerID)) TypeVideo = xbmc.getInfoLabel( "Container(%d).ListItem.DBTYPE" % (ContainerID)) if ContainerID else xbmc.getInfoLabel( "ListItem.DBTYPE") Titre = xbmc.getInfoLabel( "Container(%d).ListItem.Label" % (ContainerID)) if ContainerID else xbmc.getInfoLabel( "ListItem.Label") Titre = Titre.decode('utf-8', 'ignore') Annee = xbmc.getInfoLabel( "Container(%d).ListItem.Year" % (ContainerID)) if ContainerID else xbmc.getInfoLabel( "ListItem.Year") self.TrailerType = "videoinfo7003" if xbmc.getCondVisibility( "Control.HasFocus(7778)"): #dialogvideoinfo realisateur TypeVideo = xbmc.getInfoLabel( "Container(5052).ListItem.DBTYPE") Titre = xbmc.getInfoLabel("Container(5052).ListItem.Label") Titre = Titre.decode('utf-8', 'ignore') Annee = xbmc.getInfoLabel("Container(5052).ListItem.Year") self.TrailerType = "realisateur" if self.TrailerType == "Roles": #acteurs IMDBID = xbmc.getInfoLabel( "Container(5051).ListItem.Property(IMDBNumber)") TMDBID = xbmc.getInfoLabel( "Container(5051).ListItem.Property(TMDBNumber)") if not TMDBID: TMDBID = utils.get_externalID(IMDBID, TypeVideo) if self.TrailerType == "realisateur": #realisateur IMDBID = xbmc.getInfoLabel( "Container(5052).ListItem.Property(IMDBNumber)") TMDBID = xbmc.getInfoLabel( "Container(5052).ListItem.Property(TMDBNumber)") KODIID = xbmc.getInfoLabel("Container(5052).ListItem.DBID") PanneauActeur = True if not TMDBID: TMDBID = utils.get_externalID(IMDBID, TypeVideo) if self.TrailerType == "videonav": #VideoNav IMDBID = xbmc.getInfoLabel( "Container(1999).ListItem.Property(IMDBNumber)") TMDBID = xbmc.getInfoLabel( "Container(1999).ListItem.Property(TMDBNumber)") KODIID = xbmc.getInfoLabel("Container(1999).ListItem.DBID") if not TMDBID and not IMDBID: json_result = utils.getJSON( 'VideoLibrary.Get%sDetails' % (TypeVideo), '{ "%sid":%d,"properties":["imdbnumber"] }' % (TypeVideo, int(xbmc.getInfoLabel( "Container(1999).ListItem.DBID")))) IMDBID = json_result.get("imdbnumber") if TMDBID == '' and IMDBID: TMDBID = utils.get_externalID(IMDBID, TypeVideo) if self.TrailerType == "videonavsaga": #VideoNav TypeVideo = "movie" zz = int(xbmc.getInfoLabel("Container(1999).NumItems")) #logMsg("SagaType (%s)(%s)" %(zz,xbmc.getInfoLabel("Container(1999).NumItems")),0) compteur = 0 for compteur in range(0, zz): #SagaItem=ListeSaga.getListItem(cpt) #IMDBID=SagaItem.getProperty(IMDBNumber) #TMDBID=SagaItem.getProperty(TMDBNumber) #DBID=SagaItem.getProperty(DBID) IMDBID = xbmc.getInfoLabel( "Container(1999).ListItemAbsolute(%d).Property(IMDBNumber)" % (compteur)) TMDBID = xbmc.getInfoLabel( "Container(1999).ListItemAbsolute(%d).Property(TMDBNumber)" % (compteur)) DBID = xbmc.getInfoLabel( "Container(1999).ListItemAbsolute(%d).Property(DBID)" % (compteur)) LABEL = xbmc.getInfoLabel( "Container(1999).ListItemAbsolute(%d).Label" % (compteur)) YEAR = xbmc.getInfoLabel( "Container(1999).ListItemAbsolute(%d).Year" % (compteur)) TMDBIDListeAllocine.append({"Titre": LABEL, "Annee": YEAR}) #logMsg("Allocine (%d)(%s)(%s)(%s)(%s)(%s)" %(compteur,LABEL,YEAR,IMDBID,TMDBID,DBID),0) if DBID: if not TMDBID and not IMDBID: json_result = utils.getJSON( 'VideoLibrary.GetMovieDetails', '{ "movieid":%d,"properties":["imdbnumber"] }' % (int(DBID))) IMDBID = json_result.get("imdbnumber") if TMDBID or IMDBID: TMDBIDListe.append({ "tmdbid": TMDBID, "imdbid": IMDBID }) if self.TrailerType == "saga": #SAGA IMDBID = xbmc.getInfoLabel( "Container(5002).ListItem.Property(IMDBNumber)") TMDBID = xbmc.getInfoLabel( "Container(5002).ListItem.Property(TMDBNumber)") KODIID = xbmc.getInfoLabel("Container(5002).ListItem.DBID") if not TMDBID and not IMDBID: json_result = utils.getJSON( 'VideoLibrary.GetMovieDetails', '{ "movieid":%d,"properties":["imdbnumber"] }' % (int(xbmc.getInfoLabel( "Container(5002).ListItem.DBID")))) IMDBID = json_result.get("imdbnumber") else: if not TMDBID: TMDBID = utils.get_externalID(IMDBID, 'movie') if self.TrailerType == "videoinfo7003" or self.TrailerType == "": #acteurs videoinfo KODIID = xbmc.getInfoLabel( "Container(%d).ListItem.DBID" % (ContainerID)) if ContainerID else xbmc.getInfoLabel( "ListItem.DBID") TMDBID = xbmc.getInfoLabel( "Container(%d).ListItem.Property(TMDBNumber)" % (ContainerID)) if ContainerID else xbmc.getInfoLabel( "ListItem.Property(TMDBNumber)") if TypeVideo != "episode": IMDBNUMBER = xbmc.getInfoLabel( "Container(%d).ListItem.IMDBNumber" % (ContainerID)) if ContainerID else xbmc.getInfoLabel( "ListItem.IMDBNumber") else: IMDBNUMBER = xbmc.getInfoLabel( "Container(%d).ListItem.TVShowTitle" % (ContainerID)) if ContainerID else xbmc.getInfoLabel( "ListItem.TVShowTitle") Titre = IMDBNUMBER if not TMDBID: TMDBID = utils.get_externalID(IMDBNUMBER, TypeVideo) logMsg("self.TrailerType (%s) : (%s)(%s)(%s)(%s)" % (Titre, IMDBNUMBER, TypeVideo, TMDBID, ContainerID)) dialog.notification( 'IconMixTools', __language__(32508) + ": [COLOR=Yellow] " + Titre + "[/COLOR]", ADDON_ICON, 500) if TMDBID != '' or len(TMDBIDListe) > 0: xbmc.executebuiltin("ActivateWindow(busydialog)") logMsg("self.TrailerType (%s) : (%s)(%s)(%s)(%s)(%s)" % (self.TrailerType, Titre, TypeVideo, TMDBID, ContainerID, KODIID)) if len(TMDBIDListe) > 0: #logMsg("SagaType TMDBIDListe %s" %(TMDBIDListe),0) #start_time = time.time() if ADDON.getSetting('allocineactif') == "true": self.ListeTrailer = self.ListeTrailer + utils.GetSagaTrailersAllocine( TMDBIDListeAllocine) if ADDON.getSetting('youtubeactif') == "true": self.ListeTrailer = self.ListeTrailer + utils.GetSagaTrailers( TMDBIDListe) else: self.ListeTrailer = utils.getTrailer(TMDBID, TypeVideo, Saison) if not self.ListeTrailer: self.ListeTrailer = [] self.GetAllocineTrailer(Titre, Annee, TypeVideo, PanneauActeur) if self.TrailerType == "videonav" and KODIID != "": self.ListeTrailer.append({ "id": xbmc.getInfoLabel( "Container(1999).ListItem.FilenameAndPath"), "position": "0", "iso_639_1": "", "iso_3166_1": "", "key": "KODI", "name": xbmc.getLocalizedString(208) + "[I]" + "[COLOR=LightGrey] " + xbmc.getInfoLabel( "Container(1999).ListItem.Label").decode("utf8") + " [/I][/COLOR]", "site": "YouTube", "size": xbmc.getInfoLabel( "Container(1999).ListItem.VideoResolution"), "type": "", "landscape": xbmc.getInfoLabel("Container(1999).ListItem.Art(thumb)") }) if self.TrailerType == "saga" and KODIID != "": self.ListeTrailer.append({ "id": xbmc.getInfoLabel( "Container(5002).ListItem.FilenameAndPath"), "position": "0", "iso_639_1": "", "iso_3166_1": "", "key": "KODI", "name": xbmc.getLocalizedString(208) + "[I]" + "[COLOR=LightGrey] " + xbmc.getInfoLabel( "Container(5002).ListItem.Label").decode("utf8") + " [/I][/COLOR]", "site": "YouTube", "size": xbmc.getInfoLabel( "Container(5002).ListItem.VideoResolution"), "type": "", "landscape": xbmc.getInfoLabel("Container(5002).ListItem.Art(thumb)") }) if self.TrailerType == "videoinfo7003" and ContainerID and KODIID != "": self.ListeTrailer.append({ "id": xbmc.getInfoLabel( "Container(%d).ListItem.FilenameAndPath" % (ContainerID)), "position": "0", "iso_639_1": "", "iso_3166_1": "", "key": "KODI", "name": xbmc.getLocalizedString(208) + "[I]" + "[COLOR=LightGrey] " + xbmc.getInfoLabel("Container(%d).ListItem.Label" % (ContainerID)).decode("utf8") + " [/I][/COLOR]", "site": "YouTube", "size": xbmc.getInfoLabel( "Container(%d).ListItem.VideoResolution" % (ContainerID)), "type": "", "landscape": xbmc.getInfoLabel("Container(%d).ListItem.Art(thumb)" % (ContainerID)) }) if self.TrailerType == "videoinfo7003" and not ContainerID and KODIID != "": self.ListeTrailer.append({ "id": xbmc.getInfoLabel("ListItem.FilenameAndPath"), "position": "0", "iso_639_1": "", "iso_3166_1": "", "key": "KODI", "name": xbmc.getLocalizedString(208) + "[I]" + "[COLOR=LightGrey] " + xbmc.getInfoLabel("ListItem.Label").decode("utf8") + " [/I][/COLOR]", "site": "YouTube", "size": xbmc.getInfoLabel("ListItem.VideoResolution"), "type": "", "landscape": xbmc.getInfoLabel("ListItem.Art(thumb)") }) if self.TrailerType == "Roles" and KODIID != "": self.ListeTrailer.append({ "id": xbmc.getInfoLabel( "Container(5051).ListItem.FilenameAndPath"), "position": "0", "iso_639_1": "", "iso_3166_1": "", "key": "KODI", "name": xbmc.getLocalizedString(208) + "[I]" + "[COLOR=LightGrey] " + xbmc.getInfoLabel( "Container(5051).ListItem.Label").decode("utf8") + " [/I][/COLOR]", "site": "YouTube", "size": xbmc.getInfoLabel( "Container(5051).ListItem.VideoResolution"), "type": "", "landscape": xbmc.getInfoLabel("Container(5051).ListItem.Art(thumb)") }) if self.TrailerType == "realisateur" and KODIID != "": self.ListeTrailer.append({ "id": xbmc.getInfoLabel("ListItem.FilenameAndPath"), "position": "0", "iso_639_1": "", "iso_3166_1": "", "key": "KODI", "name": xbmc.getLocalizedString(208) + "[I]" + "[COLOR=LightGrey] " + xbmc.getInfoLabel("ListItem.Label").decode("utf8") + " [/I][/COLOR]", "site": "YouTube", "size": xbmc.getInfoLabel("ListItem.VideoResolution"), "type": "", "landscape": xbmc.getInfoLabel("ListItem.Art(thumb)") }) xbmc.executebuiltin("Dialog.Close(busydialog)") if len(self.ListeTrailer) > 0: ListeNomTrailer = [] Image = "" for Item in self.ListeTrailer: NomTrailer = None try: Image = urllib.unquote( Item.get("landscape").replace("image://", "")) except: Image = "" logMsg("erreur : %s" % (Item), 0) try: NomTrailer = utils.try_decode( Item["name"]) + " [" + utils.try_decode( Item["type"]) + " - " + str( Item["size"]) + "p - " + utils.try_decode( Item["iso_3166_1"] + "]") except: NomTrailer = utils.try_decode(Item["type"]) + ' [' + str( Item.get("size")) + 'p - ' + utils.try_decode( Item["iso_3166_1"]) + ']' Elements = xbmcgui.ListItem(label=NomTrailer, iconImage=str(Image), label2="selectionnevue") Elements.setProperty("Icon", Image) Elements.setProperty("Source", Item["key"]) ListeNomTrailer.append(Elements) if len(ListeNomTrailer) > 0: self.ui = MainService.dialog_select_UI( 'choix.xml', ADDON_PATH, 'default', '1080i', listing=ListeNomTrailer, trailers=self.ListeTrailer, ItemId=xbmc.getInfoLabel("ListItem.DBID")) self.windowhome.setProperty("IconMixTrailer", "1") ret = self.ui.doModal() del self.ui self.windowhome.clearProperty('IconMixTrailer') else: # dialog = xbmcgui.Dialog() dialog.notification('IconMixTools', Titre + ": " + __language__(32506), "acteurs/arfffff.png", 500) self.windowhome.setProperty('FenetreListeChoix', '') #retour au focus précédent retour = { "": 2008, "videonav": 2999, "realisateur": 7778, "videoinfo7003": 7003, "dialogplus": 7003, "videonavsaga": 2008, "Roles": 7779 } xbmc.executebuiltin("SetFocus(%d)" % (retour[self.TrailerType]))