Resolver

This module is used for the creation of “Route callbacks”.

class codequick.resolver.Resolver[source]

This class is used to create “Resolver” callbacks. Resolver callbacks are callbacks that return playable video URL’s which Kodi can play.

Resolver inherits all methods and attributes from script.Script.

The possible return types from Resolver Callbacks are.
  • str: URL as type “str”.
  • iterable: “List” or “tuple”, consisting of URL’s, “listItem’s” or a “tuple” consisting of (title, URL).
  • dict: “Dictionary” consisting of “title” as the key and the URL as the value.
  • listItem: A codequick.Listitem object with required data already set e.g. “label” and “path”.
  • generator: A Python “generator” that return’s one or more URL’s.
  • False: This will cause the “resolver call” to quit silently, without raising a RuntimeError.

Note

If multiple URL’s are given, a playlist will be automaticly created.

Raises:
Example:
>>> from codequick import Resolver, Route, Listitem
>>>
>>> @Route.register
>>> def root(_):
>>>     yield Listitem.from_dict("Play video", play_video,
>>>           params={"url": "https://www.youtube.com/watch?v=RZuVTOk6ePM"})
>>>
>>> @Resolver.register
>>> def play_video(plugin, url):
>>>     # Extract a playable video url using youtubeDL
>>>     return plugin.extract_source(url)
extract_source(url, quality=None, **params)[source]

Extract video URL using “YouTube.DL”.

YouTube.DL provides access to hundreds of sites.

See also

The list of supported sites can be found at:

https://rg3.github.io/youtube-dl/supportedsites.html

Quality options are.
  • 0 = SD,
  • 1 = 720p,
  • 2 = 1080p,
  • 3 = Highest Available
Parameters:
  • url (str) – URL of the video source, where the playable video can be extracted from.
  • quality (int) – [opt] Override YouTube.DL’s quality setting.
  • params – Optional “Keyword” arguments of YouTube.DL parameters.
Returns:

The playable video url

Return type:

str

See also

The list of available parameters can be found at.

https://github.com/rg3/youtube-dl#options