def __get_title(self, name): """ Create the title based on the MediaItems name and type. :param str name: the name to update. :return: an updated name :rtype: str """ if not name: name = self.name if self.type == 'page': # We need to add the Page prefix to the item name = "%s %s" % (LanguageHelper.get_localized_string( LanguageHelper.Page), name) Logger.debug("MediaItem.__get_title :: Adding Page Prefix") elif self.__date != '' and not self.is_playable( ) and not AddonSettings.is_min_version(18): # not playable items should always show date name = "%s [COLOR=dimgray](%s)[/COLOR]" % (name, self.__date) folder_prefix = AddonSettings.get_folder_prefix() if self.type == "folder" and not folder_prefix == "": name = "%s %s" % (folder_prefix, name) return name
def get_verifiable_video_url(self, url): """ Creates an RTMP(E) url that can be verified using an SWF URL. Returns a new URL that includes the self.swfUrl in the form of "url --swfVfy|-W swfUrl". If self.swfUrl == "", the original URL is returned. :param str url: The URL that should be made verifiable. :return: A new URL that includes the self.swfUrl :rtype: str """ if self.swfUrl == "": return url # TODO: Kodi 17.x also accepts an SWF-url as swfvfy option (https://www.ffmpeg.org/ffmpeg-protocols.html#rtmp). # This option should be set via the XbmcListItem.setProperty, so within Retrospect via: # part.add_property("swfvfy", self.swfUrl) # Or as an URL parameter swfvfy where we add the full URL instead of just 1: # return "%s swfvfy=%s" % (url, self.swfUrl) if AddonSettings.is_min_version(17): Logger.debug("Using Kodi 17+ RTMP parameters") return "%s swfvfy=%s" % (url, self.swfUrl) else: Logger.debug("Using Legacy (Kodi 16 and older) RTMP parameters") return "%s swfurl=%s swfvfy=1" % (url, self.swfUrl)
def show_country_settings(self): """ Shows the country settings page where channels can be shown/hidden based on the country of origin. """ if AddonSettings.is_min_version(18): AddonSettings.show_settings(-99) else: AddonSettings.show_settings(101) self.refresh()
def __set_kodi_proxy_info(self, kodi_item, stream, stream_url, kodi_params, proxy): """ Updates a Kodi ListItem with the correct Proxy configuration taken from the ProxyInfo object. :param xbmcgui.ListItem kodi_item: The current Kodi ListItem. :param MediaStream stream: The current Stream object. :param str stream_url: The current Url for the Stream object (might have been changed in the mean time by other calls) :param dict[str|unicode,str] kodi_params: A dictionary of Kodi Parameters. :param ProxyInfo proxy: The ProxyInfo object """ if not proxy: return if proxy.Scheme.startswith( "http") and not stream.Url.startswith("http"): Logger.debug("Not adding proxy due to scheme mismatch") elif proxy.Scheme == "dns": Logger.debug("Not adding DNS proxy for Kodi streams") elif not proxy.use_proxy_for_url(stream_url): Logger.debug("Not adding proxy due to filter mismatch") else: if AddonSettings.is_min_version(17): # See ffmpeg proxy in https://github.com/xbmc/xbmc/commit/60b21973060488febfdc562a415e11cb23eb9764 kodi_item.setProperty("proxy.host", proxy.Proxy) kodi_item.setProperty("proxy.port", str(proxy.Port)) kodi_item.setProperty("proxy.type", proxy.Scheme) if proxy.Username: kodi_item.setProperty("proxy.user", proxy.Username) if proxy.Password: kodi_item.setProperty("proxy.password", proxy.Password) Logger.debug("Adding (Krypton) %s", proxy) else: kodi_params["HttpProxy"] = proxy.get_proxy_address() Logger.debug("Adding (Pre-Krypton) %s", proxy) return
def set_input_stream_addon_input(strm, headers=None, addon="inputstream.adaptive", manifest_type=None, license_key=None, license_type=None, max_bit_rate=None, persist_storage=False, service_certificate=None, manifest_update=None): """ Updates an existing stream with parameters for the inputstream adaptive add-on. :param strm: (MediaStream) the MediaStream to update :param dict headers: Possible HTTP Headers :param str addon: Adaptive add-on to use :param str manifest_type: Type of manifest (hls/mpd) :param str license_key: The value of the license key request :param str license_type: The type of license key request used (see below) :param int max_bit_rate: The maximum bitrate to use (optional) :param bool persist_storage: Should we store certificates? And request server certificates? :param str service_certificate: Use the specified server certificate :param str manifest_update: How should the manifest be updated :returns: The updated stream :rtype: MediaStream Can be used like this: part = item.create_new_empty_media_part() stream = part.append_media_stream(stream_url, 0) M3u8.set_input_stream_addon_input(stream, self.headers) item.complete = True if maxBitRate is not set, the bitrate will be configured via the normal generic Retrospect or channel settings. """ if manifest_type is None: raise ValueError("No manifest type set") strm.Adaptive = True # NOSONAR # See https://forum.kodi.tv/showthread.php?tid=353560 if AddonSettings.is_min_version(AddonSettings.KodiMatrix): strm.add_property("inputstream", addon) else: strm.add_property("inputstreamaddon", addon) # See https://github.com/peak3d/inputstream.adaptive/blob/master/inputstream.adaptive/addon.xml.in strm.add_property("inputstream.adaptive.manifest_type", manifest_type) if license_key: strm.add_property("inputstream.adaptive.license_key", license_key) if license_type: strm.add_property("inputstream.adaptive.license_type", license_type) if max_bit_rate: strm.add_property("inputstream.adaptive.max_bandwidth", max_bit_rate * 1000) if persist_storage: strm.add_property("inputstream.adaptive.license_flags", "persistent_storage") if service_certificate is not None: strm.add_property("inputstream.adaptive.server_certificate", service_certificate) if manifest_update: strm.add_property("inputstream.adaptive.manifest_update_parameter", manifest_update) if headers: header = "" for k, v in headers.items(): header = "{0}&{1}={2}".format(header, k, HtmlEntityHelper.url_encode(v)) strm.add_property("inputstream.adaptive.stream_headers", header.strip("&")) return strm