def ShowCategories(self): """Displays the ShowCategories that are currently available in XOT as a directory listing. """ Logger.Info("Plugin::ShowCategories") channelRegister = ChannelImporter.GetRegister() categories = channelRegister.GetCategories() xbmcItems = [] icon = os.path.join(Config.rootDir, "icon.png") fanart = os.path.join(Config.rootDir, "fanart.jpg") for category in categories: name = LanguageHelper.GetLocalizedCategory(category) xbmcItem = xbmcgui.ListItem(name, name) # set art try: xbmcItem.setIconImage(icon) except: # it was deprecated pass xbmcItem.setArt({'thumb': icon, 'icon': icon}) if not AddonSettings.HideFanart(): xbmcItem.setArt({'fanart': fanart}) url = self.__CreateActionUrl(None, action=self.actionListCategory, category=category) xbmcItems.append((url, xbmcItem, True)) Logger.Trace(xbmcItems) ok = xbmcplugin.addDirectoryItems(self.handle, xbmcItems, len(xbmcItems)) xbmcplugin.addSortMethod(handle=self.handle, sortMethod=xbmcplugin.SORT_METHOD_LABEL) xbmcplugin.endOfDirectory(self.handle, ok) return ok
def GetXBMCItem(self): """ Creates an Xbmc ListItem object for this channel """ name = HtmlEntityHelper.ConvertHTMLEntities(self.channelName) description = HtmlEntityHelper.ConvertHTMLEntities(self.channelDescription) self.icon = self.__GetImagePath(self.icon) item = xbmcgui.ListItem(name, description) try: item.setIconImage(self.icon) except: # it was deprecated pass item.setArt({'thumb': self.icon, 'icon': self.icon}) # http://mirrors.kodi.tv/docs/python-docs/14.x-helix/xbmcgui.html#ListItem-setInfo item.setInfo("video", {"Title": name, # "Count": self.sortOrderPerCountry, # "TrackNumber": self.sortOrder, "Genre": LanguageHelper.GetFullLanguage(self.language), # "Tagline": description, "Plot": description}) if AddonSettings.HideFanart(): return item if self.fanart is not None: self.fanart = self.__GetImagePath(self.fanart) else: self.fanart = os.path.join(Config.rootDir, "fanart.jpg") item.setArt({'fanart': self.fanart}) return item
def GetXBMCItem(self, name=None): """Creates an XBMC item with the same data is the MediaItem. Keyword Arguments: name : [opt] string - Overwrites the name of the XBMC item. Returns: A complete XBMC ListItem This item is used for displaying purposes only and changes to it will not be passed on to the MediaItem. Eventually the self.UpdateXBMCItem is called to set all the parameters. For the mapping and Encoding of MediaItem properties to XBMCItem properties the __doc__ can be used. """ # Update name and descriptions namePostFix, descriptionPostFix = self.__UpdateTitleAndDescriptionWithLimitations( ) name = self.__GetTitle(name) name = "%s%s" % (name, namePostFix) name = self.__FullDecodeText(name) if self.description is None: self.description = '' description = "%s%s" % (self.description.lstrip(), descriptionPostFix) description = self.__FullDecodeText(description) if description is None: description = "" # the XBMC ListItem date # date : string (%d.%m.%Y / 01.01.2009) - file date if self.__timestamp > datetime.datetime.min: xbmcDate = self.__timestamp.strftime("%d.%m.%Y") xbmcYear = self.__timestamp.year else: xbmcDate = "" xbmcYear = 0 # Get all the info labels starting with the ones set and then add the specific ones infoLabels = self.__infoLabels.copy() infoLabels["Label"] = name infoLabels["Title"] = name if xbmcDate: infoLabels["Date"] = xbmcDate infoLabels["Year"] = xbmcYear if self.type != "audio": # infoLabels["PlotOutline"] = description infoLabels["Plot"] = description # if descriptionPostFix: # infoLabels["Tagline"] = descriptionPostFix.lstrip() # now create the XBMC item item = xbmcgui.ListItem(name or "<unknown>", self.__date) item.setLabel(name) item.setLabel2(self.__date) # set a flag to indicate it is a item that can be used with setResolveUrl. if self.IsResolvable(): Logger.Trace("Setting IsPlayable to True") item.setProperty("IsPlayable", "true") # specific items Logger.Trace("Setting InfoLabels: %s", infoLabels) if self.type == "audio": item.setInfo(type="Audio", infoLabels=infoLabels) else: item.setInfo(type="Video", infoLabels=infoLabels) try: item.setIconImage(self.icon) except: # it was deprecated pass # now set all the art to prevent duplicate calls to Kodi if self.fanart and not AddonSettings.HideFanart(): item.setArt({ 'thumb': self.thumb, 'icon': self.icon, 'fanart': self.fanart }) else: item.setArt({'thumb': self.thumb, 'icon': self.icon}) # art = dict() # for l in ("thumb", "poster", "banner", "fanart", "clearart", "clearlogo", "landscape"): # art[l] = self.thumb # item.setArt(art) # We never set the content resolving, Retrospect does this. And if we do, then the custom # headers are removed from the URL when opening the resolved URL. try: item.setContentLookup(False) except: # apparently not yet supported on this Kodi version3 pass return item