Fix: f-string syntax error in feed_generator.py

This commit is contained in:
sunwoo1524 2024-11-03 02:08:43 +09:00
parent d0c6b3aaad
commit 98b4954065

View file

@ -59,14 +59,16 @@ def generate_feed_of_user(user_handle: str) -> str | int:
# get media of status # get media of status
for media in status["media_attachments"]: for media in status["media_attachments"]:
media_url = media["url"]
media_description = media["description"]
if media["type"] == "image": if media["type"] == "image":
content += f"<img src='{media["url"]}' {f"alt='{media["description"]}'" if not media["description"] is None else ""} />" content += f"<img src='{media_url}' alt='{media_description if not media_description is None else ''}' />"
elif media["type"] == "video" or media["type"] == "gifv": elif media["type"] == "video" or media["type"] == "gifv":
content += f"<video><source src='{media["url"]}'>{f"<p>{media["description"]}</p>" if not media["description"] is None else ""}</source></video>" content += f"<video><source src='{media_url}'>{f'<p>{media_description}</p>' if not media_description is None else ''}</source></video>"
elif media["type"] == "audio": elif media["type"] == "audio":
content += f"<audio src='{media["url"]}' controls></audio>{f"<span>{media["description"]}</span>" if not media["description"] is None else ""}" content += f"<audio src='{media_url}' controls></audio>{f'<span>{media_description}</span>' if not media_description is None else ''}"
else: else:
content += f"<a href='{media["url"]}'>{media["description"] if not media["description"] is None else media["url"]}</a>" content += f"<a href='{media_url}'>{media_description if not media_description is None else media_url}</a>"
status_items.append(rfeed.Item( status_items.append(rfeed.Item(
description=content, description=content,