Spaces:
Running
Running
Upload main.py
Browse files
main.py
CHANGED
@@ -17,27 +17,30 @@
|
|
17 |
# You should have received a copy of the GNU Affero General Public License
|
18 |
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
19 |
|
20 |
-
import requests
|
21 |
import json
|
22 |
-
import base64
|
23 |
import re
|
24 |
-
import uvicorn
|
25 |
import os
|
|
|
|
|
|
|
|
|
26 |
import shutil
|
27 |
import random
|
28 |
import tempfile
|
29 |
-
import io
|
30 |
import string
|
31 |
import openai
|
32 |
import uuid
|
33 |
import time
|
|
|
|
|
|
|
|
|
34 |
from io import BytesIO
|
35 |
from datetime import datetime as dt
|
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
|
@@ -76,6 +79,7 @@ from RyuzakiLib.hackertools.chatgpt import RendyDevChat
|
|
76 |
from RyuzakiLib.hackertools.gemini import GeminiLatest
|
77 |
from RyuzakiLib.hackertools.openai_api import OpenAI
|
78 |
from RyuzakiLib.hackertools.huggingface import FaceAI
|
|
|
79 |
|
80 |
from RyuzakiLib.mental import BadWordsList
|
81 |
from RyuzakiLib.system import System
|
@@ -435,6 +439,127 @@ async def search_porn_images(query):
|
|
435 |
except requests.exceptions.RequestException:
|
436 |
return []
|
437 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
438 |
@app.get("/akeno/pornpics", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
439 |
async def pornpics(query: str):
|
440 |
try:
|
@@ -2125,7 +2250,7 @@ def custom_openapi():
|
|
2125 |
return app.openapi_schema
|
2126 |
openapi_schema = get_openapi(
|
2127 |
title="RyuzakiLib API",
|
2128 |
-
version="4.1.
|
2129 |
summary="Use It Only For Personal Project Else I Need To Delete The Api",
|
2130 |
description=description,
|
2131 |
routes=app.routes,
|
|
|
17 |
# You should have received a copy of the GNU Affero General Public License
|
18 |
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
19 |
|
|
|
20 |
import json
|
|
|
21 |
import re
|
|
|
22 |
import os
|
23 |
+
import io
|
24 |
+
import requests
|
25 |
+
import base64
|
26 |
+
import uvicorn
|
27 |
import shutil
|
28 |
import random
|
29 |
import tempfile
|
|
|
30 |
import string
|
31 |
import openai
|
32 |
import uuid
|
33 |
import time
|
34 |
+
import hashlib
|
35 |
+
import httpx
|
36 |
+
import asyncio
|
37 |
+
|
38 |
from io import BytesIO
|
39 |
from datetime import datetime as dt
|
40 |
from dotenv import load_dotenv
|
41 |
from bs4 import BeautifulSoup
|
42 |
|
43 |
from PIL import Image, ImageEnhance
|
|
|
44 |
|
45 |
from typing import *
|
46 |
from typing_extensions import Annotated
|
|
|
79 |
from RyuzakiLib.hackertools.gemini import GeminiLatest
|
80 |
from RyuzakiLib.hackertools.openai_api import OpenAI
|
81 |
from RyuzakiLib.hackertools.huggingface import FaceAI
|
82 |
+
from RyuzakiLib import AsyicXSearcher
|
83 |
|
84 |
from RyuzakiLib.mental import BadWordsList
|
85 |
from RyuzakiLib.system import System
|
|
|
439 |
except requests.exceptions.RequestException:
|
440 |
return []
|
441 |
|
442 |
+
async def pinterest_api_v2(search):
|
443 |
+
if not search:
|
444 |
+
return SuccessResponse(
|
445 |
+
status="False",
|
446 |
+
randydev={"error": "pinterest API"}
|
447 |
+
)
|
448 |
+
headers = {
|
449 |
+
'authority': 'www.pinterest.com',
|
450 |
+
'cache-control': 'max-age=0',
|
451 |
+
'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
|
452 |
+
'upgrade-insecure-requests': '1',
|
453 |
+
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36',
|
454 |
+
'sec-gpc': '1',
|
455 |
+
'sec-fetch-site': 'same-origin',
|
456 |
+
'sec-fetch-mode': 'same-origin',
|
457 |
+
'sec-fetch-dest': 'empty',
|
458 |
+
'accept-language': 'en-US,en;q=0.9',
|
459 |
+
'cookie': 'csrftoken=92c7c57416496066c4cd5a47a2448e28; g_state={"i_l":0}; _auth=1; _pinterest_sess=TWc9PSZBMEhrWHJZbHhCVW1OSzE1MW0zSkVid1o4Uk1laXRzdmNwYll3eEFQV0lDSGNRaDBPTGNNUk5JQTBhczFOM0ZJZ1ZJbEpQYlIyUmFkNzlBV2kyaDRiWTI4THFVUWhpNUpRYjR4M2dxblJCRFhESlBIaGMwbjFQWFc2NHRtL3RUcTZna1c3K0VjVTgyejFDa1VqdXQ2ZEQ3NG91L1JTRHZwZHNIcDZraEp1L0lCbkJWUytvRis2ckdrVlNTVytzOFp3ZlpTdWtCOURnbGc3SHhQOWJPTzArY3BhMVEwOTZDVzg5VDQ3S1NxYXZGUEEwOTZBR21LNC9VZXRFTkErYmtIOW9OOEU3ektvY3ZhU0hZWVcxS0VXT3dTaFpVWXNuOHhiQWdZdS9vY24wMnRvdjBGYWo4SDY3MEYwSEtBV2JxYisxMVVsV01McmpKY0VOQ3NYSUt2ZDJaWld6T0RacUd6WktITkRpZzRCaWlCTjRtVXNMcGZaNG9QcC80Ty9ZZWFjZkVGNURNZWVoNTY4elMyd2wySWhtdWFvS2dQcktqMmVUYmlNODBxT29XRWx5dWZSc1FDY0ZONlZJdE9yUGY5L0p3M1JXYkRTUDAralduQ2xxR3VTZzBveUc2Ykx3VW5CQ0FQeVo5VE8wTEVmamhwWkxwMy9SaTNlRUpoQmNQaHREbjMxRlRrOWtwTVI5MXl6cmN1K2NOTFNyU1cyMjREN1ZFSHpHY0ZCR1RocWRjVFZVWG9VcVpwbXNGdlptVzRUSkNadVc1TnlBTVNGQmFmUmtrNHNkVEhXZytLQjNUTURlZXBUMG9GZ3YwQnVNcERDak16Nlp0Tk13dmNsWG82U2xIKyt5WFhSMm1QUktYYmhYSDNhWnB3RWxTUUttQklEeGpCdE4wQlNNOVRzRXE2NkVjUDFKcndvUzNMM2pMT2dGM05WalV2QStmMC9iT055djFsYVBKZjRFTkRtMGZZcWFYSEYvNFJrYTZSbVRGOXVISER1blA5L2psdURIbkFxcTZLT3RGeGswSnRHdGNpN29KdGFlWUxtdHNpSjNXQVorTjR2NGVTZWkwPSZzd3cwOXZNV3VpZlprR0VBempKdjZqS00ybWM9; _b="AV+pPg4VpvlGtL+qN4q0j+vNT7JhUErvp+4TyMybo+d7CIZ9QFohXDj6+jQlg9uD6Zc="; _routing_id="d5da9818-8ce2-4424-ad1e-d55dfe1b9aed"; sessionFunnelEventLogged=1'
|
460 |
+
}
|
461 |
+
url = f'https://www.pinterest.com/search/pins/?q={search}&rs=typed&term_meta[]={search}|typed'
|
462 |
+
try:
|
463 |
+
response = requests.get(url, headers=headers)
|
464 |
+
arr_match = re.findall(r'https://i\.pinimg\.com/originals/[^.]+\.jpg', response.text)
|
465 |
+
my_data = {
|
466 |
+
"count": len(arr_match),
|
467 |
+
"data": arr_match
|
468 |
+
}
|
469 |
+
return my_data
|
470 |
+
except Exception as error:
|
471 |
+
return SuccessResponse(
|
472 |
+
status="False",
|
473 |
+
randydev={"error": "An error occurred while fetching data"}
|
474 |
+
)
|
475 |
+
|
476 |
+
def _get_image_md5_content(file_path: str) -> Tuple[str, bytes]:
|
477 |
+
with open(file_path, "rb") as fp:
|
478 |
+
content = fp.read()
|
479 |
+
image_md5 = base64.b64encode(hashlib.md5(content).digest()).decode("utf-8")
|
480 |
+
return image_md5, content
|
481 |
+
|
482 |
+
async def enhance_photo_and_remini(api_key: str, file_path: str):
|
483 |
+
CONTENT_TYPE = "image/jpeg"
|
484 |
+
_TIMEOUT = 60
|
485 |
+
_BASE_URL = "https://developer.remini.ai/api"
|
486 |
+
image_md5, content = _get_image_md5_content(file_path)
|
487 |
+
async with httpx.AsyncClient(
|
488 |
+
base_url=_BASE_URL,
|
489 |
+
headers={"Authorization": f"Bearer {api_key}"},
|
490 |
+
) as client:
|
491 |
+
response = await client.post(
|
492 |
+
"/tasks",
|
493 |
+
json={
|
494 |
+
"tools": [
|
495 |
+
{"type": "face_enhance", "mode": "beautify"},
|
496 |
+
{"type": "background_enhance", "mode": "base"}
|
497 |
+
],
|
498 |
+
"image_md5": image_md5,
|
499 |
+
"image_content_type": CONTENT_TYPE
|
500 |
+
}
|
501 |
+
)
|
502 |
+
assert response.status_code == 200
|
503 |
+
body = response.json()
|
504 |
+
task_id = body["task_id"]
|
505 |
+
response = await client.put(
|
506 |
+
body["upload_url"],
|
507 |
+
headers=body["upload_headers"],
|
508 |
+
content=content,
|
509 |
+
timeout=_TIMEOUT
|
510 |
+
)
|
511 |
+
assert response.status_code == 200
|
512 |
+
response = await client.post(f"/tasks/{task_id}/process")
|
513 |
+
assert response.status_code == 202
|
514 |
+
for i in range(50):
|
515 |
+
response = await client.get(f"/tasks/{task_id}")
|
516 |
+
assert response.status_code == 200
|
517 |
+
if response.json()["status"] == "completed":
|
518 |
+
break
|
519 |
+
else:
|
520 |
+
await asyncio.sleep(2)
|
521 |
+
output_url = response.json()["result"]["output_url"]
|
522 |
+
return output_url
|
523 |
+
os.remove(file_path)
|
524 |
+
|
525 |
+
@app.post("/akeno/remini", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
526 |
+
async def remini(remini_api_key: str, file: UploadFile = File(...)):
|
527 |
+
try:
|
528 |
+
image = Image.open(io.BytesIO(await file.read()))
|
529 |
+
buffer = io.BytesIO()
|
530 |
+
image.save(buffer, format='JPEG')
|
531 |
+
buffer.seek(0)
|
532 |
+
except Exception as e:
|
533 |
+
return SuccessResponse(
|
534 |
+
status="False",
|
535 |
+
randydev={"error": f"Error fucking: {e}"}
|
536 |
+
)
|
537 |
+
try:
|
538 |
+
response = await enhance_photo_and_remini(remini_api_key, buffer)
|
539 |
+
return SuccessResponse(
|
540 |
+
status="True",
|
541 |
+
randydev={"output_url": response}
|
542 |
+
)
|
543 |
+
except Exception as e:
|
544 |
+
return SuccessResponse(
|
545 |
+
status="False",
|
546 |
+
randydev={"error": f"Error fucking: {e}"}
|
547 |
+
)
|
548 |
+
|
549 |
+
@app.get("/akeno/pinterest-v2", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
550 |
+
async def pinterestv2(query: str):
|
551 |
+
try:
|
552 |
+
response = await pinterest_api_v2(query)
|
553 |
+
return SuccessResponse(
|
554 |
+
status="True",
|
555 |
+
randydev={"results": response}
|
556 |
+
)
|
557 |
+
except:
|
558 |
+
return SuccessResponse(
|
559 |
+
status="False",
|
560 |
+
randydev={"error": "Error fucking"}
|
561 |
+
)
|
562 |
+
|
563 |
@app.get("/akeno/pornpics", response_model=SuccessResponse, responses={422: {"model": SuccessResponse}})
|
564 |
async def pornpics(query: str):
|
565 |
try:
|
|
|
2250 |
return app.openapi_schema
|
2251 |
openapi_schema = get_openapi(
|
2252 |
title="RyuzakiLib API",
|
2253 |
+
version="4.1.3",
|
2254 |
summary="Use It Only For Personal Project Else I Need To Delete The Api",
|
2255 |
description=description,
|
2256 |
routes=app.routes,
|