Coverage for resources/lib/Utils.py : 98%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- # Module: Utils # Author: asciidisco # Created on: 24.07.2017 # License: MIT https://goo.gl/WA1kby
"""General plugin utils"""
""" Injects instances & the plugin handle
:param kodi_base_url: Plugin base url :type kodi_base_url: string :param constants: Constants instance :type constants: resources.lib.Constants """
""" Returns the relevant addon data for the plugin, e.g. name, version, default fanart, base data path & cookie pathname
:returns: dict - Addon data """ plugin=addon.getAddonInfo('name'), version=addon.getAddonInfo('version'), fanart=addon.getAddonInfo('fanart'), base_data_path=base_data_path, cookie_path=base_data_path + 'COOKIE')
""" Logs a message to the Kodi log (default debug)
:param msg: Message to be logged :type msg: mixed :param level: Log level :type level: int """
""" Fetches a translated string from the po files
:param string_id: Id of the string to be translated :type string_id: int :returns: string - Translated string """
""" Generates an URL for internal plugin navigation
:param query: Map of request params :type query: dict :returns: string - Url """
""" Determines if inoutstream can/should be used to play the videos
Note: At least Kodi 17.4 & Inoutstream 2.0.7 are needed, because of HSL support
:returns: bool - Use inputstream to play videos """ # determine if we can use inputstream for HLS
""" Returns an Kodi addon instance
:returns: xbmcaddon.Addon - Addon instance """
def generate_hash(cls, text): """ Returns an hash for a given text
:param text: String to be hashed :type text: string :returns: string - Hash """
def capitalize(cls, sentence): """ Capitalizes a sentence
:param sentence: String to be capitalized :type sentence: string :returns: string - Capitalized sentence """
def get_kodi_version(cls): """ Retrieves the Kodi version (Defaults to 17)
:returns: string - Kodi version """ 'jsonrpc': '2.0', 'method': 'Application.GetProperties', 'params': { 'properties': ['version', 'name'] }, 'id': 1 }
def get_inputstream_version(cls): """ Retrieves the Inputsteam version (Defaults to 1.0.0)
:returns: string - Inputsteam version """ 'jsonrpc': '2.0', 'id': 1, 'method': 'Addons.GetAddonDetails', 'params': { 'addonid': 'inputstream.adaptive', 'properties': ['enabled', 'version'] } } # execute the request
def get_user_agent(cls): """Determines the user agent string for the current platform
:returns: str -- User agent string """ # Mac OSX # Windows return base.replace('%PL%', '(Windows NT 6.1; WOW64)') # ARM based Linux # x86 Linux |