API Reference

Login

This module provides functionality for authenticating with the Seedr.cc API.

It contains the Login class for generating login tokens and the create_token function for encoding token information.

aioseedrcc.login.create_token(response, refresh_token=None, device_code=None)[source]

Create an encoded token string from the API response.

Parameters:
  • response (Dict[str, Any]) – The API response containing token information.

  • refresh_token (Optional[str]) – A refresh token to include in the encoded string.

  • device_code (Optional[str]) – A device code to include in the encoded string.

Returns:

An encoded token string.

Return type:

str

Example

>>> response = {'access_token': 'abc123'}
>>> token = create_token(response, refresh_token='refresh456', device_code='device789')
>>> print(token)
class aioseedrcc.login.Login(username=None, password=None, session=None, session_args=None)[source]

Bases: object

A class to handle authentication with the Seedr.cc API.

This class provides methods to generate login tokens either through username/password authentication or device code authorization.

token

The generated token after successful authorization.

Type:

Optional[str]

Parameters:
  • username (Optional[str]) – The username for the Seedr account.

  • password (Optional[str]) – The password for the Seedr account.

Example

Logging in with username and password:
>>> async with Login('user@example.com', 'password123') as login:
...     await login.authorize()
...     print(login.token)
Authorizing with device code:
>>> async with Login() as login:
...     device_code = await login.get_device_code()
...     print(f"Please authorize: {device_code['verification_url']}")
...     print(f"Your user code is: {device_code['user_code']}")
...     await login.authorize(device_code['device_code'])
...     print(login.token)
async get_device_code()[source]

Generate a device and user code for authorization.

Returns:

A dictionary containing the device_code, user_code,

verification_url, and expires_in.

Return type:

Dict[str, Any]

Example

>>> async with Login() as login:
...     device_code = await login.get_device_code()
...     print(device_code)
async authorize(device_code=None)[source]

Authorize and get a token for the Seedr account.

This method can be used either with a username/password combination (set during class initialization) or with a device_code obtained from the get_device_code method.

Parameters:

device_code (Optional[str]) – The device code obtained from get_device_code.

Returns:

The API response containing token information.

Return type:

Dict[str, Any]

Raises:
  • ValueError – If neither username/password nor device_code is provided.

  • aiohttp.ClientError – If the request fails.

Example

Authorizing with username and password:
>>> async with Login('user@example.com', 'password123') as login:
...     response = await login.authorize()
...     print(response)
...     print(login.token)
Authorizing with device code:
>>> async with Login() as login:
...     device_code_info = await login.get_device_code()
...     response = await login.authorize(device_code_info['device_code'])
...     print(response)
...     print(login.token)
async device_authorization_flow(callback)[source]

Perform the complete device authorization flow.

This method gets a device code, waits for user authorization, and then completes the authorization process.

Parameters:

callback – A callable that takes the device_code information and handles user interaction (e.g., displaying the verification URL and user code).

Returns:

The final API response after successful authorization.

Return type:

Dict[str, Any]

Example

>>> async def user_interaction(device_info):
...     print(f"Please go to {device_info['verification_url']} and enter code: {device_info['user_code']}")
...     input("Press Enter after you've authorized the device...")
>>> async with Login() as login:
...     response = await login.device_authorization_flow(user_interaction)
...     print(response)
...     print(login.token)

Seedr

This module provides an asynchronous interface to interact with the Seedr.cc API.

It contains the Seedr class which encapsulates all the functionality to manage a Seedr account, including adding torrents, managing files and folders, and handling account settings.

class aioseedrcc.seedr.Seedr(token, session_args=None, token_refresh_callback=None, token_refresh_callback_kwargs=None)[source]

Bases: object

Asynchronous client for interacting with the Seedr.cc API.

This class provides methods to perform various operations on a Seedr account, such as adding torrents, managing files and folders, and handling account settings.

token

The authentication token for the Seedr account.

Type:

str

Parameters:
  • token (str) – The authentication token for the Seedr account.

  • session_args (Optional[Dict[str, Any]]) – Optional arguments to pass to the aiohttp ClientSession.

  • token_refresh_callback (Optional[Callable]) – Callable[[Seedr, **Any], Coroutine[Any, Any, None]] - async callback function to be called after token refresh

  • token_refresh_callback_kwargs (Optional[Dict[str, Any]]) – Dict[str, Any] - custom arguments to be passed to the token refresh callback function

Example

>>> async with Seedr(token='your_token_here') as seedr:
...     settings = await seedr.get_settings()
...     print(settings)
BASE_URL = 'https://www.seedr.cc/oauth_test/resource.php'
async test_token()[source]

Test the validity of the current token.

Returns:

The API response indicating whether the token is valid.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token_here') as seedr:
...     result = await seedr.test_token()
...     print(result)
async refresh_token()[source]

Refresh the expired token.

This method is called automatically when needed, but can also be called manually.

Returns:

The API response containing the new token information.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token_here') as seedr:
...     new_token_info = await seedr.refresh_token()
...     print(seedr.token)  # This will be the new token
async get_settings()[source]

Retrieve the user’s account settings.

Returns:

The API response containing the user’s settings.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token_here') as seedr:
...     settings = await seedr.get_settings()
...     print(settings)
async get_memory_bandwidth()[source]

Retrieve the memory and bandwidth usage information.

Returns:

The API response containing memory and bandwidth usage data.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token_here') as seedr:
...     usage = await seedr.get_memory_bandwidth()
...     print(usage)
async add_torrent(magnet_link=None, torrent_file=None, wishlist_id=None, folder_id='-1')[source]

Add a torrent to the Seedr account for downloading.

Parameters:
  • magnet_link (Optional[str]) – The magnet link of the torrent.

  • torrent_file (Optional[str]) – Remote or local path of the torrent file.

  • wishlist_id (Optional[str]) – The wishlist ID to add the torrent to.

  • folder_id (str) – The folder ID to add the torrent to. Default to ‘-1’ (root folder).

Returns:

The API response after adding the torrent.

Return type:

Dict[str, Any]

Raises:

SeedrException – If there’s an error reading the torrent file or making the request.

Example

Adding a torrent using a magnet link:
>>> async with Seedr(token='your_token_here') as seedr:
...     result = await seedr.add_torrent(magnet_link='magnet:?xt=urn:btih:...')
...     print(result)
Adding a torrent from a local file:
>>> async with Seedr(token='your_token_here') as seedr:
...     result = await seedr.add_torrent(torrent_file='/path/to/file.torrent')
...     print(result)
async scan_page(url)[source]

Scan a page and return a list of torrents.

This method can be used to fetch magnet links from torrent pages.

Parameters:

url (str) – The URL of the page to scan.

Returns:

The API response containing the scan results.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token') as seedr:
...     result = await seedr.scan_page('https://1337x.to/torrent/1234')
...     print(result)
async create_archive(folder_id)[source]

Create an archive link of a folder.

Parameters:

folder_id (str) – The ID of the folder to archive.

Returns:

The API response containing the archive link.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token') as seedr:
...     result = await seedr.create_archive('12345')
...     print(result)
async fetch_file(file_id)[source]

Create a download link for a file.

Parameters:

file_id (str) – The ID of the file to fetch.

Returns:

The API response containing the download link.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token_here') as seedr:
...     file_info = await seedr.fetch_file('12345')
...     print(file_info)
async delete_item(item_id, item_type)[source]

Delete a file, folder, or torrent.

Parameters:
  • item_id (str) – The ID of the item to delete.

  • item_type (str) – The type of the item (‘file’, ‘folder’, or ‘torrent’).

Returns:

The API response after deleting the item.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token_here') as seedr:
...     result = await seedr.delete_item('12345', 'file')
...     print(result)
async rename_item(item_id, new_name, item_type)[source]

Rename a file or folder.

Parameters:
  • item_id (str) – The ID of the item to rename.

  • new_name (str) – The new name for the item.

  • item_type (str) – The type of the item (‘file’ or ‘folder’).

Returns:

The API response after renaming the item.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token_here') as seedr:
...     result = await seedr.rename_item('12345', 'New Name', 'file')
...     print(result)
async list_contents(folder_id='0')[source]

List the contents of a folder.

Parameters:

folder_id (str) – The ID of the folder to list. Defaults to ‘0’ (root folder).

Returns:

The API response containing the folder contents.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token_here') as seedr:
...     contents = await seedr.list_contents()
...     print(contents)
async add_folder(name)[source]

Create a new folder.

Parameters:

name (str) – The name of the new folder.

Returns:

The API response after creating the folder.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token_here') as seedr:
...     result = await seedr.add_folder('New Folder')
...     print(result)
async delete_wishlist(wishlist_id)[source]

Delete an item from the wishlist.

Parameters:

wishlist_id (str) – The ID of the wishlist item to delete.

Returns:

The API response after deleting the wishlist item.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token') as seedr:
...     result = await seedr.delete_wishlist('12345')
...     print(result)
async search_files(query)[source]

Search for files in the Seedr account.

Parameters:

query (str) – The search query.

Returns:

The API response containing the search results.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token') as seedr:
...     result = await seedr.search_files('example file')
...     print(result)
async change_name(name, password)[source]

Change the name of the Seedr account.

Parameters:
  • name (str) – The new name for the account.

  • password (str) – The current password of the account.

Returns:

The API response after changing the name.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token') as seedr:
...     result = await seedr.change_name('New Name', 'current_password')
...     print(result)
async change_password(old_password, new_password)[source]

Change the password of the Seedr account.

Parameters:
  • old_password (str) – The current password of the account.

  • new_password (str) – The new password to set.

Returns:

The API response after changing the password.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token') as seedr:
...     result = await seedr.change_password('old_password', 'new_password')
...     print(result)
async get_devices()[source]

Get the list of devices connected to the Seedr account.

Returns:

The API response containing the list of connected devices.

Return type:

Dict[str, Any]

Example

>>> async with Seedr(token='your_token_here') as seedr:
...     devices = await seedr.get_devices()
...     print(devices)