API

flix.provider

Module provider provides the core logic behind providers.

class flix.provider.ProviderResult[source]

The ProviderResult is the only type allowed to be returned by Provider.search(), Provider.search_movie() and Provider.search_episode() methods.

Parameters:
  • label (str, optional) – The result label.

  • label2 (str, optional) – The result label2.

  • icon (str, optional) – The result icon. If not set, the fallback icon will be used.

  • url (str, optional) – The result url. If not set, then provider_data must be set, otherwise the result is discarded.

  • provider_data (any, optional) – Data to be sent to provider when Provider.resolve() is called.

Example:

# Start by creating the result with some values
result = ProviderResult(
    label="label",
    label2="label2",
    icon="foo/icon.png",
    url="http://foo.bar/video.mp4",
)

# We can then modify values
result.set_label2("new label2")
class flix.provider.Provider[source]

This is where all the logic behind a provider must be implemented. It has methods which are required to be implemented by it’s subclass (search(), search_movie() and search_episode()) and also optional methods (resolve()). The provider can then be registered by using register().

Example:

class CustomProvider(Provider):
    def search(self, query):
        # Implementation here
        return []

    def search_movie(self, tmdb_id, title, titles, year=None):
        return self.search("{:s} {:d}".format(title, year) if year else title)

    def search_show(self, tmdb_id, show_title, titles, year=None):
        return self.search("{:s} {:d}".format(show_title, year) if year else show_title)

    def search_season(self, tmdb_id, show_title, season_number, titles):
        return self.search("{:s} S{:02d}".format(show_title, season_number))

    def search_episode(self, tmdb_id, show_title, season_number, episode_number, titles):
        return self.search("{:s} S{:02d}E{:02d}".format(show_title, season_number, episode_number))

CustomProvider().register()

flix.kodi

Module kodi provides Kodi utilities.

flix.kodi.ADDON

The addon instance (xbmcaddon.Addon).

flix.kodi.ADDON_NAME

The addon name (str).

flix.kodi.ADDON_ID

The addon id (str).

flix.kodi.ADDON_PATH

The addon path (str).

flix.kodi.ADDON_ICON

The addon icon (str).

flix.kodi.ADDON_DATA

The addon data path (str).

flix.kodi.set_setting(id, value)

Set a setting.

Parameters:
  • id (str) – id of the setting that the module needs to set.

  • value (str) – value of the setting.

flix.kodi.get_setting(id)

Get a setting.

Parameters:

id (str) – id of the setting that the module needs to access.

flix.kodi.open_settings()

Open settings window.

flix.kodi.translate(id)

Get a localized string.

Parameters:

id (int) – id of string to localize.

Returns:

Localized string.

Return type:

str

flix.kodi.translate_path(path)

Translates the provided path.

Parameters:

path (str) – path to translate.

Returns:

Translated path.

Return type:

str

flix.utils

Module utils provides some compatibility utilities for both Python 2 and 3.

flix.utils.PY3

Indicates if running on Python 3+ (bool).

flix.utils.string_types

Available string types for current Python version (type).

flix.utils.str_to_bytes(s)[source]

Convert string to bytes. This is a noop for Python 2.

flix.utils.bytes_to_str(s)[source]

Convert bytes to string. This is a noop for Python 2.

flix.utils.assure_unicode(s)[source]

Convert string to unicode if necessary. This is a noop for Python 3.

flix.utils.assure_str(s)[source]

Convert unicode to string if necessary. This is a noop for Python 3.