From 11b35bb5a6d1b7ca458217cf353ba4fbd4b3c55b Mon Sep 17 00:00:00 2001 From: Koval Yaroslav Date: Thu, 12 Dec 2024 15:41:13 +0100 Subject: [PATCH] Add url key to preview link --- app/telegram/models/post.py | 2 ++ app/telegram/parser/types/post.py | 1 + 2 files changed, 3 insertions(+) diff --git a/app/telegram/models/post.py b/app/telegram/models/post.py index 66003bc..09de778 100644 --- a/app/telegram/models/post.py +++ b/app/telegram/models/post.py @@ -143,12 +143,14 @@ class PreviewLink(BaseModel): Attributes: title (Optional[str]): The title of the linked content, if available + url (HttpUrl): This URL of preview page site_name (str): The name of the website or platform the link is from description (Optional[ParsedAndRaw]): The description of the linked content, containing both parsed text and raw HTML formats thumb (HttpUrl): The URL of the preview thumbnail image """ title: Optional[str] + url: HttpUrl site_name: str description: Optional[ParsedAndRaw] thumb: HttpUrl diff --git a/app/telegram/parser/types/post.py b/app/telegram/parser/types/post.py index 862dd34..c111787 100644 --- a/app/telegram/parser/types/post.py +++ b/app/telegram/parser/types/post.py @@ -89,6 +89,7 @@ def preview_link(buble: LexborNode) -> Union[dict, None]: return { "site_name": preview.css_first(".link_preview_site_name").text(strip=True), + "url": preview.attributes.get("href"), "title": title.text(strip=True) if title else None, "description": description, "thumb": Utils.background_extr(