Files
Mohamed Zumair 48b3f5e85f Migrate streaming providers functions to async & improve performance (#331)
* Migrate streaming providers functions to async & improve performance

* Fix streaming provider file selection & validate file extension as video type

* Improve RD torrent handling

* Find file based on filename or the largest file or episode based and remove index base file finding due to not trustable

* Add support for updating torrent matadata with offcloud

* Fix RD background task to update torrent metadata

* Fix OC file size callback function

* Fix AD, DL & PM

* Fix PikPak httpx client leak & use medialink for speed & set 5 min for token cache

* Migrate to AIOSeedrcc & fix season pack file selecting & refactorings

* Qbittorrent: Add support for season pack file finding & disable dht, pex, lsd on private indexer torrent

* Migrate to aiohttp for stability on resource fetching & bugfixes

* Migrated to aioseedrcc & update libs

* pass indexer type & remove Upper info hash finding
2024-11-01 15:58:39 +05:30

28 lines
869 B
Python

from fastapi import APIRouter
from fastapi.responses import JSONResponse
from aioseedrcc import Login
from db.schemas import AuthorizeData
from utils import const
router = APIRouter()
@router.get("/get-device-code")
async def get_device_code():
async with Login() as seedr_login:
device_code = await seedr_login.get_device_code()
return JSONResponse(content=device_code, headers=const.NO_CACHE_HEADERS)
@router.post("/authorize")
async def authorize(data: AuthorizeData):
async with Login() as seedr_login:
response = await seedr_login.authorize(data.device_code)
if "access_token" in response:
return JSONResponse(
content={"token": seedr_login.token}, headers=const.NO_CACHE_HEADERS
)
else:
return JSONResponse(content=response, headers=const.NO_CACHE_HEADERS)