Package: seedrcc
Python API Wrapper of Seedr.ccTable of ContentsInstallationHow I got the API endpoints?Start GuideGetting TokenLogging with Username and PasswordAuthorizing with device codeBasic ExamplesManaging tokenCallback functionFunction with single argumentFunction with multiple argumentsDetailed DocumentationContributingProjects using this APILicenseInstallationInstall viaPyPipipinstallseedrccInstall from the sourcegitclonehttps://github.com/hemantapkh/seedrcc&&cdseedrcc&&pythonsetup.pysdist&&pipinstalldist/*How I got the API endpointsSeedr don't provide anAPIto the freemium users. However, Seedr has achromeandkodiextension 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 guideGetting TokenThere are two methods to get the account token. You can login with username/password or by authorizing with device code.Logging with Username and PasswordThis method uses the seedr Chrome extension API.fromseedrccimportLoginseedr=Login('foo@bar.com','password')response=seedr.authorize()print(response)# Getting the tokenprint(seedr.token)Authorizing with device codeThis method uses the seedr kodi API.To use this method, generate a device & user code. Paste the user code inhttps://seedr.cc/devicesand authorize with the device code.fromseedrccimportLoginseedr=Login()deviceCode=seedr.getDeviceCode()# Go to https://seedr.cc/devices and paste the user codeprint(deviceCode)# Authorize with device coderesponse=seedr.authorize(deviceCode['device_code'])print(response)# Getting the tokenseedr.token✏️ Note: You must use the token from the instance variable ‘token’ instead of the ‘access_token’ or ‘refresh_token’ from the response.Basic ExamplesFor all available methods, please refer to thedocumentation. Also, it is recommended to set a callback function, read more about ithere.fromseedrccimportSeedraccount=Seedr(token='token')# Getting user settingsprint(account.getSettings())# Adding torrentresponse=account.addTorrent('magnetlink')print(response)#Listing folder contentsresponse=account.listContents()print(response)Managing tokenThe 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 functionYou 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 argumentHere is an example of callback function with a single argument which read and update the token in a file calledtoken.txt.# Read the token from token.txttoken=open('token.txt','r').read().strip()# Defining the callback functiondefafterRefresh(token):withopen('token.txt','w')asf:f.write(token)account=Seedr(token,callbackFunc=afterRefresh)Callback function with multiple argumentsIn 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 functiondefafterRefresh(token,userId):# Add your code to deal with the databaseprint(f'Token of the user{userId}is updated.')# Creating a Seedr object for user 12345account=Seedr(token='token',callbackFunc=lambdatoken:afterRefresh(token,userId='12345'))DocumentationThe detailled documentation of each methods is availablehere.ContributingAny contributions you make aregreatly appreciated.Fork the ProjectCreate 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 RequestThanks to everycontributorswho have contributed in this project.Projects using this APITorrent Seedr - Telegram bot to download torrents (Source code,Link).Want to list your project here? Just make a pull request.LicenseDistributed under the MIT License. SeeLICENSEfor more information.Author/Maintainer:Hemanta Pokharel