aioseedrcc


Nameaioseedrcc JSON
Version 0.3.2 PyPI version JSON
download
home_pagehttps://aioseedrcc.rtfd.io
SummaryAIOSeedrcc is a Python asyncrnous library for interacting with Seedr.cc API.
upload_time2024-12-22 05:31:20
maintainerNone
docs_urlNone
authormhdzumair
requires_python>=3.10
licenseMIT
keywords seedr seedr.cc torrent api asyncio aiohttp
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <p align="center">
<img src="https://raw.githubusercontent.com/mhdzumair/aioseedrcc/main/docs/images/AIOSeedrCC.png" align="center" height=250 alt="AIOSeedrcc logo" />
</p>

<h2 align='center'>Asynchronous Python API Wrapper for Seedr.cc</h2>

<p align="center">
<a href="https://pypi.org/project/aioseedrcc">
<img src='https://img.shields.io/pypi/v/aioseedrcc.svg'>
</a>
<a href="https://pepy.tech/project/aioseedrcc">
<img src='https://pepy.tech/badge/aioseedrcc'>
</a>
<a href="https://github.com/mhdzumair/aioseedrcc/stargazers">
<img src="https://img.shields.io/github/stars/mhdzumair/aioseedrcc" alt="Stars"/>
</a>
<a href="https://github.com/mhdzumair/aioseedrcc/issues">
<img src="https://img.shields.io/github/issues/mhdzumair/aioseedrcc" alt="Issues"/>
</a>
<br>

## Table of Contents
- [Installation](#installation)
- [Start Guide](#start-guide)
    - [Getting Token](#getting-token)
        - [Logging with Username and Password](#logging-with-username-and-password)
        - [Authorizing with device code](#authorizing-with-device-code)
    - [Basic Examples](#basic-examples)
    - [Managing token](#managing-token)
        - [Callback function](#callback-function)
            - [Function with single argument](#callback-function-with-single-argument)
            - [Function with multiple arguments](#callback-function-with-multiple-arguments)
- [Detailed Documentation](#documentation)
- [Contributing](#contributing)
- [License](#license)

## Installation
- Install via [PyPi](https://www.pypi.org/project/aioseedrcc)
    ```bash
    pip install aioseedrcc
    ```

- Install from the source
    ```bash
    pip install git+https://github.com/mhdzumair/aioseedrcc.git
    ```

## Start guide

### Getting Token

There are two methods to get the account token. You can login with username/password or by authorizing with device code. 

#### Logging with Username and Password

This method uses the seedr Chrome extension API.

```python
import asyncio
from aioseedrcc import Login

async def main():
    async with Login('foo@bar.com', 'password') as seedr:
        response = await seedr.authorize()
        print(response)

        # Getting the token 
        print(seedr.token)

asyncio.run(main())
```

### Authorizing with device code

This method uses the seedr kodi API.

**To use this method, generate a device & user code. Paste the user code in https://seedr.cc/devices and authorize with the device code.**

```python
import asyncio
from aioseedrcc import Login

async def main():
    async with Login() as seedr:
        device_code = await seedr.get_device_code()
        # Go to https://seedr.cc/devices and paste the user code
        print(device_code)

        # Authorize with device code
        response = await seedr.authorize(device_code['device_code'])
        print(response)

        # Getting the token
        print(seedr.token)

asyncio.run(main())
```

**✏️ Note: You must use the token from the instance variable 'token' instead of the 'access_token' or 'refresh_token' from the response.**

### Basic Examples

For all available methods, please refer to the [documentation](https://aioseedrcc.readthedocs.org/en/latest/). Also, it is recommended to set a callback function, read more about it [here](#managing-token).

```python
import asyncio
from aioseedrcc import Seedr

async def main():
    async with Seedr(token='token') as account:
        # Getting user settings
        settings = await account.get_settings()
        print(settings)

        # Adding torrent
        response = await account.add_torrent('magnetlink')
        print(response)

        # Listing folder contents
        contents = await account.list_contents()
        print(contents)

asyncio.run(main())
```

### Managing token

The access token may expire after a certain time and need to be refreshed. However, this process is handled by the module and you don't have to worry about it. 

**⚠️ The token is updated after this process and if you are storing the token in a file/database and reading the token from it, It is recommended to update the token in the database/file using the callback function. If you do not update the token in such case, the module will refresh the token in each session which will cost extra request and increase the response time.**


### Callback function

You can set a callback function which will be called automatically each time the token is refreshed. You can use such function to deal with the refreshed token.

**✏️ Note: The callback function must be asynchronous and have at least one parameter. The first parameter of the callback function will be the `Seedr` class instance.**

#### Callback function with single argument

Here is an example of a callback function with a single argument which reads and updates the token in a file called `token.txt`.

```python
import asyncio
from aioseedrcc import Seedr

# Read the token from token.txt
with open('token.txt', 'r') as f:
    token = f.read().strip()

# Defining the callback function
async def after_refresh(seedr):
    with open('token.txt', 'w') as f:
        f.write(seedr.token)

async def main():
    async with Seedr(token, token_refresh_callback=after_refresh) as account:
        # Your code here
        pass

asyncio.run(main())
```

#### Callback function with multiple arguments

In situations where you need to pass multiple arguments to the callback function, you can use the `token_refresh_callback_kwargs` argument. This can be useful if your app is dealing with multiple users.

Here is an example of a callback function with multiple arguments which will update the token of a certain user in the database after the token of that user is refreshed.

```python
import asyncio
from aioseedrcc import Seedr

# Defining the callback function
async def after_refresh(seedr, user_id):
    # Add your code to deal with the database
    print(f'Token of the user {user_id} is updated.')

async def main():
    # Creating a Seedr object for user 12345
    async with Seedr(token='token', token_refresh_callback=after_refresh, token_refresh_callback_kwargs={'user_id': '12345'}) as account:
        # Your code here
        pass

asyncio.run(main())
```

## Documentation

The detailed documentation of each method is available [here](https://aioseedrcc.readthedocs.org/en/latest/).

## Contributing

Any contributions you make are **greatly appreciated**.

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

## License

Distributed under the MIT License. See [LICENSE](https://github.com/mhdzumair/aioseedrcc/blob/main/LICENSE) for more information.


            

Raw data

            {
    "_id": null,
    "home_page": "https://aioseedrcc.rtfd.io",
    "name": "aioseedrcc",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "seedr, seedr.cc, torrent, api, asyncio, aiohttp",
    "author": "mhdzumair",
    "author_email": "mhdzumair@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0d/80/3bff820eb3bb03fa3be4f301961b38994bf0381c122a06350811bf21b8cc/aioseedrcc-0.3.2.tar.gz",
    "platform": null,
    "description": "<p align=\"center\">\n<img src=\"https://raw.githubusercontent.com/mhdzumair/aioseedrcc/main/docs/images/AIOSeedrCC.png\" align=\"center\" height=250 alt=\"AIOSeedrcc logo\" />\n</p>\n\n<h2 align='center'>Asynchronous Python API Wrapper for Seedr.cc</h2>\n\n<p align=\"center\">\n<a href=\"https://pypi.org/project/aioseedrcc\">\n<img src='https://img.shields.io/pypi/v/aioseedrcc.svg'>\n</a>\n<a href=\"https://pepy.tech/project/aioseedrcc\">\n<img src='https://pepy.tech/badge/aioseedrcc'>\n</a>\n<a href=\"https://github.com/mhdzumair/aioseedrcc/stargazers\">\n<img src=\"https://img.shields.io/github/stars/mhdzumair/aioseedrcc\" alt=\"Stars\"/>\n</a>\n<a href=\"https://github.com/mhdzumair/aioseedrcc/issues\">\n<img src=\"https://img.shields.io/github/issues/mhdzumair/aioseedrcc\" alt=\"Issues\"/>\n</a>\n<br>\n\n## Table of Contents\n- [Installation](#installation)\n- [Start Guide](#start-guide)\n    - [Getting Token](#getting-token)\n        - [Logging with Username and Password](#logging-with-username-and-password)\n        - [Authorizing with device code](#authorizing-with-device-code)\n    - [Basic Examples](#basic-examples)\n    - [Managing token](#managing-token)\n        - [Callback function](#callback-function)\n            - [Function with single argument](#callback-function-with-single-argument)\n            - [Function with multiple arguments](#callback-function-with-multiple-arguments)\n- [Detailed Documentation](#documentation)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n- Install via [PyPi](https://www.pypi.org/project/aioseedrcc)\n    ```bash\n    pip install aioseedrcc\n    ```\n\n- Install from the source\n    ```bash\n    pip install git+https://github.com/mhdzumair/aioseedrcc.git\n    ```\n\n## Start guide\n\n### Getting Token\n\nThere are two methods to get the account token. You can login with username/password or by authorizing with device code. \n\n#### Logging with Username and Password\n\nThis method uses the seedr Chrome extension API.\n\n```python\nimport asyncio\nfrom aioseedrcc import Login\n\nasync def main():\n    async with Login('foo@bar.com', 'password') as seedr:\n        response = await seedr.authorize()\n        print(response)\n\n        # Getting the token \n        print(seedr.token)\n\nasyncio.run(main())\n```\n\n### Authorizing with device code\n\nThis method uses the seedr kodi API.\n\n**To use this method, generate a device & user code. Paste the user code in https://seedr.cc/devices and authorize with the device code.**\n\n```python\nimport asyncio\nfrom aioseedrcc import Login\n\nasync def main():\n    async with Login() as seedr:\n        device_code = await seedr.get_device_code()\n        # Go to https://seedr.cc/devices and paste the user code\n        print(device_code)\n\n        # Authorize with device code\n        response = await seedr.authorize(device_code['device_code'])\n        print(response)\n\n        # Getting the token\n        print(seedr.token)\n\nasyncio.run(main())\n```\n\n**\u270f\ufe0f Note: You must use the token from the instance variable 'token' instead of the 'access_token' or 'refresh_token' from the response.**\n\n### Basic Examples\n\nFor all available methods, please refer to the [documentation](https://aioseedrcc.readthedocs.org/en/latest/). Also, it is recommended to set a callback function, read more about it [here](#managing-token).\n\n```python\nimport asyncio\nfrom aioseedrcc import Seedr\n\nasync def main():\n    async with Seedr(token='token') as account:\n        # Getting user settings\n        settings = await account.get_settings()\n        print(settings)\n\n        # Adding torrent\n        response = await account.add_torrent('magnetlink')\n        print(response)\n\n        # Listing folder contents\n        contents = await account.list_contents()\n        print(contents)\n\nasyncio.run(main())\n```\n\n### Managing token\n\nThe access token may expire after a certain time and need to be refreshed. However, this process is handled by the module and you don't have to worry about it. \n\n**\u26a0\ufe0f The token is updated after this process and if you are storing the token in a file/database and reading the token from it, It is recommended to update the token in the database/file using the callback function. If you do not update the token in such case, the module will refresh the token in each session which will cost extra request and increase the response time.**\n\n\n### Callback function\n\nYou can set a callback function which will be called automatically each time the token is refreshed. You can use such function to deal with the refreshed token.\n\n**\u270f\ufe0f Note: The callback function must be asynchronous and have at least one parameter. The first parameter of the callback function will be the `Seedr` class instance.**\n\n#### Callback function with single argument\n\nHere is an example of a callback function with a single argument which reads and updates the token in a file called `token.txt`.\n\n```python\nimport asyncio\nfrom aioseedrcc import Seedr\n\n# Read the token from token.txt\nwith open('token.txt', 'r') as f:\n    token = f.read().strip()\n\n# Defining the callback function\nasync def after_refresh(seedr):\n    with open('token.txt', 'w') as f:\n        f.write(seedr.token)\n\nasync def main():\n    async with Seedr(token, token_refresh_callback=after_refresh) as account:\n        # Your code here\n        pass\n\nasyncio.run(main())\n```\n\n#### Callback function with multiple arguments\n\nIn situations where you need to pass multiple arguments to the callback function, you can use the `token_refresh_callback_kwargs` argument. This can be useful if your app is dealing with multiple users.\n\nHere is an example of a callback function with multiple arguments which will update the token of a certain user in the database after the token of that user is refreshed.\n\n```python\nimport asyncio\nfrom aioseedrcc import Seedr\n\n# Defining the callback function\nasync def after_refresh(seedr, user_id):\n    # Add your code to deal with the database\n    print(f'Token of the user {user_id} is updated.')\n\nasync def main():\n    # Creating a Seedr object for user 12345\n    async with Seedr(token='token', token_refresh_callback=after_refresh, token_refresh_callback_kwargs={'user_id': '12345'}) as account:\n        # Your code here\n        pass\n\nasyncio.run(main())\n```\n\n## Documentation\n\nThe detailed documentation of each method is available [here](https://aioseedrcc.readthedocs.org/en/latest/).\n\n## Contributing\n\nAny contributions you make are **greatly appreciated**.\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## License\n\nDistributed under the MIT License. See [LICENSE](https://github.com/mhdzumair/aioseedrcc/blob/main/LICENSE) for more information.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "AIOSeedrcc is a Python asyncrnous library for interacting with Seedr.cc API.",
    "version": "0.3.2",
    "project_urls": {
        "Documentation": "https://aioseedrcc.rtfd.io",
        "Homepage": "https://aioseedrcc.rtfd.io",
        "Repository": "https://github.com/mhdzumair/aioseedrcc"
    },
    "split_keywords": [
        "seedr",
        " seedr.cc",
        " torrent",
        " api",
        " asyncio",
        " aiohttp"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c0a1bf16dc68198614726aa708c82712df0310b52329419baff52296e857f9f7",
                "md5": "d325b71fb3842e72acb9d142ec7d2e7e",
                "sha256": "4810e24f9371b32a743987d6a45e0ec477f5eb6cebd64b22fe75d29095dbfff3"
            },
            "downloads": -1,
            "filename": "aioseedrcc-0.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d325b71fb3842e72acb9d142ec7d2e7e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 11270,
            "upload_time": "2024-12-22T05:31:18",
            "upload_time_iso_8601": "2024-12-22T05:31:18.438189Z",
            "url": "https://files.pythonhosted.org/packages/c0/a1/bf16dc68198614726aa708c82712df0310b52329419baff52296e857f9f7/aioseedrcc-0.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0d803bff820eb3bb03fa3be4f301961b38994bf0381c122a06350811bf21b8cc",
                "md5": "71d10c353f9026f2b45d257420e5d66b",
                "sha256": "00ca6256e2092fe259d2a81b151dd55e348e83150c7ce8d8c8c6d97a8ba5319e"
            },
            "downloads": -1,
            "filename": "aioseedrcc-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "71d10c353f9026f2b45d257420e5d66b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 11579,
            "upload_time": "2024-12-22T05:31:20",
            "upload_time_iso_8601": "2024-12-22T05:31:20.601710Z",
            "url": "https://files.pythonhosted.org/packages/0d/80/3bff820eb3bb03fa3be4f301961b38994bf0381c122a06350811bf21b8cc/aioseedrcc-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-22 05:31:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mhdzumair",
    "github_project": "aioseedrcc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aioseedrcc"
}
        
Elapsed time: 0.40482s