183 lines
9.1 KiB
Python
183 lines
9.1 KiB
Python
import json
|
|||
|
|
import re
|
||
|
|
|
||
|
|
with open("/home/creserver/Desktop/Vaishno_workspace/Jsons/credentials_23-10-2026.json") as f:
|
||
|
|
creds_data = json.load(f)["data"]
|
||
|
|
|
||
|
|
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)
|
||
|
|
doc_data = json.loads(m.group(1))
|
||
|
|
|
||
|
|
all_eps = []
|
||
|
|
for s in doc_data["sections"]:
|
||
|
|
for ep in s["eps"]:
|
||
|
|
all_eps.append((s["id"], s["title"], ep))
|
||
|
|
|
||
|
|
assigned_eps = set()
|
||
|
|
api_groups = []
|
||
|
|
|
||
|
|
for c in creds_data:
|
||
|
|
key = c["api_key"]
|
||
|
|
url = c["api_ip_link"].strip()
|
||
|
|
|
||
|
|
# Matching logic
|
||
|
|
matched = []
|
||
|
|
|
||
|
|
for s_id, s_title, ep in all_eps:
|
||
|
|
p = ep["path"]
|
||
|
|
|
||
|
|
# Specific mappings
|
||
|
|
if key == "Teeth_Whitener" and "/teeth_whitener/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Face_Coordinates" and "/face_landmark/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Face_Swapper" and "/face_swapper/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Caricature_Avatar" and "/caricature_avatar/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cre_Aws_Waifu2x_Model" and "/new_enhancer/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Blemish_Remover" and "/blemish_remover/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Eye_Bag_Remover" and "/eye_bag_remover/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Eye_Redness_Remover" and "/eye_redness_remover/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cre_Aws_Colorization_Model" and "/colorization/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cre_Aws_Old_Photo_Restore_Model" and "/oldPhotoRestore/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cre_Aws_Advance_Image_Segment_Anything_Dichotomous_Model" and "/advance_image_segment_anything_dichotomous/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cre_Aws_cloth_segmentation_Model" and p == "/cloth_segmentation/image":
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cloth_Segmentation_Model_V2" and "/cloth_segmentation_v2/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "dress_segmentation_auto" and "/dress_segmentation_auto_newurl/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cre_Aws_Lama_Cleaner_Model" and "/lamaCleaner/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cre_Aws_Background_Remover_Model" and "/background_remover_p3m/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cre_Aws_Cartoon_Model" and "/cartoon_effects/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Text_To_Image_Model" and "/sdxl/text_to_image/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Realistic_Avatar" and "/stable_diffusion_avatar_with_original_face/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cre_Face_With_Hair_Segment_Model" and "/face_hair_segmentation/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cre_Cartoonify_Caricature_Effects_Model" and "/cartoonify_caricature_effects/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Cre_Hair_Detection_Segment_Model" and (p == "/hair_segmentation/image/" or p == "/hair_segmentation_yolo_sam/image/"):
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Hair_Color_Changer_And_Hair_Style_Changer" and ("/hair_color_changer/" in p or "/hair_style_changer/" in p):
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Hair_Segmentation" and "/stable_diffusion_hair_segmentation/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Outpainting" and "/sdxl/outpainting/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Art_Style_Transfer" and ("/stable_diffusion_art_style_transfer/" in p or "/art_style_transfer/" in p):
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Reaslistic_Background_Changer" and "/stable_diffusion_realistic_background_changer/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Headshot" and "/flux/headshots/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Eye_Changer" and "/flux_fill/eye_changer/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Caricature_Effects" and "/stable_diffusion_caricature_effects/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Head_Cartoon_Effects" and "/flux/head_cartoon_effect/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Modified_Head_Cartoon_Effects" and "/flux/modified_head_cartoon_effects/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Comic_Generator" and "/stable_diffusion_comic_generator/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Inpaint_Object_Replacer" and "/sdxl/inpaint_object_replacer/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Skin_Detection" and "/skin_detection/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Sky_Detection" and "/sky_detection/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Dress_Pattern" and "/sdxl/dress_pattern/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Photo_2_Caricature" and "/stable_diffusion_photo_2_caricature/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Caricature_Hair_Face_Effect" and "/stable_diffusion_caricature_hair_face_effect/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Blend_Collage" and "/sdxl/blend_collage/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Dress_Replacer" and "/sdxl/dress_replacer/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Comic_Coverpage_Generator" and "/flux/comic_cover/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Text_To_Cartoon_Character_Generator" and "/sdxl/text_to_cartoon/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Dress_Changer" and (p == "/dress-changer/image/" or "/sdxl/dress_changer/" in p):
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Text_To_Caricature" and "/sdxl/text_to_caricature/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Face_Expressions_Changer" and "/sdxl/expressions_changer/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Pose_Detection" and "/pose_detection/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_New_Cartoon Effects" and "/stable_diffusion_new_cartoon_effects/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Artistic_Effects" and "/stable_diffusion_artistic_effects/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Polaroid_Effect" and "/polaroid_effect/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Relighter" and "/relighting_effect/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Feedbacks" and "/feedback/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Flux_Hairstyles" and "/flux/hairstyles/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Flux_Sculpture_Effect" and "/flux/sculptures/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Flux_Silhouette_Effect" and "/flux/silhouette/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Flux_Couple_Dress_Changer" and "/flux_fill/couple_dress_changer/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Flux_Glasses" and "/flux/glasses_maker/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Reports" and "/reports/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Flux_Cartoon" and "/flux/cartoon/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Flux_Background_Changer" and "/flux/background_with_depth/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Credits_Limit" and "/credits/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Multi_Segmentation_Model" and "/multi_segmentation_yolo_sam/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Vintage_Look" and "/flux/vintage_look/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Face_Analyzer" and "/skin_analyzer/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Flux_Dress_Changer" and "/flux_fill/dress_changer/" in p:
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Image_To_Image_Model" and p == "/stable_diffusion/image/":
|
||
|
|
matched.append(ep)
|
||
|
|
elif key == "Stable_Diffusion_Silhouette_Maker" and "silhouette" in p and "flux" not in p:
|
||
|
|
matched.append(ep)
|
||
|
|
|
||
|
|
for me in matched:
|
||
|
|
assigned_eps.add(me["id"])
|
||
|
|
|
||
|
|
api_groups.append({
|
||
|
|
"api_key": key,
|
||
|
|
"url": url,
|
||
|
|
"matched": matched
|
||
|
|
})
|
||
|
|
|
||
|
|
print(f"Total APIs configured: {len(api_groups)}")
|
||
|
|
print(f"Total assigned endpoints: {len(assigned_eps)} / {len(all_eps)}")
|
||
|
|
|
||
|
|
unassigned = [ep for s_id, s_title, ep in all_eps if ep["id"] not in assigned_eps]
|
||
|
|
print(f"Unassigned endpoints count: {len(unassigned)}")
|
||
|
|
for u in unassigned:
|
||
|
|
print(f" - {u['id']} | {u['path']} | {u['title']}")
|