randydev commited on
Commit
57422b1
1 Parent(s): 4dba342

Upload main.py

Browse files
Files changed (1) hide show
  1. main.py +158 -2
main.py CHANGED
@@ -36,6 +36,9 @@ from datetime import datetime as dt
36
  from dotenv import load_dotenv
37
  from bs4 import BeautifulSoup
38
 
 
 
 
39
  from typing import *
40
  from typing_extensions import Annotated
41
  from typing import Annotated, Union
@@ -87,7 +90,6 @@ 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 tools import router as tools_router
91
  from driver import YoutubeDriver
92
  from yt_dlp import YoutubeDL
93
 
@@ -115,6 +117,7 @@ SOURCE_ASSISTANT_GOOGLE_AI = os.environ["SOURCE_ASSISTANT_GOOGLE_AI"]
115
  SOURCE_MONITOR_URL = os.environ["SOURCE_MONITOR_URL"]
116
  SOURCE_OPENAI_ACCESS_URL = os.environ["SOURCE_OPENAI_ACCESS_URL"]
117
  SOURCE_PICSART_URL = os.environ["SOURCE_PICSART_URL"]
 
118
 
119
  # api keys
120
  REVERSE_IMAGE_API = os.environ["REVERSE_IMAGE_API"]
@@ -136,7 +139,6 @@ app = FastAPI(docs_url=None, redoc_url="/")
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
 
@@ -245,6 +247,160 @@ async def youtube_api(payload: YouTubeBase):
245
  return SuccessResponse(
246
  status="False",
247
  randydev={"error": f"An error occurred: {str(e)}"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  )
249
 
250
  @app.post("/uploadfile/")
 
36
  from dotenv import load_dotenv
37
  from bs4 import BeautifulSoup
38
 
39
+ from PIL import Image, ImageEnhance
40
+ from RyuzakiLib import AsyicXSearcher
41
+
42
  from typing import *
43
  from typing_extensions import Annotated
44
  from typing import Annotated, Union
 
90
  from fluxai import router as fluxai_router
91
  from whisper import router as whisper_router
92
  from instagram import router as instagram_router
 
93
  from driver import YoutubeDriver
94
  from yt_dlp import YoutubeDL
95
 
 
117
  SOURCE_MONITOR_URL = os.environ["SOURCE_MONITOR_URL"]
118
  SOURCE_OPENAI_ACCESS_URL = os.environ["SOURCE_OPENAI_ACCESS_URL"]
119
  SOURCE_PICSART_URL = os.environ["SOURCE_PICSART_URL"]
120
+ TOOLS_NEW_URL = os.environ["TOOLS_NEW_URL"]
121
 
122
  # api keys
123
  REVERSE_IMAGE_API = os.environ["REVERSE_IMAGE_API"]
 
139
  app.include_router(fluxai_router, prefix="/api/v1")
140
  app.include_router(whisper_router, prefix="/api/v1")
141
  app.include_router(instagram_router, prefix="/api/v1")
 
142
 
143
  timeout = 100
144
 
 
247
  return SuccessResponse(
248
  status="False",
249
  randydev={"error": f"An error occurred: {str(e)}"}
250
+
251
+ class XnxxSearch(BaseModel):
252
+ q: str
253
+
254
+ class XnxxLinks(BaseModel):
255
+ url: str
256
+
257
+ async def tools_search(
258
+ name=None,
259
+ parameter=None,
260
+ ai_model=None,
261
+ upload_check=False
262
+ ):
263
+ if upload_check:
264
+ TOOLS_API_URL = f"{TOOLS_NEW_URL}/{ai_model}/{parameter}"
265
+ return TOOLS_API_URL
266
+ else:
267
+ TOOLS_API_URL = f"{TOOLS_NEW_URL}/tools/{name}?{parameter}"
268
+ return TOOLS_API_URL
269
+
270
+ async def toanime(input):
271
+ url = await tools_search(
272
+ ai_model="ai",
273
+ parameter="toanime",
274
+ upload_check=True
275
+ )
276
+ try:
277
+ image = Image.open(input)
278
+ buffer = io.BytesIO()
279
+ image.save(buffer, format='JPEG')
280
+ buffer.seek(0)
281
+ files = {
282
+ 'image': ('toanime.jpg', buffer, 'image/jpeg')
283
+ }
284
+ response = requests.post(
285
+ url,
286
+ files=files,
287
+ headers={
288
+ 'accept': 'application/json'
289
+ }
290
+ )
291
+ if response.status_code == 200:
292
+ data = response.json()
293
+ res = {
294
+ "image_data": data['result'],
295
+ "image_size": data['size']
296
+ }
297
+ return res
298
+ else:
299
+ return 'Identifikasi Gagal'
300
+ except Exception:
301
+ return 'Identifikasi Gagal'
302
+
303
+ @app.post("/akeno/toanime", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
304
+ async def toanime_endpoint(
305
+ file: UploadFile = File(...),
306
+ api_key: str = Depends(validate_api_key)
307
+ ):
308
+ file_path = f"./uploads/{file.filename}"
309
+ try:
310
+ with open(file_path, "wb") as f:
311
+ f.write(await file.read())
312
+ except Exception:
313
+ raise HTTPException(status_code=500, detail="Failed to save file")
314
+ try:
315
+ response = await toanime(file_path)
316
+ url_image = response["image_data"]
317
+ return SuccessResponse(
318
+ status="True",
319
+ randydev={"url": url_image}
320
+ )
321
+ except Exception:
322
+ return SuccessResponse(
323
+ status="False",
324
+ randydev={"error": "Error during processing"}
325
+ )
326
+ finally:
327
+ if os.path.exists(file_path):
328
+ os.remove(file_path)
329
+
330
+ @app.post("/akeno/xnxxsearch", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
331
+ async def xnxx_search(
332
+ payload: XnxxSearch,
333
+ api_key: None = Depends(validate_api_key)
334
+ ):
335
+ url = await tools_search(name="xnxxsearch", parameter=f"q={payload.query}")
336
+ try:
337
+ response = await AsyicXSearcher.search(url, re_json=True)
338
+ result = response["result"]
339
+ return SuccessResponse(
340
+ status="True",
341
+ randydev={"results": result}
342
+ )
343
+ except:
344
+ return SuccessResponse(
345
+ status="False",
346
+ randydev={"error": "Error fucking"}
347
+ )
348
+
349
+ @app.post("/akeno/xnxx-dl", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
350
+ async def xnxx_download(
351
+ payload: XnxxLinks,
352
+ api_key: None = Depends(validate_api_key)
353
+ ):
354
+ url = await tools_search(name="xnxxdl", parameter=f"url={payload.link}")
355
+ try:
356
+ response = await AsyicXSearcher.search(url, re_json=True)
357
+ result = response["result"]
358
+ return SuccessResponse(
359
+ status="True",
360
+ randydev={"results": result}
361
+ )
362
+ except:
363
+ return SuccessResponse(
364
+ status="False",
365
+ randydev={"error": "Error fucking"}
366
+ )
367
+
368
+ @app.post("/akeno/xnxx-videodl", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
369
+ async def xnxx_videodl(
370
+ payload: XnxxLinks,
371
+ api_key: None = Depends(validate_api_key)
372
+ ):
373
+ url = await tools_search(name="xvideosdl", parameter=f"url={payload.link}")
374
+ try:
375
+ response = await AsyicXSearcher.search(url, re_json=True)
376
+ result = response["result"]
377
+ return SuccessResponse(
378
+ status="True",
379
+ randydev={"results": result}
380
+ )
381
+ except:
382
+ return SuccessResponse(
383
+ status="False",
384
+ randydev={"error": "Error fucking"}
385
+ )
386
+
387
+ @app.post("/akeno/instagramdl", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
388
+ async def instagramdl(
389
+ payload: XnxxLinks,
390
+ api_key: None = Depends(validate_api_key)
391
+ ):
392
+ url = await tools_search(name="instagramdl", parameter=f"url={payload.link}")
393
+ try:
394
+ response = await AsyicXSearcher.search(url, re_json=True)
395
+ result = response["result"]
396
+ return SuccessResponse(
397
+ status="True",
398
+ randydev={"results": result}
399
+ )
400
+ except:
401
+ return SuccessResponse(
402
+ status="False",
403
+ randydev={"error": "Error fucking"}
404
  )
405
 
406
  @app.post("/uploadfile/")