sonicbit


Namesonicbit JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/viperadnan-git/sonicbit-python-sdk
SummaryAn unofficial Python SDK for SonicBit which uses the internal API to interact with the application.
upload_time2024-10-01 13:37:23
maintainerNone
docs_urlNone
authorAdnan Ahmad
requires_python>=3.10
licenseGNU General Public License v3.0
keywords sonicbit python sdk
VCS
bugtrack_url
requirements requests
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SonicBit Python SDK

An unofficial Python SDK for SonicBit which uses the internal API to interact with the application.

> [!WARNING]  
> This SDK is provided as-is and is not officially supported by SonicBit. The author is not responsible for any damages or losses caused by the use of this SDK. Use it at your own risk. Please use it responsibly and with the understanding that it may not be fully functional or reliable. Check SonicBit's terms of service for more information.

## Installation

Install the package using pip:

```bash
pip install sonicbit
```

Install bleeding edge version:

```bash
pip install git+https://github.com/viperadnan-git/sonicbit-python-sdk.git
```

## Usage

> [!IMPORTANT]  
> This SDK is still in development and may not be fully functional. Please report any issues or bugs you encounter.
> The below documentation is generated by AI and is subject to change as the SDK evolves.

To use the SDK, you need to create an instance of the `SonicBit` class and provide your email and password:

```python
from sonicbit import SonicBit

sb = SonicBit(email='your_email@example.com', password='your_password')
```

Once you have an instance of `SonicBit`, you can use its various methods to interact with the application. For example, to list the files in your storage:

```python
files = sb.list_files()
print(files)
```

### Token Handling

By default, the SDK will store your authentication token in a file named `.sonicbit.cache` in the current working directory. If you want to specify a different location for the token file, you can pass a `token_handler` argument to the `SonicBit` constructor:

```python
sb = SonicBit(email='your_email@example.com', password='your_password', token_handler=MyTokenHandler())
```

The `token_handler` should implement the following methods:

-   `read(email: str) -> str | None`: Reads the token for the given email from the token file.
-   `write(email: str, token: str) -> None`: Writes the token for the given email to the token file.

The `token_handler` is optional and will default to a `TokenFileHandler` if not provided.

> [!TIP]  
> You can use the `TokenHandler` class to store and update tokens in a database or other storage mechanism. Simply implement the `read` and `write` methods and pass an instance of your custom class to the `SonicBit` constructor. This will allow you to store tokens in a secure location and easily update them as needed.

### User Module

The `User` module provides methods for interacting with the user's account, such as getting their user details and storage details.

#### User Details

To get the user's details, you can use the `get_user_details` method:

```python
details = sb.get_user_details()
print(details)
```

This will print a `UserDetails` object containing information about the user's account, such as their email, plan name, and more.

#### Storage Details

To get the storage details, you can use the `get_storage_details` method:

```python
details = sb.get_storage_details()
print(details)
```

This will print a `StorageDetails` object containing information about the user's storage, such as their total storage size, free space, and more.

#### Clear Storage

To clear the user's storage, you can use the `clear_storage` method:

```python
success = sb.clear_storage()
print(success)
```

This will return `True` if the storage was successfully cleared, or `False` if there was an error.

### Torrent Management

The `Torrent` module provides methods for interacting with the user's torrents, such as adding, listing, and deleting torrents.

#### Add Torrent

To add a torrent, you can use the `add_torrent` method:

```python
torrents = sb.add_torrent("https://example.com/torrent.torrent")
print(torrents)
```

This will return a list of torrent hashes that were added.

#### List Torrents

To list the user's torrents, you can use the `list_torrents` method:

```python
torrents = sb.list_torrents()
print(torrents)
```

This will print a `TorrentList` object containing information about each torrent in the user's storage, such as the torrent name, hash, size, progress, and more.

#### Get Torrent Details

To get the details of a torrent, you can use the `get_torrent_details` method:

```python
details = sb.get_torrent_details("hash")
print(details)
```

This will print a `TorrentDetails` object containing information about the torrent, such as the files it contains, the download rate, and more.

#### Delete Torrent

To delete a torrent, you can use the `delete_torrent` method:

```python
success = sb.delete_torrent("hash")
print(success)
```

This will return `True` if the torrent was successfully deleted, or `False` if there was an error.

### Remote Download Management

The `RemoteDownload` module provides methods for interacting with the user's remote downloads, such as adding, listing, and deleting remote downloads.

#### Add Remote Download

To add a remote download, you can use the `add_remote_download` method:

```python
success = sb.add_remote_download("https://example.com/file.torrent", PathInfo.root())
print(success)
```

This will return `True` if the remote download was successfully added, or `False` if there was an error.

#### List Remote Downloads

To list the user's remote downloads, you can use the `list_remote_downloads` method:

```python
downloads = sb.list_remote_downloads()
print(downloads)
```

This will print a `RemoteTaskList` object containing information about each remote download in the user's storage, such as the download URL, progress, and more.

#### Delete Remote Download

To delete a remote download, you can use the `delete_remote_download` method:

```python
success = sb.delete_remote_download(id)
print(success)
```

This will return `True` if the remote download was successfully deleted, or `False` if there was an error.

### File Management

The `File` module provides methods for interacting with the user's files, such as listing, deleting, and moving files.

#### List Files

To list the user's files, you can use the `list_files` method:

```python
files = sb.list_files()
print(files)
```

This will print a `FileList` object containing information about each file in the user's storage, such as the file name, size, and more.

#### Delete File

To delete a file, you can use the `delete_file` method:

```python
success = sb.delete_file("path/to/file")
print(success)
```

This will return `True` if the file was successfully deleted, or `False` if there was an error.

### Sign Up

The `Signup` module provides methods for signing up to SonicBit.

#### Sign Up

To sign up to SonicBit, you can use the `signup` method:

```python
def otp_callback(email):
    return input(f"Enter OTP for {email}: ")

success = SonicBit.signup("John Doe", "email@example.com", "password", otp_callback)
print(success)
```

This will return `True` if the signup was successful, or `False` if there was an error.

> [!NOTE]  
> If `otp_callback` is provided the `signup` method will automatically complete the signup process by submitting the OTP code and skipping tutorial. If `otp_callback` is not provided, the user will need to manually complete the signup process by submitting the OTP code and skipping tutorial. Once signup is complete, the user can use the `submit_otp` method to submit the OTP code.

#### Submit OTP

To submit the OTP code, you can use the `submit_otp` method:

```python
success = SonicBit.submit_otp("123456")
print(success)
```

This will return `True` if the OTP code was successfully submitted, or `False` if there was an error.

#### Complete Signup Tutorial (Optional)

To complete the signup tutorial, you can use the `_complete_tutorial` method:

```python
SonicBit._complete_tutorial("token")
```

This will mark the tutorial as completed and allow the user to access their account.


## Contributing

Contributions are welcome! If you find a bug or have a suggestion for a new feature, please open an issue or submit a pull request on the GitHub repository.

## License

This project is licensed under the GNU General Public License v3.0. See the [LICENSE](LICENSE) file for more details.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/viperadnan-git/sonicbit-python-sdk",
    "name": "sonicbit",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "sonicbit python sdk",
    "author": "Adnan Ahmad",
    "author_email": "viperadnan@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e7/97/53e4e05809f772dd8850ce38eb0a1283b71f6937390d37a8128bafa66f25/sonicbit-0.2.2.tar.gz",
    "platform": null,
    "description": "# SonicBit Python SDK\n\nAn unofficial Python SDK for SonicBit which uses the internal API to interact with the application.\n\n> [!WARNING]  \n> This SDK is provided as-is and is not officially supported by SonicBit. The author is not responsible for any damages or losses caused by the use of this SDK. Use it at your own risk. Please use it responsibly and with the understanding that it may not be fully functional or reliable. Check SonicBit's terms of service for more information.\n\n## Installation\n\nInstall the package using pip:\n\n```bash\npip install sonicbit\n```\n\nInstall bleeding edge version:\n\n```bash\npip install git+https://github.com/viperadnan-git/sonicbit-python-sdk.git\n```\n\n## Usage\n\n> [!IMPORTANT]  \n> This SDK is still in development and may not be fully functional. Please report any issues or bugs you encounter.\n> The below documentation is generated by AI and is subject to change as the SDK evolves.\n\nTo use the SDK, you need to create an instance of the `SonicBit` class and provide your email and password:\n\n```python\nfrom sonicbit import SonicBit\n\nsb = SonicBit(email='your_email@example.com', password='your_password')\n```\n\nOnce you have an instance of `SonicBit`, you can use its various methods to interact with the application. For example, to list the files in your storage:\n\n```python\nfiles = sb.list_files()\nprint(files)\n```\n\n### Token Handling\n\nBy default, the SDK will store your authentication token in a file named `.sonicbit.cache` in the current working directory. If you want to specify a different location for the token file, you can pass a `token_handler` argument to the `SonicBit` constructor:\n\n```python\nsb = SonicBit(email='your_email@example.com', password='your_password', token_handler=MyTokenHandler())\n```\n\nThe `token_handler` should implement the following methods:\n\n-   `read(email: str) -> str | None`: Reads the token for the given email from the token file.\n-   `write(email: str, token: str) -> None`: Writes the token for the given email to the token file.\n\nThe `token_handler` is optional and will default to a `TokenFileHandler` if not provided.\n\n> [!TIP]  \n> You can use the `TokenHandler` class to store and update tokens in a database or other storage mechanism. Simply implement the `read` and `write` methods and pass an instance of your custom class to the `SonicBit` constructor. This will allow you to store tokens in a secure location and easily update them as needed.\n\n### User Module\n\nThe `User` module provides methods for interacting with the user's account, such as getting their user details and storage details.\n\n#### User Details\n\nTo get the user's details, you can use the `get_user_details` method:\n\n```python\ndetails = sb.get_user_details()\nprint(details)\n```\n\nThis will print a `UserDetails` object containing information about the user's account, such as their email, plan name, and more.\n\n#### Storage Details\n\nTo get the storage details, you can use the `get_storage_details` method:\n\n```python\ndetails = sb.get_storage_details()\nprint(details)\n```\n\nThis will print a `StorageDetails` object containing information about the user's storage, such as their total storage size, free space, and more.\n\n#### Clear Storage\n\nTo clear the user's storage, you can use the `clear_storage` method:\n\n```python\nsuccess = sb.clear_storage()\nprint(success)\n```\n\nThis will return `True` if the storage was successfully cleared, or `False` if there was an error.\n\n### Torrent Management\n\nThe `Torrent` module provides methods for interacting with the user's torrents, such as adding, listing, and deleting torrents.\n\n#### Add Torrent\n\nTo add a torrent, you can use the `add_torrent` method:\n\n```python\ntorrents = sb.add_torrent(\"https://example.com/torrent.torrent\")\nprint(torrents)\n```\n\nThis will return a list of torrent hashes that were added.\n\n#### List Torrents\n\nTo list the user's torrents, you can use the `list_torrents` method:\n\n```python\ntorrents = sb.list_torrents()\nprint(torrents)\n```\n\nThis will print a `TorrentList` object containing information about each torrent in the user's storage, such as the torrent name, hash, size, progress, and more.\n\n#### Get Torrent Details\n\nTo get the details of a torrent, you can use the `get_torrent_details` method:\n\n```python\ndetails = sb.get_torrent_details(\"hash\")\nprint(details)\n```\n\nThis will print a `TorrentDetails` object containing information about the torrent, such as the files it contains, the download rate, and more.\n\n#### Delete Torrent\n\nTo delete a torrent, you can use the `delete_torrent` method:\n\n```python\nsuccess = sb.delete_torrent(\"hash\")\nprint(success)\n```\n\nThis will return `True` if the torrent was successfully deleted, or `False` if there was an error.\n\n### Remote Download Management\n\nThe `RemoteDownload` module provides methods for interacting with the user's remote downloads, such as adding, listing, and deleting remote downloads.\n\n#### Add Remote Download\n\nTo add a remote download, you can use the `add_remote_download` method:\n\n```python\nsuccess = sb.add_remote_download(\"https://example.com/file.torrent\", PathInfo.root())\nprint(success)\n```\n\nThis will return `True` if the remote download was successfully added, or `False` if there was an error.\n\n#### List Remote Downloads\n\nTo list the user's remote downloads, you can use the `list_remote_downloads` method:\n\n```python\ndownloads = sb.list_remote_downloads()\nprint(downloads)\n```\n\nThis will print a `RemoteTaskList` object containing information about each remote download in the user's storage, such as the download URL, progress, and more.\n\n#### Delete Remote Download\n\nTo delete a remote download, you can use the `delete_remote_download` method:\n\n```python\nsuccess = sb.delete_remote_download(id)\nprint(success)\n```\n\nThis will return `True` if the remote download was successfully deleted, or `False` if there was an error.\n\n### File Management\n\nThe `File` module provides methods for interacting with the user's files, such as listing, deleting, and moving files.\n\n#### List Files\n\nTo list the user's files, you can use the `list_files` method:\n\n```python\nfiles = sb.list_files()\nprint(files)\n```\n\nThis will print a `FileList` object containing information about each file in the user's storage, such as the file name, size, and more.\n\n#### Delete File\n\nTo delete a file, you can use the `delete_file` method:\n\n```python\nsuccess = sb.delete_file(\"path/to/file\")\nprint(success)\n```\n\nThis will return `True` if the file was successfully deleted, or `False` if there was an error.\n\n### Sign Up\n\nThe `Signup` module provides methods for signing up to SonicBit.\n\n#### Sign Up\n\nTo sign up to SonicBit, you can use the `signup` method:\n\n```python\ndef otp_callback(email):\n    return input(f\"Enter OTP for {email}: \")\n\nsuccess = SonicBit.signup(\"John Doe\", \"email@example.com\", \"password\", otp_callback)\nprint(success)\n```\n\nThis will return `True` if the signup was successful, or `False` if there was an error.\n\n> [!NOTE]  \n> If `otp_callback` is provided the `signup` method will automatically complete the signup process by submitting the OTP code and skipping tutorial. If `otp_callback` is not provided, the user will need to manually complete the signup process by submitting the OTP code and skipping tutorial. Once signup is complete, the user can use the `submit_otp` method to submit the OTP code.\n\n#### Submit OTP\n\nTo submit the OTP code, you can use the `submit_otp` method:\n\n```python\nsuccess = SonicBit.submit_otp(\"123456\")\nprint(success)\n```\n\nThis will return `True` if the OTP code was successfully submitted, or `False` if there was an error.\n\n#### Complete Signup Tutorial (Optional)\n\nTo complete the signup tutorial, you can use the `_complete_tutorial` method:\n\n```python\nSonicBit._complete_tutorial(\"token\")\n```\n\nThis will mark the tutorial as completed and allow the user to access their account.\n\n\n## Contributing\n\nContributions are welcome! If you find a bug or have a suggestion for a new feature, please open an issue or submit a pull request on the GitHub repository.\n\n## License\n\nThis project is licensed under the GNU General Public License v3.0. See the [LICENSE](LICENSE) file for more details.\n",
    "bugtrack_url": null,
    "license": "GNU General Public License v3.0",
    "summary": "An unofficial Python SDK for SonicBit which uses the internal API to interact with the application.",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/viperadnan-git/sonicbit-python-sdk"
    },
    "split_keywords": [
        "sonicbit",
        "python",
        "sdk"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e9848eede12be45d14ffbb2cf1c3abbdcbc22c42ec87ebe77a80648628505fc0",
                "md5": "3906e8b1e331481df9338cf2f53d23cd",
                "sha256": "751757a127cd424b80e5877a62965faef338e368604202fff2693adb6ff6ed55"
            },
            "downloads": -1,
            "filename": "sonicbit-0.2.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3906e8b1e331481df9338cf2f53d23cd",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 35857,
            "upload_time": "2024-10-01T13:37:22",
            "upload_time_iso_8601": "2024-10-01T13:37:22.100063Z",
            "url": "https://files.pythonhosted.org/packages/e9/84/8eede12be45d14ffbb2cf1c3abbdcbc22c42ec87ebe77a80648628505fc0/sonicbit-0.2.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e79753e4e05809f772dd8850ce38eb0a1283b71f6937390d37a8128bafa66f25",
                "md5": "7148b3e8f51bde8a1dd5cef760c8c74a",
                "sha256": "37ee92f30b07081a1d28116e0949802e878d3250344a84743ea5cbb415f5e2e8"
            },
            "downloads": -1,
            "filename": "sonicbit-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "7148b3e8f51bde8a1dd5cef760c8c74a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 27548,
            "upload_time": "2024-10-01T13:37:23",
            "upload_time_iso_8601": "2024-10-01T13:37:23.081897Z",
            "url": "https://files.pythonhosted.org/packages/e7/97/53e4e05809f772dd8850ce38eb0a1283b71f6937390d37a8128bafa66f25/sonicbit-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-01 13:37:23",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "viperadnan-git",
    "github_project": "sonicbit-python-sdk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "requests",
            "specs": [
                [
                    ">=",
                    "2.28.1"
                ]
            ]
        }
    ],
    "lcname": "sonicbit"
}
        
Elapsed time: 0.32871s