torrent#

class platypush.plugins.torrent.TorrentPlugin(download_dir=None, torrent_ports=None, imdb_key=None, popcorn_base_url='http://popcorn-time.ga', **kwargs)[source]#

Bases: Plugin

Plugin to search and download torrents.

Requires:

  • python-libtorrent (pip install python-libtorrent)

__init__(download_dir=None, torrent_ports=None, imdb_key=None, popcorn_base_url='http://popcorn-time.ga', **kwargs)[source]#
Parameters:
  • download_dir (str) – Directory where the videos/torrents will be downloaded (default: none)

  • torrent_ports (list[int]) – Torrent ports to listen on (default: 6881 and 6891)

  • imdb_key (str) – The IMDb API (https://imdb-api.com/) is used to search for movies and series. Insert your IMDb API key if you want support for content search.

  • popcorn_base_url (str) – Custom base URL to use for the PopcornTime API.

download(torrent, download_dir=None, _async=False, event_hndl=None, is_media=False)[source]#

Download a torrent.

Parameters:
  • torrent (str) –

    Torrent to download. Supported formats:

    • Magnet URLs

    • Torrent URLs

    • Local torrent file

  • download_dir (str) – Directory to download, overrides the default download_dir attribute (default: None)

  • _async (bool) – If true then the method will add the torrent to the transfer and then return. Updates on the download status should be retrieved either by listening to torrent events or registering the event handler. If false (default) then the method will exit only when the torrent download is complete.

  • event_hndl (function) – A function that takes an event object as argument and is invoked upon a new torrent event (download started, progressing, completed etc.)

  • is_media (bool) – Set it to true if you’re downloading a media file that you’d like to stream as soon as the first chunks are available. If so, then the events and the status method will only include media files

pause(torrent)[source]#

Pause/resume a torrent transfer.

Parameters:

torrent (str) – Torrent URL as returned from get_status()

quit()[source]#

Quits all the transfers and the active session

remove(torrent)[source]#

Stops and removes a torrent transfer.

Parameters:

torrent (str) – Torrent URL as returned from get_status()

resume(torrent)[source]#

Resume a torrent transfer.

Parameters:

torrent (str) – Torrent URL as returned from get_status()

search(query, category=None, language=None, *args, **kwargs)[source]#

Perform a search of video torrents.

Parameters:
  • query (str) – Query string, video name or partial name

  • category (str or list) – Category to search. Supported types: “movies”, “tv”. Default: None (search all categories)

  • language (str) – Language code for the results - example: “en” (default: None, no filter)

status(torrent=None)[source]#

Get the status of the current transfers.

Parameters:

torrent (str) – Torrent path, URL or magnet URI whose status will be retrieve (default: None, retrieve all current transfers)

Returns:

A dictionary in the format torrent_url -> status