абузы: extract промокодов/сумм/ссылок в API и панели, +16 проверенных источников (TG/reddit/discourse/RSS/github/HN), чистка HTML в деталях, клэмп days
Some checks failed
ci / test (3.10) (push) Has been cancelled
ci / test (3.11) (push) Has been cancelled
ci / test (3.12) (push) Has been cancelled

This commit is contained in:
Vlad Gothbreach
2026-10-27 01:50:05 +03:00
parent 8de421b6af
commit b09cb5f873
22 changed files with 552 additions and 2992 deletions

View File

@@ -21,9 +21,11 @@ def _clean(v, n=0):
import html as _h
if not v:
return ""
t = re.sub(r"<[^>]{1,200}>", " ", str(v))
for _ in range(2):
t = str(v)
# unescape и снятие тегов в цикле: иначе &lt;b&gt; после unescape снова станет тегом
for _ in range(3):
t = _h.unescape(t)
t = re.sub(r"<[^>]{1,200}>", " ", t)
t = re.sub(r"\s+", " ", t).strip()
return t[:n].rstrip() if n else t
@@ -39,7 +41,8 @@ def timeline(days=30, cat=None, mode="pub"):
mode="pub" — по дате публикации (или дате попадания в базу, если публикации нет);
mode="seen" — строго по времени импорта: «что комбайн принёс за день».
"""
days = max(1, min(365, int(days or 30)))
days = 30 if days is None else int(days or 0)
days = max(1, min(365, days))
bucket = BUCKET_SEEN if mode == "seen" else BUCKET
names = [s.name for s in sources.all_sources() if s.category == cat] if cat not in (None, "", "all") else None
where, args = "", []