Aktualizovat upraveny_pubcrawler/urls.py

This commit is contained in:
Kristián Sokolský 2026-11-09 02:38:37 +00:00
parent 540d98b71d
commit 28921cd098

View File

@ -2,11 +2,9 @@ import re
from urllib.parse import urlsplit
from ...common.urls import normalize_url
ARTICLE_EXPERT = re.compile(r"^/ask-an-expert/[^/]+/[^/]+/?$", re.I)
ARTICLE_FORUM = re.compile(r"^/forum/[^/]+/[^/]+/?$", re.I)
ARTICLE_BLOG = re.compile(r"^/blogs/[^/]+/(message|article)/[^/]+/?$", re.I)
def normalize(url, base="https://www.modrykonik.sk/"):
@ -16,7 +14,7 @@ def normalize(url, base="https://www.modrykonik.sk/"):
def article_id(url):
path = urlsplit(url).path
m = ARTICLE_EXPERT.match(path) or ARTICLE_FORUM.match(path)
m = ARTICLE_EXPERT.match(path) or ARTICLE_FORUM.match(path) or ARTICLE_BLOG.match(path)
return m.group(0) if m else None
@ -41,14 +39,22 @@ def kind(url):
return "article_expert"
return None
if segments[0] == "forum":
if len(segments) >= 3 and segments[1] not in {"category", "topics"}:
return "article_forum"
if len(segments) <= 2 or segments[1] in {"category", "topics"}:
return "listing"
return None
if segments[0] == "blogs":
if len(segments) == 1:
return "listing"
if len(segments) == 2:
return "listing"
if len(segments) == 3:
return "article_forum"
if len(segments) >= 4 and segments[2] in {"message", "article"}:
return "article_blog"
return None
return None