Complete Python API wrapper of seedr.cc
Project description
Python API Wrapper of Seedr.cc
Table of Contents
- Installation
- How I got the API endpoints?
- Start Guide
- Detailed Documentation
- Contributing
- Projects using this API
- License
Installation
-
Install via PyPi
pip install seedrcc
-
Install from the source
git clone https://github.com/hemantapkh/seedrcc && cd seedrcc && python setup.py sdist && pip install dist/*
How I got the API endpoints
Seedr don't provide an API to the freemium users. However, Seedr has a chrome and kodi extension that works for all users. Some of the endpoints (very few) are extracted from these extensions.
After analyzing the requests sent by the seedr site (old version), I found the seedr-site API (which needs captcha) are quiet similar to that of seedr-chrome and seedr-kode API. So, I just predicted the other endpoints.
This API works for all users since it uses the seedr-chrome and seedr-kodi API.
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.
from seedrcc import Login
seedr = Login('foo@bar.com', 'password')
response = seedr.authorize()
print(response)
# Getting the token
print(seedr.token)
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.
from seedrcc import Login
seedr = Login()
deviceCode = seedr.getDeviceCode()
# Go to https://seedr.cc/devices and paste the user code
print(deviceCode)
# Authorize with device code
response = seedr.authorize(deviceCode['device_code'])
print(response)
# Getting the token
seedr.token
✏️ 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. Also, it is recommended to set a callback function, read more about it here.
from seedrcc import Seedr
account = Seedr(token='token')
# Getting user settings
print(account.getSettings())
# Adding torrent
response = account.addTorrent('magnetlink')
print(response)
#Listing folder contents
response = account.listContents()
print(response)
Managing token
The access token may expire after 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 have at least one parameter. The first parameter of the callback function will be the updated token.
Callback function with single argument
Here is an example of callback function with a single argument which read and update the token in a file called token.txt
.
# Read the token from token.txt
token = open('token.txt', 'r').read().strip()
# Defining the callback function
def afterRefresh(token):
with open('token.txt', 'w') as f:
f.write(token)
account = Seedr(token, callbackFunc=afterRefresh)
Callback function with multiple arguments
In situations where you need to pass multiple arguments to the callback function, you can use the lambda function. Callback function with multiple arguments can be useful if your app is dealing with multiple users.
Here is an example of callback function with multiple arguments which will update the token of certain user in the database after the token of that user is refreshed.
# Defining the callback function
def afterRefresh(token, userId):
# Add your code to deal with the database
print(f'Token of the user {userId} is updated.')
# Creating a Seedr object for user 12345
account = Seedr(token='token', callbackFunc=lambda token: afterRefresh(token, userId='12345'))
Documentation
The detailled documentation of each methods is available here.
Contributing
Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Thanks to every contributors who have contributed in this project.
Projects using this API
- Torrent Seedr - Telegram bot to download torrents (Source code, Link).
Want to list your project here? Just make a pull request.
License
Distributed under the MIT License. See LICENSE for more information.
Author/Maintainer: Hemanta Pokharel
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file seedrcc-1.0.1.tar.gz
.
File metadata
- Download URL: seedrcc-1.0.1.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e19b1086e304ce24e4fc706fc444523a9b873b9e9c7802a9c0d90bbac62ed417 |
|
MD5 | cc66ea780d0f1822ce139dc92f2d87d4 |
|
BLAKE2b-256 | c92023a9ce49bcb42984ba76ce6113afbee219dd97aac1d756fae0c1834836a9 |
File details
Details for the file seedrcc-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: seedrcc-1.0.1-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c41d35b49118b5e3abb5ea643e848afad68125ccd328ebcc5e8c9a11420dd5d |
|
MD5 | c71a21b0ea221ad65e2b94b4b7547472 |
|
BLAKE2b-256 | 061f5fec2a06e4478d226ba9e3a3dbb9c31adaf1b9eee9d7194f68952d93bb40 |