85 lines
3.4 KiB
Python
85 lines
3.4 KiB
Python
import json
|
|
import re
|
|
|
|
with open("/home/creserver/Desktop/Vaishno_workspace/Jsons/credentials_23-10-2026.json") as f:
|
|
creds = json.load(f)
|
|
|
|
with open("web/docs/index.html") as f:
|
|
html = f.read()
|
|
|
|
m = re.search(r'<script id="api-data" type="application/json">(.*?)</script>', html, re.DOTALL)
|
|
data = json.loads(m.group(1))
|
|
|
|
all_eps = [ep for s in data["sections"] for ep in s["eps"]]
|
|
|
|
# Let's map accurately
|
|
# We want each cred entry to have a list of endpoints.
|
|
# Let's inspect which endpoints match which cred entry.
|
|
|
|
mapping = []
|
|
|
|
for c in creds["data"]:
|
|
k = c["api_key"]
|
|
url = c["api_ip_link"]
|
|
|
|
# Path extraction:
|
|
# URL e.g.:
|
|
# https://apigp0006.creinnovations.in/apis/mlm/teeth_whitener/
|
|
# https://apigp0006.creinnovations.in/apis/flxf/flux_fill/hair_color_changer/
|
|
# https://apigp0006.creinnovations.in/apis/flxk/flux/hairstyles/
|
|
# https://apigp0905.creinnovations.in/apis/lxds/sdxl/text_to_image/
|
|
# https://apigp0905.creinnovations.in/apis/cmf/dress-changer/
|
|
|
|
# Clean the url
|
|
clean_url = url.strip()
|
|
|
|
# Let's find all eps that match this API
|
|
matched = []
|
|
|
|
# Custom specific rules if needed:
|
|
if k == "Teeth_Whitener":
|
|
matched = [ep for ep in all_eps if "/teeth_whitener/" in ep["path"]]
|
|
elif k == "Face_Coordinates":
|
|
matched = [ep for ep in all_eps if "/face_landmark/" in ep["path"]]
|
|
elif k == "Face_Swapper":
|
|
matched = [ep for ep in all_eps if "/face_swapper/" in ep["path"]]
|
|
elif k == "Caricature_Avatar":
|
|
matched = [ep for ep in all_eps if "/caricature_avatar/" in ep["path"]]
|
|
elif k == "Cre_Aws_Waifu2x_Model":
|
|
matched = [ep for ep in all_eps if "/new_enhancer/" in ep["path"]]
|
|
elif k == "Blemish_Remover":
|
|
matched = [ep for ep in all_eps if "/blemish_remover/" in ep["path"]]
|
|
elif k == "Feedbacks":
|
|
matched = [ep for ep in all_eps if "/feedback/" in ep["path"]]
|
|
elif k == "Reports":
|
|
matched = [ep for ep in all_eps if "/reports/" in ep["path"]]
|
|
elif k == "Credits_Limit":
|
|
matched = [ep for ep in all_eps if "/credits/" in ep["path"]]
|
|
elif k == "Multi_Segmentation_Model":
|
|
matched = [ep for ep in all_eps if "multi_segmentation" in ep["path"]]
|
|
elif k == "Stable_Diffusion_Dress_Pattern":
|
|
matched = [ep for ep in all_eps if "dress_pattern" in ep["path"]]
|
|
elif k == "Stable_Diffusion_Silhouette_Maker":
|
|
matched = [ep for ep in all_eps if "silhouette" in ep["path"] and "flux" not in ep["path"]]
|
|
else:
|
|
# Generic matcher: extract key segment from url
|
|
# remove domain and /apis/xxx/
|
|
path_part = re.sub(r"https?://[^/]+/apis/(mlm|lxds|flxf|flxk|cmf)/", "", clean_url).strip("/")
|
|
# path_part could be "hair_segmentation", "flux/headshots", "sdxl/blend_collage", "cartoon_effects", etc.
|
|
for ep in all_eps:
|
|
ep_p = ep["path"].strip("/")
|
|
if path_part and (path_part == ep_p or ep_p.startswith(path_part + "/") or ep_p.endswith("/" + path_part) or path_part in ep_p):
|
|
matched.append(ep)
|
|
|
|
mapping.append({
|
|
"api_key": k,
|
|
"url": clean_url,
|
|
"matched_count": len(matched),
|
|
"eps": [f"{ep['method']} {ep['path']}" for ep in matched]
|
|
})
|
|
|
|
for m in mapping:
|
|
print(f"API: {m['api_key']}")
|
|
print(f" URL: {m['url']}")
|
|
print(f" Endpoints ({m['matched_count']}): {', '.join(m['eps'])}")
|