seedr_client package#

Module contents#

class seedr_client.SeedrHandler(email=None, password=None, access_token=None, aria2c_secret=None, download_directory='.')[source]#

Bases: object

add_torrent(torrent=None, wishlist_id=None, folder_id=-1, check_size=True)[source]#

This function allows you to pass either torrent file or magnet uri or a wishlist id, to start downloading by Seedr.

Note: If magnet uri is passed instead of a torrent file which is the preferred method, and if the peers in the torrent is lower than 3 or if the torrent is completely dead then this function might not be able to add the torrent due to the underlying logic which requires the meta info of the torrent. This is a drawback of this approach as this helps avoid wasting time checking if there is enough storage space, but can’t use the Seedr’s cache, which works even if there is no seeders. If there is enough requests to correct this approach I will add a timeout logic to the method in next iteration. For now try supplying torrents file instead of the magnet uri.

Parameters:
  • torrent (str) – The torrent file or magnet uri that you want to add to be leeched/downloaded

  • wishlist_id (int) – The wishlist id that you want to add from your Seedr wishlist

  • folder_id (int) – The folder you want the torrent to be downloaded to. Defaults to parent.

  • check_size (bool) – Used to inform function if checking of Seedr drive space with torrent size is required or not. By default, it checks the torrent size with drive size and raise error if torrent size is larger than drive size.

Returns:

If successful returns the name, ID and progress url(returns completed incase the download has already completed and there is no url to present) of the torrent.

Return type:

dict

static bytes_to_mb_gb(byte)[source]#

A simple function that converts Bytes to Megabytes if value is less than 1 Gigabyte else returns value in Gigabytes

Parameters:

byte (int) – The value in Bytes to be converted

Returns:

The converted value in MB or GB based on logic

Return type:

str

static contains_bad_token(response_text)[source]#
delete_all()[source]#

This method deletes all the content within the drive, whether it downloaded to the drive or being downloaded.

Returns:

Returns True if the method clears the whole drive successfully, False otherwise.

Return type:

bool

delete_file(folder_file_id)[source]#

This method deletes the file associated with the id that is passed and returns True on success

Parameters:

folder_file_id (int) – The id of the file you wish to delete

Returns:

Returns True or False based on success

Return type:

bool

delete_folder(folder_id)[source]#

This method deletes the folder associated with the id that is passed and returns True on success

Parameters:

folder_id (int) – The id of the folder you wish to delete

Returns:

Returns True or False based on success

Return type:

bool

delete_torrent(torrent_id)[source]#

This method deletes any active torrent associated with the id that is passed and returns True on success

Parameters:

torrent_id (int) – The id of the active torrent you wish to delete

Returns:

Returns True or False based on success

Return type:

bool

download_folder(folder_id, builtin_downloader=True)[source]#

This function either downloads the entire folder excluding any extensions that are bared or returns a list of files with their exact order and download url.

Parameters:
  • folder_id (int) – The ID of the folder you would like to download

  • builtin_downloader (bool) – This is to inform the function if you would like SeedrClient to download the folder all by itself or wish to just get a dictionary of files and their information so that you can download them yourself.

Returns:

Returns a dict if builtin_downloader is set to False or returns True after completing the download of the folder.

Return type:

Union[dict, bool]

get_drive()[source]#

Gets details about the drive’s space, active torrents, and all downloaded files and folders Note: This is the same as the get_folder method except seedr api does not ask for a folder id, additionally we are able top display a few additional details, including active torrents

Returns:

A dictionary containing, available and used drive space, active torrents and its details, downloaded folders and files and their details

Return type:

dict

get_file(folder_file_id)[source]#

This method returns the name and the download url associated with the file id that is passed

Parameters:

folder_file_id (int) – The unique id associated with the file you need the info about

Returns:

A dictionary containing file name and download url

Return type:

dict

get_folder(folder_id)[source]#

This method lists all the content of the folder as a dictionary associated with the folder id that is passed if it exists

Parameters:

folder_id (int) – The unique id associated with the folder that you need the info about

Returns:

A dictionary contains a list of all files and folders in the associated folder

Return type:

dict

get_token()[source]#

Gets the access token if email and password is passed during init, else if token itself was provided instead verifies that the access token is valid and if an error occurs during the previous process or if none of the required details are passed during init of client raises an error.

is_login_success()[source]#

Checks if the access token is valid

Returns:

Returns True if the token is valid, False if it isn’t

Return type:

bool

static is_op_success(response_text)[source]#

Checks if there is a success code in the response provided by the api call and returns the appropriate boolean :param response_text: The response from the api call in text format :type response_text: str :return: Returns true if success, false otherwise :rtype: bool

is_request_failed(response_text, requested_on)[source]#

Checks for any failed codes in the response and if there is any, then it raises the appropriate error code with detail, else returns false

Parameters:
  • response_text (str) – The text response received by Seedr api to the request made by the previous method

  • requested_on (str) – A string that is either “file” or “folder” based on what kinda file system operations was going on in the previous method

Returns:

Returns False if no fail code

Return type:

bool

list_contents(response_json)[source]#

This method takes the response provided by the api request and sanitizes it, to only returns the relevant details pertaining to the folder structure :param response_json: The response from the api requests passed in json format :type response_json: dict :return: The folder structure of the folder pertaining to the api response :rtype: dict

Submodules#

seedr_client.errors module#

exception seedr_client.errors.BadLeeching[source]#

Bases: Exception

exception seedr_client.errors.DriveLimit[source]#

Bases: Exception

exception seedr_client.errors.InvalidLogin[source]#

Bases: Exception

exception seedr_client.errors.InvalidToken[source]#

Bases: Exception

exception seedr_client.errors.InvalidTorrent[source]#

Bases: Exception

exception seedr_client.errors.LoginRequired[source]#

Bases: Exception