Beispiel #1
0
    def __update_title_and_description_with_limitations(self):
        """ Updates the title/name and description with the symbols for DRM, GEO and Paid.

        :return:            (tuple) name postfix, description postfix
        :rtype: tuple[str,str]

        """

        geo_lock = "º"  # º
        drm_lock = "^"       # ^
        paid = "ª"     # ª
        cloaked = "¨"   # ¨
        description_prefix = []
        title_postfix = []

        description = ""
        title = ""

        if self.__expires_datetime is not None:
            expires = "{}: {}".format(MediaItem.ExpiresAt, self.__expires_datetime.strftime("%Y-%m-%d %H:%M"))
            description_prefix.append(expires)

        if self.isDrmProtected:
            title_postfix.append(drm_lock)
            description_prefix.append(
                LanguageHelper.get_localized_string(LanguageHelper.DrmProtected))

        if self.isGeoLocked:
            title_postfix.append(geo_lock)
            description_prefix.append(
                LanguageHelper.get_localized_string(LanguageHelper.GeoLockedId))

        if self.isPaid:
            title_postfix.append(paid)
            description_prefix.append(
                LanguageHelper.get_localized_string(LanguageHelper.PremiumPaid))

        if self.isCloaked:
            title_postfix.append(cloaked)
            description_prefix.append(
                LanguageHelper.get_localized_string(LanguageHelper.HiddenItem))

        if self.uses_external_addon:
            from resources.lib.xbmcwrapper import XbmcWrapper
            external = XbmcWrapper.get_external_add_on_label(self.url)
            title_postfix.append(external)

        # actually update it
        if description_prefix:
            description_prefix = "\n".join(description_prefix)
            description = "[COLOR gold][I]%s[/I][/COLOR]" % (description_prefix.rstrip(), )

        if title_postfix:
            title = "".join(title_postfix)
            title = "[COLOR gold]%s[/COLOR]" % (title.lstrip(), )

        return title, description
Beispiel #2
0
    def get_kodi_item(self):
        """ Creates an Kodi ListItem object for this channel
        
        :return: a Kodi ListItem with all required properties set.
        :rtype: xbmcgui.ListItem

        """

        name = HtmlEntityHelper.convert_html_entities(self.channelName)
        description = HtmlEntityHelper.convert_html_entities(
            self.channelDescription)

        if self.uses_external_addon:
            from resources.lib.xbmcwrapper import XbmcWrapper
            name = "{} {}".format(
                name, XbmcWrapper.get_external_add_on_label(self.addonUrl))

        self.icon = self.__get_image_path(self.icon)
        item = kodifactory.list_item(name, description)
        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.get_full_language(self.language),
                # "Tagline": description,
                "Plot": description
            })

        if self.poster is not None:
            self.poster = self.__get_image_path(self.poster)
            item.setArt({'poster': self.poster})

        if AddonSettings.hide_fanart():
            return item

        if self.fanart is not None:
            self.fanart = self.__get_image_path(self.fanart)
        else:
            self.fanart = Config.fanart
        item.setArt({'fanart': self.fanart})
        return item
Beispiel #3
0
    def __update_title_and_description_with_limitations(self):
        """ Updates the title/name and description with the symbols for DRM, GEO and Paid.

        :return:            (tuple) name postfix, description postfix
        :rtype: tuple[str,str]

        """

        geo_lock = "º"  # º
        drm_lock = "^"  # ^
        paid = "ª"  # ª
        cloaked = "¨"  # ¨
        description_prefix = []
        title_postfix = []

        description = ""
        title = ""

        if self.__expires_datetime is not None:
            expires = "{}: {}".format(
                MediaItem.ExpiresAt,
                self.__expires_datetime.strftime("%Y-%m-%d %H:%M"))
            description_prefix.append(("gold", expires))

        if self.isDrmProtected:
            title_postfix.append(("gold", drm_lock))
            description_prefix.append(("gold",
                                       LanguageHelper.get_localized_string(
                                           LanguageHelper.DrmProtected)))

        if self.isGeoLocked:
            title_postfix.append(("aqua", geo_lock))
            description_prefix.append(("aqua",
                                       LanguageHelper.get_localized_string(
                                           LanguageHelper.GeoLockedId)))

        if self.isPaid:
            title_postfix.append(("gold", paid))
            description_prefix.append(("gold",
                                       LanguageHelper.get_localized_string(
                                           LanguageHelper.PremiumPaid)))

        if self.isCloaked:
            title_postfix.append(("gold", cloaked))
            description_prefix.append(("gold",
                                       LanguageHelper.get_localized_string(
                                           LanguageHelper.HiddenItem)))

        if self.uses_external_addon:
            from resources.lib.xbmcwrapper import XbmcWrapper
            external = XbmcWrapper.get_external_add_on_label(self.url)
            title_postfix.append(("gold", external))

        def __color_text(texts, text_format="[COLOR {}]{}[/COLOR]"):
            """

            :param list[tuple[str, str]] texts:     The color and text (in tuple)
            :param str text_format:                 The format used for filling

            :return: A Kodi compatible color coded string.
            :rtype: str

            See https://forum.kodi.tv/showthread.php?tid=210837
            """

            return "".join([
                text_format.format(clr, text.lstrip()) for clr, text in texts
            ])

        # actually update it
        if description_prefix:
            description = __color_text(description_prefix)

        if title_postfix:
            title = __color_text(title_postfix)

        return title, description