feat: hashtagy z featured_tags místo bio parsování
This commit is contained in:
+12
-9
@@ -232,14 +232,17 @@ def categorize(acc):
|
|||||||
return cat
|
return cat
|
||||||
return "ostatni"
|
return "ostatni"
|
||||||
|
|
||||||
def extract_tags(acc):
|
def fetch_featured_tags(acc):
|
||||||
text = re.sub(r"<[^>]+>", " ", acc.get("note", "") or "").lower()
|
account_id = acc.get("id")
|
||||||
found = []
|
instance = acc.get("_source_instance", "")
|
||||||
for kws in CATEGORIES.values():
|
if not account_id or not instance:
|
||||||
for kw in kws:
|
return []
|
||||||
if kw in text and kw not in found and len(kw) > 3:
|
url = f"https://{instance}/api/v1/accounts/{account_id}/featured_tags"
|
||||||
found.append(kw.strip())
|
token = _token_for(instance)
|
||||||
return found[:4]
|
data = api_get(url, token=token)
|
||||||
|
if not data or not isinstance(data, list):
|
||||||
|
return []
|
||||||
|
return [t["name"] for t in data if isinstance(t, dict) and t.get("name")][:4]
|
||||||
|
|
||||||
# ── VÝSTUP ────────────────────────────────────
|
# ── VÝSTUP ────────────────────────────────────
|
||||||
def _to_output(acc):
|
def _to_output(acc):
|
||||||
@@ -253,7 +256,7 @@ def _to_output(acc):
|
|||||||
"followers": acc.get("followers_count", 0),
|
"followers": acc.get("followers_count", 0),
|
||||||
"statuses": acc.get("statuses_count", 0),
|
"statuses": acc.get("statuses_count", 0),
|
||||||
"score": score(acc),
|
"score": score(acc),
|
||||||
"tags": extract_tags(acc),
|
"tags": fetch_featured_tags(acc),
|
||||||
"category": categorize(acc),
|
"category": categorize(acc),
|
||||||
"last_active": acc.get("last_status_at", ""),
|
"last_active": acc.get("last_status_at", ""),
|
||||||
"url": acc.get("url", ""),
|
"url": acc.get("url", ""),
|
||||||
|
|||||||
Reference in New Issue
Block a user