Spaces:
Running
Running
Update tools.py
Browse files
tools.py
CHANGED
@@ -16,10 +16,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):
|
@@ -28,6 +33,20 @@ class XnxxSearch(BaseModel):
|
|
28 |
class XnxxLinks(BaseModel):
|
29 |
url: str
|
30 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
async def tools_search(
|
32 |
name=None,
|
33 |
parameter=None,
|
@@ -82,7 +101,7 @@ async def toanime_endpoint(
|
|
82 |
try:
|
83 |
with open(file_path, "wb") as f:
|
84 |
f.write(await file.read())
|
85 |
-
except Exception
|
86 |
raise HTTPException(status_code=500, detail="Failed to save file")
|
87 |
try:
|
88 |
response = await toanime(file_path)
|
|
|
16 |
from pymongo import MongoClient
|
17 |
from models import *
|
18 |
from RyuzakiLib import AsyicXSearcher
|
|
|
19 |
|
20 |
load_dotenv()
|
21 |
TOOLS_NEW_URL = os.environ["TOOLS_NEW_URL"]
|
22 |
+
MONGO_URL = os.environ["MONGO_URL"]
|
23 |
+
|
24 |
+
client_mongo = MongoClient(MONGO_URL)
|
25 |
+
db = client_mongo["tiktokbot"]
|
26 |
+
collection = db["users"]
|
27 |
+
|
28 |
router = APIRouter()
|
29 |
|
30 |
class XnxxSearch(BaseModel):
|
|
|
33 |
class XnxxLinks(BaseModel):
|
34 |
url: str
|
35 |
|
36 |
+
def get_all_api_keys():
|
37 |
+
user = collection.find({})
|
38 |
+
api_keys = []
|
39 |
+
for x in user:
|
40 |
+
api_key = x.get("ryuzaki_api_key")
|
41 |
+
if api_key:
|
42 |
+
api_keys.append(api_key)
|
43 |
+
return api_keys
|
44 |
+
|
45 |
+
def validate_api_key(api_key: str = Header(...)):
|
46 |
+
USERS_API_KEYS = get_all_api_keys()
|
47 |
+
if api_key not in USERS_API_KEYS:
|
48 |
+
raise HTTPException(status_code=401, detail="Invalid API key")
|
49 |
+
|
50 |
async def tools_search(
|
51 |
name=None,
|
52 |
parameter=None,
|
|
|
101 |
try:
|
102 |
with open(file_path, "wb") as f:
|
103 |
f.write(await file.read())
|
104 |
+
except Exception:
|
105 |
raise HTTPException(status_code=500, detail="Failed to save file")
|
106 |
try:
|
107 |
response = await toanime(file_path)
|