From 3367b2fa4b0a2537be926209efeda04005e4a3b5 Mon Sep 17 00:00:00 2001 From: LepkoQQ Date: Tue, 23 Apr 2024 15:33:39 +0200 Subject: [PATCH] try to fix invalid url on articles --- novdan_api/articles/management/commands/parse_articles.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/novdan_api/articles/management/commands/parse_articles.py b/novdan_api/articles/management/commands/parse_articles.py index 1de8db9..daf5291 100644 --- a/novdan_api/articles/management/commands/parse_articles.py +++ b/novdan_api/articles/management/commands/parse_articles.py @@ -127,12 +127,19 @@ def parse_rss_feed(self, medium, url): self.stdout.write(f" > {title[:67]}") + if item.link and item.link.content and not item.link.content.startswith("http"): + if item.link.content.startswith("//"): + item.link.content = f"http:{item.link.content}" + if "://" not in item.link.content: + item.link.content = f"http://{item.link.content}" + if not self.is_url(item.link.content): with push_scope() as scope: scope.set_extra("command", "parse_articles") scope.set_extra("rss_url", url) capture_message(f"Invalid url: {item.link.content}") self.stdout.write(f" > invalid url: {item.link.content}") + self.stdout.write("") continue url = item.link.content[:512]