Spaces:
Paused
Paused
Upload useapi.py
Browse files
useapi.py
CHANGED
|
@@ -81,7 +81,7 @@ def get_models():
|
|
| 81 |
#解析推荐json
|
| 82 |
async def extract_recommand(data, language):
|
| 83 |
result = []
|
| 84 |
-
for item in data["data"]
|
| 85 |
opening = await get_moment_opening(item["_id"], language)
|
| 86 |
result.append({
|
| 87 |
"character_id": item["character_id"],
|
|
@@ -89,7 +89,7 @@ async def extract_recommand(data, language):
|
|
| 89 |
"_id": item["_id"],
|
| 90 |
"image_url": str(image_url + item["_id"] + "_large.webp"),
|
| 91 |
"description": item["description"],
|
| 92 |
-
"name": item["title"],
|
| 93 |
"opening": opening
|
| 94 |
})
|
| 95 |
return result
|
|
@@ -105,7 +105,7 @@ async def get_moment_opening(moment_id, language):
|
|
| 105 |
|
| 106 |
#请求推荐API
|
| 107 |
async def recommand(char_id, language):
|
| 108 |
-
recommand_url = str(recommand_base_url + char_id)
|
| 109 |
async with httpx.AsyncClient() as client:
|
| 110 |
response = await client.get(recommand_url, headers=create_headers(language))
|
| 111 |
json_data = response.json()
|
|
|
|
| 81 |
#解析推荐json
|
| 82 |
async def extract_recommand(data, language):
|
| 83 |
result = []
|
| 84 |
+
for item in data["data"]:
|
| 85 |
opening = await get_moment_opening(item["_id"], language)
|
| 86 |
result.append({
|
| 87 |
"character_id": item["character_id"],
|
|
|
|
| 89 |
"_id": item["_id"],
|
| 90 |
"image_url": str(image_url + item["_id"] + "_large.webp"),
|
| 91 |
"description": item["description"],
|
| 92 |
+
"name": item["title"],
|
| 93 |
"opening": opening
|
| 94 |
})
|
| 95 |
return result
|
|
|
|
| 105 |
|
| 106 |
#请求推荐API
|
| 107 |
async def recommand(char_id, language):
|
| 108 |
+
recommand_url = str(recommand_base_url + char_id + "?num=20&offset=0")
|
| 109 |
async with httpx.AsyncClient() as client:
|
| 110 |
response = await client.get(recommand_url, headers=create_headers(language))
|
| 111 |
json_data = response.json()
|