Spaces:
Running
Running
Upload 2 files
Browse files
main.py
CHANGED
@@ -87,6 +87,7 @@ import functions as code
|
|
87 |
from fluxai import router as fluxai_router
|
88 |
from whisper import router as whisper_router
|
89 |
from instagram import router as instagram_router
|
|
|
90 |
from driver import YoutubeDriver
|
91 |
from yt_dlp import YoutubeDL
|
92 |
|
@@ -135,6 +136,7 @@ app = FastAPI(docs_url=None, redoc_url="/")
|
|
135 |
app.include_router(fluxai_router, prefix="/api/v1")
|
136 |
app.include_router(whisper_router, prefix="/api/v1")
|
137 |
app.include_router(instagram_router, prefix="/api/v1")
|
|
|
138 |
|
139 |
timeout = 100
|
140 |
|
@@ -1746,7 +1748,7 @@ def custom_openapi():
|
|
1746 |
return app.openapi_schema
|
1747 |
openapi_schema = get_openapi(
|
1748 |
title="RyuzakiLib API",
|
1749 |
-
version="
|
1750 |
summary="Use It Only For Personal Project Else I Need To Delete The Api",
|
1751 |
description=description,
|
1752 |
routes=app.routes,
|
|
|
87 |
from fluxai import router as fluxai_router
|
88 |
from whisper import router as whisper_router
|
89 |
from instagram import router as instagram_router
|
90 |
+
from tools import router as tools_router
|
91 |
from driver import YoutubeDriver
|
92 |
from yt_dlp import YoutubeDL
|
93 |
|
|
|
136 |
app.include_router(fluxai_router, prefix="/api/v1")
|
137 |
app.include_router(whisper_router, prefix="/api/v1")
|
138 |
app.include_router(instagram_router, prefix="/api/v1")
|
139 |
+
app.include_router(tools_router, prefix="/api/v1")
|
140 |
|
141 |
timeout = 100
|
142 |
|
|
|
1748 |
return app.openapi_schema
|
1749 |
openapi_schema = get_openapi(
|
1750 |
title="RyuzakiLib API",
|
1751 |
+
version="4.1.1",
|
1752 |
summary="Use It Only For Personal Project Else I Need To Delete The Api",
|
1753 |
description=description,
|
1754 |
routes=app.routes,
|
tools.py
ADDED
@@ -0,0 +1,170 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import io
|
2 |
+
import requests
|
3 |
+
import os
|
4 |
+
import re
|
5 |
+
import uuid
|
6 |
+
from PIL import Image, ImageEnhance
|
7 |
+
from fastapi import APIRouter, Depends
|
8 |
+
from fastapi.responses import StreamingResponse
|
9 |
+
from fastapi import UploadFile
|
10 |
+
from fastapi import *
|
11 |
+
from fastapi.responses import *
|
12 |
+
from fastapi.responses import JSONResponse
|
13 |
+
from fastapi import HTTPException
|
14 |
+
from dotenv import load_dotenv
|
15 |
+
from pydantic import BaseModel
|
16 |
+
from pymongo import MongoClient
|
17 |
+
from models import *
|
18 |
+
from RyuzakiLib import AsyicXSearcher
|
19 |
+
from main import validate_api_key
|
20 |
+
|
21 |
+
load_dotenv()
|
22 |
+
TOOLS_NEW_URL = os.environ["TOOLS_NEW_URL"]
|
23 |
+
router = APIRouter()
|
24 |
+
|
25 |
+
class XnxxSearch(BaseModel):
|
26 |
+
q: str
|
27 |
+
|
28 |
+
class XnxxLinks(BaseModel):
|
29 |
+
url: str
|
30 |
+
|
31 |
+
async def tools_search(
|
32 |
+
name=None,
|
33 |
+
parameter=None,
|
34 |
+
ai_model=None,
|
35 |
+
upload_check=False
|
36 |
+
):
|
37 |
+
if upload_check:
|
38 |
+
TOOLS_API_URL = f"{TOOLS_NEW_URL}/{ai_model}/{parameter}"
|
39 |
+
else:
|
40 |
+
TOOLS_API_URL = f"{TOOLS_NEW_URL}/tools/{name}?{parameter}"
|
41 |
+
return TOOLS_API_URL
|
42 |
+
|
43 |
+
async def toanime(input):
|
44 |
+
url = await tools_search(
|
45 |
+
ai_model="ai",
|
46 |
+
parameter="toanime",
|
47 |
+
upload_check=True
|
48 |
+
)
|
49 |
+
try:
|
50 |
+
image = Image.open(input)
|
51 |
+
buffer = io.BytesIO()
|
52 |
+
image.save(buffer, format='JPEG')
|
53 |
+
buffer.seek(0)
|
54 |
+
files = {
|
55 |
+
'image': ('toanime.jpg', buffer, 'image/jpeg')
|
56 |
+
}
|
57 |
+
response = requests.post(
|
58 |
+
url,
|
59 |
+
files=files,
|
60 |
+
headers={
|
61 |
+
'accept': 'application/json'
|
62 |
+
}
|
63 |
+
)
|
64 |
+
if response.status_code == 200:
|
65 |
+
data = response.json()
|
66 |
+
res = {
|
67 |
+
"image_data": data['result'],
|
68 |
+
"image_size": data['size']
|
69 |
+
}
|
70 |
+
return res
|
71 |
+
else:
|
72 |
+
return 'Identifikasi Gagal'
|
73 |
+
except Exception:
|
74 |
+
return 'Identifikasi Gagal'
|
75 |
+
|
76 |
+
@router.post("/akeno/toanime", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
77 |
+
async def toanime(
|
78 |
+
file: UploadFile = File(...),
|
79 |
+
api_key: None = Depends(validate_api_key)
|
80 |
+
):
|
81 |
+
with open(file_path, "wb") as f:
|
82 |
+
f.write(await file.read())
|
83 |
+
try:
|
84 |
+
response = await toanime(file_path)
|
85 |
+
url_image = response["image_data"]
|
86 |
+
return SuccessResponse(
|
87 |
+
status="True",
|
88 |
+
randydev={"url": url_image}
|
89 |
+
)
|
90 |
+
except:
|
91 |
+
return SuccessResponse(
|
92 |
+
status="False",
|
93 |
+
randydev={"error": "Error fucking"}
|
94 |
+
)
|
95 |
+
|
96 |
+
@router.post("/akeno/xnxxsearch", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
97 |
+
async def xnxx_search(
|
98 |
+
payload: XnxxSearch,
|
99 |
+
api_key: None = Depends(validate_api_key)
|
100 |
+
):
|
101 |
+
url = await tools_search(name="xnxxsearch", parameter=f"q={payload.query}")
|
102 |
+
try:
|
103 |
+
response = await AsyicXSearcher.search(url, re_json=True)
|
104 |
+
result = response["result"]
|
105 |
+
return SuccessResponse(
|
106 |
+
status="True",
|
107 |
+
randydev={"results": result}
|
108 |
+
)
|
109 |
+
except:
|
110 |
+
return SuccessResponse(
|
111 |
+
status="False",
|
112 |
+
randydev={"error": "Error fucking"}
|
113 |
+
)
|
114 |
+
|
115 |
+
@router.post("/akeno/xnxx-dl", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
116 |
+
async def xnxx_download(
|
117 |
+
payload: XnxxLinks,
|
118 |
+
api_key: None = Depends(validate_api_key)
|
119 |
+
):
|
120 |
+
url = await tools_search(name="xnxxdl", parameter=f"url={payload.link}")
|
121 |
+
try:
|
122 |
+
response = await AsyicXSearcher.search(url, re_json=True)
|
123 |
+
result = response["result"]
|
124 |
+
return SuccessResponse(
|
125 |
+
status="True",
|
126 |
+
randydev={"results": result}
|
127 |
+
)
|
128 |
+
except:
|
129 |
+
return SuccessResponse(
|
130 |
+
status="False",
|
131 |
+
randydev={"error": "Error fucking"}
|
132 |
+
)
|
133 |
+
|
134 |
+
@router.post("/akeno/xnxx-videodl", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
135 |
+
async def xnxx_videodl(
|
136 |
+
payload: XnxxLinks,
|
137 |
+
api_key: None = Depends(validate_api_key)
|
138 |
+
):
|
139 |
+
url = await tools_search(name="xvideosdl", parameter=f"url={payload.link}")
|
140 |
+
try:
|
141 |
+
response = await AsyicXSearcher.search(url, re_json=True)
|
142 |
+
result = response["result"]
|
143 |
+
return SuccessResponse(
|
144 |
+
status="True",
|
145 |
+
randydev={"results": result}
|
146 |
+
)
|
147 |
+
except:
|
148 |
+
return SuccessResponse(
|
149 |
+
status="False",
|
150 |
+
randydev={"error": "Error fucking"}
|
151 |
+
)
|
152 |
+
|
153 |
+
@router.post("/akeno/instagramdl", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
154 |
+
async def instagramdl(
|
155 |
+
payload: XnxxLinks,
|
156 |
+
api_key: None = Depends(validate_api_key)
|
157 |
+
):
|
158 |
+
url = await tools_search(name="instagramdl", parameter=f"url={payload.link}")
|
159 |
+
try:
|
160 |
+
response = await AsyicXSearcher.search(url, re_json=True)
|
161 |
+
result = response["result"]
|
162 |
+
return SuccessResponse(
|
163 |
+
status="True",
|
164 |
+
randydev={"results": result}
|
165 |
+
)
|
166 |
+
except:
|
167 |
+
return SuccessResponse(
|
168 |
+
status="False",
|
169 |
+
randydev={"error": "Error fucking"}
|
170 |
+
)
|