mirror of
https://github.com/Radiquum/AniX.git
synced 2025-04-30 18:09:40 +05:00
ADD New Pre-Commit hooks and Formatting code
This commit is contained in:
parent
5c9c3e67fa
commit
9e75a0783c
26 changed files with 4163 additions and 105 deletions
|
@ -1,36 +0,0 @@
|
|||
# See https://pre-commit.com for more information
|
||||
# See https://pre-commit.com/hooks.html for more hooks
|
||||
repos:
|
||||
- repo: https://github.com/psf/black
|
||||
rev: 24.4.0
|
||||
hooks:
|
||||
- id: black
|
||||
args: [--safe]
|
||||
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v4.5.0
|
||||
hooks:
|
||||
- id: trailing-whitespace
|
||||
- id: end-of-file-fixer
|
||||
- id: check-yaml
|
||||
- id: check-added-large-files
|
||||
- id: debug-statements
|
||||
language_version: python3
|
||||
|
||||
- repo: https://github.com/PyCQA/flake8
|
||||
rev: 7.0.0
|
||||
hooks:
|
||||
- id: flake8
|
||||
language_version: python3
|
||||
|
||||
- repo: https://github.com/asottile/reorder_python_imports
|
||||
rev: v3.12.0
|
||||
hooks:
|
||||
- id: reorder-python-imports
|
||||
args: [--py39-plus]
|
||||
|
||||
- repo: https://github.com/asottile/pyupgrade
|
||||
rev: v3.15.2
|
||||
hooks:
|
||||
- id: pyupgrade
|
||||
args: [--py39-plus]
|
|
@ -31,11 +31,13 @@ TAGS = [
|
|||
]
|
||||
|
||||
app = FastAPI(
|
||||
openapi_tags=TAGS,
|
||||
title="AniX API",
|
||||
description="unofficial API proxy for Anixart android application.",
|
||||
openapi_url="/api/openapi.json",
|
||||
docs_url="/api/docs", redoc_url=None)
|
||||
openapi_tags=TAGS,
|
||||
title="AniX API",
|
||||
description="unofficial API proxy for Anixart android application.",
|
||||
openapi_url="/api/openapi.json",
|
||||
docs_url="/api/docs",
|
||||
redoc_url=None,
|
||||
)
|
||||
|
||||
app.include_router(profile.router, prefix="/api/profile", tags=["Profile"])
|
||||
app.include_router(auth.router, prefix="/api/auth", tags=["Profile"])
|
||||
|
|
|
@ -1,10 +1,22 @@
|
|||
from typing import TypedDict
|
||||
from typing import Union
|
||||
|
||||
import requests
|
||||
from fastapi import Request
|
||||
|
||||
|
||||
class Endpoints(TypedDict):
|
||||
release: dict[str, str]
|
||||
profile: str
|
||||
filter: str
|
||||
auth: str
|
||||
user: dict[str, str]
|
||||
search: str
|
||||
statistic: dict[str, str]
|
||||
|
||||
|
||||
API_URL = "https://api.anixart.tv"
|
||||
ENDPOINTS = {
|
||||
ENDPOINTS: Endpoints = {
|
||||
"release": {
|
||||
"info": f"{API_URL}/release",
|
||||
"episode": f"{API_URL}/episode",
|
||||
|
@ -30,10 +42,9 @@ USER_AGENT = "AnixartApp/8.2.1-23121216 (Android 11; SDK 30; arm64-v8a;)"
|
|||
|
||||
|
||||
async def apiRequest(
|
||||
# noqa: E501
|
||||
request: Request = None,
|
||||
endpoint: str = "",
|
||||
path: str = "",
|
||||
endpoint: Union[str, Endpoints] = "",
|
||||
path: Union[str, int] = "",
|
||||
query: str = "",
|
||||
data: Union[None, str, dict] = None,
|
||||
):
|
||||
|
|
|
@ -11,9 +11,7 @@ async def GetReleaseById(request: Request, release_id: str):
|
|||
return await apiRequest(request, ENDPOINTS["release"]["info"], release_id)
|
||||
|
||||
|
||||
@router.get(
|
||||
"/{release_id}/voiceover", summary="Get release voiceover info"
|
||||
)
|
||||
@router.get("/{release_id}/voiceover", summary="Get release voiceover info")
|
||||
async def GetReleaseVoiceover(request: Request, release_id: str):
|
||||
return await apiRequest(request, ENDPOINTS["release"]["episode"], release_id)
|
||||
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
from typing import Union
|
||||
|
||||
from fastapi import APIRouter
|
||||
from fastapi import Request
|
||||
from modules.proxy import apiRequest
|
||||
from modules.proxy import ENDPOINTS
|
||||
from typing import Union
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/{user_id}", summary="Get user profile by user ID")
|
||||
async def getUserById(request: Request, user_id: str, short: bool = False, token: Union[None, str] = None):
|
||||
async def getUserById(
|
||||
request: Request, user_id: str, short: bool = False, token: Union[None, str] = None
|
||||
):
|
||||
query = ""
|
||||
if token:
|
||||
query = f"?token={token}"
|
||||
|
@ -23,5 +26,5 @@ async def getUserById(request: Request, user_id: str, short: bool = False, token
|
|||
"login": res["profile"]["login"],
|
||||
"avatar": res["profile"]["avatar"],
|
||||
},
|
||||
"is_my_profile": res["is_my_profile"]
|
||||
"is_my_profile": res["is_my_profile"],
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue