bug fix: return the same pic's info

This commit is contained in:
tianyi 2024-05-09 06:10:39 +00:00
parent 51986a13bd
commit d2238c2cb2
1 changed files with 9 additions and 7 deletions

View File

@ -5,13 +5,15 @@ from .models import Picture
pics=Picture.objects.order_by("?") pics=Picture.objects.order_by("?")
def get_random_picture_url(): def get_random_picture_url():
return "https://cdn.clf3.org/tianyi-random/"+pics[0].name+".webp" selected_pic=pics[0]
return "https://cdn.clf3.org/tianyi-random/"+selected_pic.name+".webp"
def get_random_picture_meta(): def get_random_picture_meta():
selected_pic=pics[0]
return { return {
"name":pics[0].name, "name":selected_pic.name,
"url":"https://cdn.clf3.org/tianyi-random/"+pics[0].name+".webp", "url":"https://cdn.clf3.org/tianyi-random/"+selected_pic.name+".webp",
"description":pics[0].description, "description":selected_pic.description,
"author":pics[0].author, "author":selected_pic.author,
"author_url":pics[0].author_url, "author_url":selected_pic.author_url,
"original_url":pics[0].original_url "original_url":selected_pic.original_url
} }