mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-05 07:44:38 +00:00
Changelog:
Backend: - ADD Search API - EXTEND Release API
This commit is contained in:
parent
642277face
commit
ed21441f9f
4 changed files with 93 additions and 2 deletions
|
@ -2,6 +2,7 @@ import uvicorn
|
|||
from fastapi import FastAPI
|
||||
from modules.pages import favorites
|
||||
from modules.pages import index
|
||||
from modules.pages import search
|
||||
from modules.release import release
|
||||
from modules.user import auth
|
||||
from modules.user import profile
|
||||
|
@ -23,6 +24,10 @@ TAGS = [
|
|||
"name": "Favorites",
|
||||
"description": "Favorites API requests",
|
||||
},
|
||||
{
|
||||
"name": "Search",
|
||||
"description": "Search API requests",
|
||||
},
|
||||
]
|
||||
|
||||
app = FastAPI()
|
||||
|
@ -34,6 +39,7 @@ app.include_router(release.router, prefix="/release", tags=["Releases"])
|
|||
|
||||
app.include_router(index.router, prefix="/index", tags=["Index"])
|
||||
app.include_router(favorites.router, prefix="/favorites", tags=["Favorites"])
|
||||
app.include_router(search.router, prefix="/search", tags=["Search"])
|
||||
|
||||
if __name__ == "__main__":
|
||||
uvicorn.run("main:app", host="0.0.0.0", port=8000)
|
||||
|
|
14
backend/modules/pages/search.py
Normal file
14
backend/modules/pages/search.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
import json
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi import Request
|
||||
from modules.proxy import apiRequest
|
||||
from modules.proxy import ENDPOINTS
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.post("", summary="Search for a release")
|
||||
async def Search(request: Request, query: str, page: int = 0):
|
||||
data = json.dumps({"query": query, "searchBy": 0})
|
||||
return await apiRequest(request, ENDPOINTS["search"], page, data=data)
|
|
@ -5,7 +5,10 @@ from fastapi import Request
|
|||
|
||||
API_URL = "https://api.anixart.tv"
|
||||
ENDPOINTS = {
|
||||
"release": f"{API_URL}/release",
|
||||
"release": {
|
||||
"info": f"{API_URL}/release",
|
||||
"episode": f"{API_URL}/episode",
|
||||
},
|
||||
"profile": f"{API_URL}/profile",
|
||||
"filter": f"{API_URL}/filter",
|
||||
"auth": f"{API_URL}/auth/signIn",
|
||||
|
@ -17,6 +20,11 @@ ENDPOINTS = {
|
|||
"delayed": f"{API_URL}/profile/list/all/4",
|
||||
"abandoned": f"{API_URL}/profile/list/all/5",
|
||||
},
|
||||
"search": f"{API_URL}/search/releases",
|
||||
"statistic": {
|
||||
"addHistory": f"{API_URL}/history/add",
|
||||
"markWatched": f"{API_URL}/episode/watch",
|
||||
},
|
||||
}
|
||||
USER_AGENT = "AnixartApp/8.2.1-23121216 (Android 11; SDK 30; arm64-v8a;)"
|
||||
|
||||
|
|
|
@ -8,4 +8,67 @@ router = APIRouter()
|
|||
|
||||
@router.get("/{release_id}", summary="Get release info by release ID")
|
||||
async def GetReleaseById(request: Request, release_id: str):
|
||||
return await apiRequest(request, ENDPOINTS["release"], release_id)
|
||||
return await apiRequest(request, ENDPOINTS["release"]["info"], release_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{release_id}/voiceover", summary="Get release voiceover info by release ID"
|
||||
)
|
||||
async def GetReleaseVoiceover(request: Request, release_id: str):
|
||||
return await apiRequest(request, ENDPOINTS["release"]["episode"], release_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{release_id}/{voiceover_id}",
|
||||
summary="Get available players for selected voiceover of an release",
|
||||
)
|
||||
async def GetReleaseVoiceoverPlayer(
|
||||
request: Request, release_id: str, voiceover_id: str
|
||||
):
|
||||
return await apiRequest(
|
||||
request, ENDPOINTS["release"]["episode"], f"{release_id}/{voiceover_id}"
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{release_id}/{voiceover_id}/{source_id}",
|
||||
summary="Get available episodes for selected voiceover and a player of an release",
|
||||
)
|
||||
async def GetReleaseEpisodes(
|
||||
request: Request, release_id: str, voiceover_id: str, source_id: str
|
||||
):
|
||||
return await apiRequest(
|
||||
request,
|
||||
ENDPOINTS["release"]["episode"],
|
||||
f"{release_id}/{voiceover_id}/{source_id}",
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{release_id}/{episode}/markWatched",
|
||||
summary="mark episode of a selected voiceover as watched",
|
||||
)
|
||||
async def MarkEpisodeAsWatched(
|
||||
request: Request, release_id: str, source_id: str, episode: str, token: str
|
||||
):
|
||||
return await apiRequest(
|
||||
request,
|
||||
ENDPOINTS["statistic"]["markWatched"],
|
||||
f"${release_id}/${source_id}/${episode}",
|
||||
query=f"?token={token}",
|
||||
)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{release_id}/{episode}/addHistory",
|
||||
summary="mark episode of a selected voiceover as watched",
|
||||
)
|
||||
async def AddEpisodeToHistory(
|
||||
request: Request, release_id: str, source_id: str, episode: str, token: str
|
||||
):
|
||||
return await apiRequest(
|
||||
request,
|
||||
ENDPOINTS["statistic"]["addHistory"],
|
||||
f"${release_id}/${source_id}/${episode}",
|
||||
query=f"?token={token}",
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue