diff --git a/ops/work/COMPATIBILITY-SOURCE.md b/ops/work/COMPATIBILITY-SOURCE.md
index 2d53b57..aea9ddd 100644
--- a/ops/work/COMPATIBILITY-SOURCE.md
+++ b/ops/work/COMPATIBILITY-SOURCE.md
@@ -1,62 +1,67 @@
-# Официальные списки совместимости Yealink — как добываем
+# Официальные списки Yealink: что собрано
-Дата: 06.11.2026. Источник: **support.yealink.com** (официальный портал вендора).
+Дата: 06.11.2026. Источник: **support.yealink.com** (портал вендора).
-## Прорыв: данные достаются из ProseMirror-JSON
+## Технический прорыв
-Страницы поддержки — **Nuxt SPA**, `web_fetch` и `curl` отдают пустую оболочку.
-Но контент лежит в `', html, re.S)
+ if not m:
+ return None
+ try:
+ return json.loads(m.group(1).strip())
+ except Exception:
+ return None
+
+
+def find_docs(obj, out, path=""):
+ """Ищем объекты, похожие на документ: есть title/name и 32-символьный хеш."""
+ if isinstance(obj, dict):
+ vals = {k: v for k, v in obj.items() if isinstance(v, (str, int))}
+ title = None
+ for k in ("title", "name", "docTitle", "articleTitle"):
+ if k in vals and isinstance(vals[k], str):
+ title = vals[k]
+ break
+ hid = None
+ for v in vals.values():
+ if isinstance(v, str) and re.fullmatch(r"[0-9a-f]{32}", v):
+ hid = v
+ break
+ if title and hid:
+ out.append({"id": hid, "title": title, "path": path})
+ for k, v in obj.items():
+ find_docs(v, out, "%s.%s" % (path, k))
+ elif isinstance(obj, list):
+ for i, v in enumerate(obj):
+ find_docs(v, out, "%s[%d]" % (path, i))
+
+
+def main():
+ all_docs = []
+ for name, cid in CATEGORIES:
+ url = "%s/categories/%s/%s" % (BASE, name, cid)
+ html = get(url)
+ data = nuxt_data(html)
+ if data is None:
+ print(" %-28s NUXT не найден (%d Б)" % (name, len(html)))
+ continue
+ docs = []
+ find_docs(data, docs)
+ uniq = {d["id"]: d for d in docs}
+ compat = [d for d in uniq.values() if re.search(r"compatib", d["title"], re.I)]
+ print(" %-28s документов: %3d | «compatibility»: %2d" % (name, len(uniq), len(compat)))
+ for d in compat[:6]:
+ print(" %s" % d["title"][:70])
+ all_docs += compat
+
+ uniq = {d["id"]: d for d in all_docs}
+ with open("/opt/work-hub/compat-src/compat_docs.json", "w", encoding="utf-8") as f:
+ json.dump(sorted(uniq.values(), key=lambda x: x["title"]), f,
+ ensure_ascii=False, indent=1)
+ print("\nвсего уникальных «compatibility»-документов: %d" % len(uniq))
+ for d in sorted(uniq.values(), key=lambda x: x["title"])[:15]:
+ print(" %-70s %s" % (d["title"][:70], d["id"][:8]))
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/ops/work/tools/collect_urls.py b/ops/work/tools/collect_urls.py
new file mode 100644
index 0000000..169f36d
--- /dev/null
+++ b/ops/work/tools/collect_urls.py
@@ -0,0 +1,52 @@
+#!/usr/bin/env python3
+"""Собирает все страницы списков совместимости Yealink из sitemap."""
+import re
+import subprocess
+import sys
+
+UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/120"
+BASE = "https://support.yealink.com"
+
+
+def get(url):
+ r = subprocess.run(["curl", "-sL", "-m", "40", "-A", UA, url],
+ capture_output=True, text=True, timeout=90)
+ return r.stdout or ""
+
+
+def locs(xml):
+ return re.findall(r"([^<]+)", xml)
+
+
+def main():
+ idx = get(BASE + "/sitemap.xml")
+ subs = locs(idx)
+ print("подкарт в индексе:", len(subs))
+ urls = set()
+ for s in subs:
+ xml = get(s)
+ found = locs(xml)
+ for u in found:
+ if "/docs/" in u:
+ urls.add(u.split("?")[0])
+ print(" %-52s %d URL" % (s.replace(BASE, ""), len(found)))
+ print("\nвсего /docs/ URL:", len(urls))
+
+ compat = sorted(u for u in urls if re.search(r"compatib|compatible", u, re.I))
+ print("со 'compatib' в адресе:", len(compat))
+
+ # выделяем английские версии (без локали в пути)
+ en = [u for u in compat if re.search(r"/docs/", u) and not re.search(r"/(de-de|fr-fr|es-es|it-it|zh-cn|ru-ru|ja-jp|ko-kr|pt-br)/", u)]
+ print("английских:", len(en))
+
+ with open("/opt/work-hub/compat-src/urls.txt", "w", encoding="utf-8") as f:
+ f.write("\n".join(en) + "\n")
+ print("\nпервые 25:")
+ for u in en[:25]:
+ print(" ", u.replace(BASE, ""))
+ print("\nсохранено: /opt/work-hub/compat-src/urls.txt")
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/ops/work/tools/parse_compat.py b/ops/work/tools/parse_compat.py
new file mode 100644
index 0000000..ffdaa71
--- /dev/null
+++ b/ops/work/tools/parse_compat.py
@@ -0,0 +1,112 @@
+#!/usr/bin/env python3
+"""Извлечение официальных таблиц совместимости Yealink.
+
+Формат в руководствах:
+ Accessories Compatibility
+ 1. Compatibility of with accessories
+ Device | Accessories | Max Qty | Note
+
+Пишет ops/work/compat//.yaml с провенансом.
+"""
+import os
+import re
+import subprocess
+import sys
+
+OUT = os.environ.get("COMPAT_OUT", "/opt/work-hub/compat")
+
+ROLE_MAP = [
+ (r"^CPW\d|^VCM\d|^CP960|^CP700|^CP900|^MSpeaker|^CM\d|^CS\d", "audio"),
+ (r"^CTP\d", "touch"),
+ (r"^UVC\d", "camera"),
+ (r"^VCH\d|^WPP\d|^WF\d|^DD1\d", "hub_or_sharing"),
+ (r"^VCR\d", "remote"),
+ (r"^MVC|^MCore", "kit"),
+]
+
+
+def role_of(model):
+ for pat, role in ROLE_MAP:
+ if re.match(pat, model, re.I):
+ return role
+ return "other"
+
+
+def text_of(pdf):
+ r = subprocess.run(["pdftotext", "-layout", pdf, "-"],
+ capture_output=True, text=True, timeout=180)
+ return r.stdout or ""
+
+
+def parse_guide(text, source):
+ """Возвращает список устройств с их аксессуарами."""
+ lines = text.splitlines()
+ devices = []
+ cur_dev = None
+ section = None
+ expect_header = False
+
+ for i, ln in enumerate(lines):
+ s = ln.strip()
+ m = re.match(r"^\d+\.\s*Compatibility of (.+?) with accessories", s, re.I)
+ if m:
+ cur_dev = {"device": m.group(1).strip(), "accessories": [], "source": source}
+ devices.append(cur_dev)
+ expect_header = True
+ continue
+ if not cur_dev:
+ continue
+ if re.search(r"Device\s+Accessories\s+Max Qty\s+Note", s):
+ expect_header = False
+ continue
+ if expect_header:
+ continue
+
+ # строки вида: " Audio Device CPW90-DECT 4 Note..."
+ m2 = re.match(r"^\s*(Audio Device|Other Accessories|Other|Camera|Accessories)?\s*"
+ r"([A-Z][A-Za-z0-9][\w\-/.]*)\s+(\d+|Unlimited|Nonsupport|N/A|\-)\s*(.*)$", ln)
+ if m2:
+ cat, model, qty, note = m2.group(1), m2.group(2), m2.group(3), m2.group(4).strip()
+ if model.lower() in ("device", "accessories"):
+ continue
+ try:
+ q = int(qty)
+ except ValueError:
+ q = 0 if qty.lower().startswith("nonsupport") else None
+ cur_dev["accessories"].append({
+ "model": model, "role": role_of(model), "max_qty": q,
+ "note": re.sub(r"\s{2,}", " ", note)[:200] or None,
+ })
+ return [d for d in devices if d["accessories"]]
+
+
+def main():
+ if len(sys.argv) < 2:
+ print("использование: parse_compat.py [ ...]")
+ return 1
+ import yaml
+ os.makedirs(OUT, exist_ok=True)
+ total_dev = total_acc = 0
+ for pdf in sys.argv[1:]:
+ text = text_of(pdf)
+ src = os.path.basename(pdf)
+ devs = parse_guide(text, src)
+ for d in devs:
+ safe = re.sub(r"[^A-Za-z0-9._-]+", "_", d["device"])[:60]
+ path = os.path.join(OUT, "yealink", safe + ".yaml")
+ os.makedirs(os.path.dirname(path), exist_ok=True)
+ with open(path, "w", encoding="utf-8") as f:
+ yaml.safe_dump({"compatibility": {
+ "vendor": "yealink", "device": d["device"],
+ "source": {"file": src, "kind": "official_guide", "verified": True},
+ "accessories": d["accessories"]}},
+ f, allow_unicode=True, sort_keys=False, width=160)
+ total_dev += 1
+ total_acc += len(d["accessories"])
+ print(" %-28s аксессуаров: %2d" % (d["device"][:28], len(d["accessories"])))
+ print("\nустройств: %d | рёбер совместимости: %d" % (total_dev, total_acc))
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/ops/work/tools/parse_compat2.py b/ops/work/tools/parse_compat2.py
new file mode 100644
index 0000000..50f3ab0
--- /dev/null
+++ b/ops/work/tools/parse_compat2.py
@@ -0,0 +1,136 @@
+#!/usr/bin/env python3
+"""Извлечение официальных таблиц совместимости Yealink (v2).
+
+Исправления:
+ - состояние таблицы: парсим только между заголовком и следующим разделом
+ - заметки склеиваются из строк-продолжений
+ - дубли между источниками не перезаписывают, а дополняются
+"""
+import os
+import re
+import subprocess
+import sys
+
+OUT = os.environ.get("COMPAT_OUT", "/opt/work-hub/compat")
+
+ROLE_MAP = [
+ (r"^CPW\d|^VCM\d|^CP9\d\d|^CP7\d\d|^MSpeaker|^CM\d|^CS\d|^BT\d", "audio"),
+ (r"^CTP\d", "touch"),
+ (r"^UVC\d", "camera"),
+ (r"^VCH\d|^WPP\d|^WF\d|^DD1\d", "hub_or_sharing"),
+ (r"^VCR\d", "remote"),
+ (r"^MVC|^MCore", "kit"),
+]
+
+STOP_PATTERNS = [
+ r"^\s*\| .* \|\s*\d+\s*$", # колонтитул
+ r"^\s*\d+\.\s+[A-Z].*", # новый раздел
+ r"^\s*(Contents|Before You Begin|Getting Started|Troubleshooting)\b",
+ r"^\s*$", # пустая строка завершает таблицу
+]
+
+
+def role_of(model):
+ for pat, role in ROLE_MAP:
+ if re.match(pat, model, re.I):
+ return role
+ return "other"
+
+
+def text_of(pdf):
+ r = subprocess.run(["pdftotext", "-layout", pdf, "-"],
+ capture_output=True, text=True, timeout=180)
+ return r.stdout or ""
+
+
+ROW_RE = re.compile(
+ r"^\s{2,}([A-Z][\w\-/.]*(?:\s+[A-Z][\w\-/.]*)?)\s{2,}"
+ r"(\d+|Unlimited|Nonsupport|N/A)\s*(.*)$")
+
+
+def parse_guide(text, source):
+ devices, cur, in_table, last = [], None, False, None
+ for raw in text.splitlines():
+ s = raw.strip()
+ m = re.match(r"^\d+\.\s*Compatibility of (.+?) with accessories", s, re.I)
+ if m:
+ cur = {"device": m.group(1).strip(), "accessories": [], "source": source}
+ devices.append(cur)
+ in_table, last = False, None
+ continue
+ if not cur:
+ continue
+
+ if re.search(r"Device\s+Accessories\s+Max\s+Qty\s+Note", s):
+ in_table, last = True, None
+ continue
+ if not in_table:
+ continue
+
+ # конец таблицы
+ if not s:
+ in_table, last = False, None
+ continue
+ if re.match(r"^\| .* \|\s*\d+\s*$", s) or re.match(r"^\d+\.\s+[A-Z]", s):
+ in_table, last = False, None
+ continue
+
+ m2 = ROW_RE.match(raw)
+ if m2:
+ model, qty, note = m2.group(1).strip(), m2.group(2), m2.group(3).strip()
+ if re.fullmatch(r"MeetingEye\s*\d{3}", model) or len(model) > 24:
+ continue # мусорная строка
+ try:
+ q = int(qty)
+ except ValueError:
+ q = 0 if qty.lower().startswith("nonsupport") else None
+ row = {"model": model, "role": role_of(model), "max_qty": q,
+ "note": re.sub(r"\s{2,}", " ", note) or None}
+ cur["accessories"].append(row)
+ last = row
+ continue
+ # строка-продолжение заметки
+ if last and len(s) > 3 and not re.match(r"^\s*\d+\.", s):
+ if last["note"]:
+ last["note"] = (last["note"] + " " + re.sub(r"\s{2,}", " ", s))[:250]
+ else:
+ last["note"] = re.sub(r"\s{2,}", " ", s)[:250]
+ return [d for d in devices if d["accessories"]]
+
+
+def main():
+ if len(sys.argv) < 2:
+ print("использование: parse_compat.py ...")
+ return 1
+ import yaml
+ merged = {}
+ for pdf in sys.argv[1:]:
+ for d in parse_guide(text_of(pdf), os.path.basename(pdf)):
+ key = d["device"].lower()
+ if key in merged:
+ have = {a["model"] for a in merged[key]["accessories"]}
+ for a in d["accessories"]:
+ if a["model"] not in have:
+ merged[key]["accessories"].append(a)
+ merged[key].setdefault("sources", []).append(d["source"])
+ else:
+ merged[key] = d
+ total = 0
+ for key, d in sorted(merged.items()):
+ safe = re.sub(r"[^A-Za-z0-9._-]+", "_", d["device"])[:60]
+ path = os.path.join(OUT, "yealink", safe + ".yaml")
+ os.makedirs(os.path.dirname(path), exist_ok=True)
+ with open(path, "w", encoding="utf-8") as f:
+ yaml.safe_dump({"compatibility": {
+ "vendor": "yealink", "device": d["device"],
+ "source": {"file": d["source"], "kind": "official_guide", "verified": True},
+ "accessories": d["accessories"]}},
+ f, allow_unicode=True, sort_keys=False, width=160)
+ total += len(d["accessories"])
+ print(" %-24s аксессуаров: %2d" % (d["device"][:24], len(d["accessories"])))
+ print("\nустройств: %d | рёбер: %d" % (len(merged), total))
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())