web_api module

Provide an easy and intuitive way to fetch data from streaming websites.

web_api._filter_stream(streams_, type_, quality, container)[source]

Look up the properties of the video streams and filter by keyword arguments. A certain level of interpretation is used, if the exact stream is not found. It will only return None if the container format is not provided.

Parameters:args (tuple(str)) – an arbitrary number of values. Last argument is the dict.
Returns:True if all values were present, False otherwise.
Return type:bool
web_api._playlist(plugin, media_url, **kwargs)[source]

Search for videos in a playlist.

Parameters:
  • plugin (module) – the plugin.
  • media_url (str) – the media url.
  • results (int) – the number of results to return (0 = all).
Returns:

the search result.

Return type:

list(dict)

web_api._subtitles(plugin, media_url, lang='en')[source]
web_api.cache(func)[source]

A decorator function which caches the results of requests.

Parameters:func (callable) – the decorated function.
Returns:the wrapper.
Return type:callable
web_api.channel(plugin, url)[source]
web_api.download(media_url, folder, audio=True, video=True, subtitles=False, **kwargs)[source]

Download the streams for the media url.

Parameters:
  • media_url (str) – the url.
  • folder (str) – the local folder for the output.
  • audio (bool) – download audio.
  • video (bool) – download video.
  • subtitles (bool) – download subtitles.
  • kwargs – additional video properties (see streams).
Returns:

a Download instance.

web_api.metadata(plugin, media_url)[source]

Fetch information for the specified media url and return a dict.

Parameters:media_url (str) – the url of the media page.
Returns:all the information / metadata found.
Return type:dict
web_api.module(func)[source]

A decorator function which provides the necessary plugin modules.

Parameters:func (callable) – the decorated function.
Returns:the wrapper.
Return type:callable
web_api.play(media_url, **kwargs)[source]
web_api.search(plugin, query_or_url, **kwargs)[source]

Perform a search and return the result. The result will be a list of dicts, each dict containing some basic data for the video like title, duration etc. The query_or_url parameter can either be a regular search time, in which case the plugin must be specified, or ot may be the url of a channel or playlist (where the plugin in determined automatically).

Parameters:
  • plugin (module) – the plugin.
  • query_or_url (str) – the search query.
  • results (int) – the number of search results (0 = all).
Returns:

the search result.

Return type:

list(dict)

web_api.streams(media_url, quality='best', container='webm')[source]

Given a media url, return the stream dicts.

Parameters:
  • media_url (str) – the media url.
  • quality (str) – the stream quality (concerns only video files). Default: ‘1080p’.
  • container (str) – the container format. Usually either mp4 or webm. Default: ‘webm’.
Returns:

the audio and video dicts.

Return type:

tuple(dict, dict)

web_api.thumbnail(media_url, size='small')[source]

Download the thumbnail and return the filepath.

Parameters:
  • plugin (module) – the plugin.
  • media_url (str) – the media url.
  • size (str) – the thumbnail size, either ‘small’ or ‘big’.
Returns:

the local filepath.

;rtype: str

web_api.user(plugin, url)[source]