Update main.py
Browse files
main.py
CHANGED
|
@@ -39,6 +39,12 @@ async def starrail_profile(id):
|
|
| 39 |
async with starrailcard.Card(remove_logo=True, seeleland=True) as card:
|
| 40 |
return await card.create_profile(id, style=2)
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
# Route for Genshin Impact
|
| 43 |
@app.get("/genshin/{id}")
|
| 44 |
async def genshin_characters(id: int, design: str = "1"):
|
|
@@ -78,9 +84,21 @@ async def starrail_profile_route(id: int):
|
|
| 78 |
except Exception as e:
|
| 79 |
return JSONResponse(content={'error': 'UNKNOWN ERR: ' + str(e)}, status_code=500)
|
| 80 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
@app.get("/")
|
| 82 |
def root():
|
| 83 |
-
return "
|
| 84 |
|
| 85 |
# Helper function to upload the image to Cloudinary
|
| 86 |
def upload_image(data, character_id, player_id):
|
|
@@ -117,9 +135,7 @@ def process_profile(profile_card, player_id):
|
|
| 117 |
# Use the character ID and player ID for the profile card
|
| 118 |
image_url = upload_image(byte_io, profile_card.character_id, player_id)
|
| 119 |
return {
|
| 120 |
-
"name": profile_card.character_name,
|
| 121 |
"url": image_url,
|
| 122 |
-
"character_ids": profile_card.character_id
|
| 123 |
}
|
| 124 |
|
| 125 |
# Process all the images returned
|
|
|
|
| 39 |
async with starrailcard.Card(remove_logo=True, seeleland=True) as card:
|
| 40 |
return await card.create_profile(id, style=2)
|
| 41 |
|
| 42 |
+
|
| 43 |
+
# genshin profile creation
|
| 44 |
+
async def genshinprofile(id):
|
| 45 |
+
async with encbanner.ENC(uid = id) as encard:
|
| 46 |
+
return await encard.profile(card = True)
|
| 47 |
+
|
| 48 |
# Route for Genshin Impact
|
| 49 |
@app.get("/genshin/{id}")
|
| 50 |
async def genshin_characters(id: int, design: str = "1"):
|
|
|
|
| 84 |
except Exception as e:
|
| 85 |
return JSONResponse(content={'error': 'UNKNOWN ERR: ' + str(e)}, status_code=500)
|
| 86 |
|
| 87 |
+
|
| 88 |
+
# Route for Star Rail profile
|
| 89 |
+
@app.get("/starrail/profile/{id}")
|
| 90 |
+
async def starrail_profile_route(id: int):
|
| 91 |
+
try:
|
| 92 |
+
result = await genshinprofile(id)
|
| 93 |
+
profile_data = process_profile(result, id)
|
| 94 |
+
return JSONResponse(content={'response': profile_data})
|
| 95 |
+
|
| 96 |
+
except Exception as e:
|
| 97 |
+
return JSONResponse(content={'error': 'UNKNOWN ERR: ' + str(e)}, status_code=500)
|
| 98 |
+
|
| 99 |
@app.get("/")
|
| 100 |
def root():
|
| 101 |
+
return "خدتك عليه"
|
| 102 |
|
| 103 |
# Helper function to upload the image to Cloudinary
|
| 104 |
def upload_image(data, character_id, player_id):
|
|
|
|
| 135 |
# Use the character ID and player ID for the profile card
|
| 136 |
image_url = upload_image(byte_io, profile_card.character_id, player_id)
|
| 137 |
return {
|
|
|
|
| 138 |
"url": image_url,
|
|
|
|
| 139 |
}
|
| 140 |
|
| 141 |
# Process all the images returned
|