支持快手图片贴

This commit is contained in:
yezian 2024-08-13 15:49:38 +08:00
parent 4cad0f65e2
commit dccde20a19
1 changed files with 26 additions and 0 deletions

View File

@ -251,6 +251,32 @@ class Video:
response = requests.post(url, headers=headers, data=post_data)
json_data = response.json()
if len(json_data["photo"]["mainMvUrls"]) == 0:
cdn = json_data["photo"]["ext_params"]["atlas"]["cdn"][0]
origin_image_urls = [
("https://" + cdn + image)
for image in json_data["photo"]["ext_params"]["atlas"]["list"]
]
image_urls = [endecode_and_proxy_url(url) for url in origin_image_urls]
result = {
"code": 200,
"msg": "解析成功",
"data": {
"avatar": endecode_and_proxy_url(json_data["photo"]["headUrl"]),
"author": json_data["photo"]["userName"],
"time": json_data["photo"]["timestamp"],
"title": json_data["photo"]["caption"],
"cover": endecode_and_proxy_url(
json_data["photo"]["coverUrls"][0]["url"]
),
"origin_cover": json_data["photo"]["coverUrls"][0]["url"],
"image_urls": image_urls,
"origin_image_urls": origin_image_urls,
},
}
return result
video_url = json_data["photo"]["mainMvUrls"][0]["url"]
if video_url:
result = {