revert 105b2b6183
revert Aktualizovat upraveny_pubcrawler/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/[^/]
This commit is contained in:
parent
105b2b6183
commit
540d98b71d
@ -2,9 +2,11 @@ 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/"):
|
||||
@ -14,7 +16,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) or ARTICLE_BLOG.match(path)
|
||||
m = ARTICLE_EXPERT.match(path) or ARTICLE_FORUM.match(path)
|
||||
return m.group(0) if m else None
|
||||
|
||||
|
||||
@ -39,22 +41,14 @@ 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 segments[0] == "forum":
|
||||
if len(segments) == 1:
|
||||
return "listing"
|
||||
if len(segments) == 2:
|
||||
return "listing"
|
||||
if len(segments) >= 4 and segments[2] in {"message", "article"}:
|
||||
return "article_blog"
|
||||
if len(segments) == 3:
|
||||
return "article_forum"
|
||||
return None
|
||||
|
||||
return None
|
||||
Loading…
Reference in New Issue
Block a user