kryten-webqueue 0.2.4__tar.gz → 0.2.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/PKG-INFO +1 -1
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/catalog/sync.py +43 -13
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/pyproject.toml +1 -1
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/.github/workflows/python-publish.yml +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/.github/workflows/release.yml +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/.gitignore +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/README.md +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/config.example.json +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/deploy/kryten-webqueue.service +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/deploy/nginx-queue.conf +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/docs/IMPLEMENTATION_SPEC.md +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/docs/IMPL_API_GATE.md +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/docs/IMPL_ECONOMY.md +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/docs/IMPL_KRYTEN_PY.md +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/docs/IMPL_ROBOT.md +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/docs/PRE_PLAN_GAPS.md +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/docs/PRODUCT_PLAN.md +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/__init__.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/__main__.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/api_gate/__init__.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/api_gate/client.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/app.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/auth/__init__.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/auth/otp.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/auth/rate_limit.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/auth/session.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/catalog/__init__.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/catalog/db.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/catalog/images.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/config.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/playlists/__init__.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/playlists/fire.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/playlists/importer.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/playlists/scheduler.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/queue/__init__.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/queue/ordering.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/queue/poller.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/queue/shadow.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/routes/__init__.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/routes/admin_playlists.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/routes/admin_queue.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/routes/admin_schedules.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/routes/auth.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/routes/catalog.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/routes/pages.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/routes/queue.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/routes/user.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/static/css/main.css +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/static/js/main.js +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/templates/admin/index.html +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/templates/auth/login.html +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/templates/base.html +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/templates/catalog/browse.html +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/templates/queue/index.html +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/templates/user/dashboard.html +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/ws/__init__.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/ws/handler.py +0 -0
- {kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/ws/manager.py +0 -0
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
import httpx
|
|
2
2
|
import logging
|
|
3
3
|
from datetime import datetime, UTC
|
|
4
|
+
from urllib.parse import urlparse
|
|
4
5
|
|
|
5
6
|
logger = logging.getLogger(__name__)
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
def _describe_httpx_error(exc: Exception, url: str) -> str:
|
|
10
|
+
"""Return a human-readable description of an httpx network error."""
|
|
11
|
+
host = urlparse(url).netloc or url
|
|
12
|
+
if isinstance(exc, httpx.ConnectTimeout):
|
|
13
|
+
return f"Connection to {host} timed out — check host/port and firewall"
|
|
14
|
+
if isinstance(exc, httpx.ConnectError):
|
|
15
|
+
cause = str(exc.__cause__ or exc).lower()
|
|
16
|
+
if "name or service not known" in cause or "nodename nor servname" in cause or "getaddrinfo" in cause:
|
|
17
|
+
return f"DNS lookup failed for {host} — check mediacms_url in config"
|
|
18
|
+
if "connection refused" in cause:
|
|
19
|
+
return f"Connection refused by {host} — service may be down"
|
|
20
|
+
return f"Could not connect to {host}: {exc.__cause__ or exc}"
|
|
21
|
+
if isinstance(exc, httpx.ReadTimeout):
|
|
22
|
+
return f"Read timed out waiting for response from {host}"
|
|
23
|
+
if isinstance(exc, httpx.TimeoutException):
|
|
24
|
+
return f"Request to {host} timed out"
|
|
25
|
+
return f"{type(exc).__name__} connecting to {host}: {exc}"
|
|
26
|
+
|
|
27
|
+
|
|
8
28
|
class CatalogSync:
|
|
9
29
|
"""Synchronizes catalog data from MediaCMS."""
|
|
10
30
|
|
|
@@ -32,12 +52,19 @@ class CatalogSync:
|
|
|
32
52
|
stats = {"seen": 0, "new": 0, "updated": 0, "errors": 0}
|
|
33
53
|
|
|
34
54
|
try:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
55
|
+
next_url: str | None = f"{self._url}/api/v1/media"
|
|
56
|
+
params: dict = {"page_size": 50}
|
|
57
|
+
page = 0
|
|
58
|
+
|
|
59
|
+
while next_url:
|
|
60
|
+
page += 1
|
|
61
|
+
try:
|
|
62
|
+
resp = await self._client.get(next_url, params=params if page == 1 else None)
|
|
63
|
+
except httpx.TransportError as exc:
|
|
64
|
+
logger.error(_describe_httpx_error(exc, next_url))
|
|
65
|
+
stats["errors"] += 1
|
|
66
|
+
break
|
|
67
|
+
|
|
41
68
|
if resp.status_code != 200:
|
|
42
69
|
logger.error(
|
|
43
70
|
f"MediaCMS API returned {resp.status_code} for URL {resp.url} — "
|
|
@@ -60,15 +87,18 @@ class CatalogSync:
|
|
|
60
87
|
logger.warning(f"Error processing {media.get('friendly_token')}: {e}")
|
|
61
88
|
stats["errors"] += 1
|
|
62
89
|
|
|
63
|
-
#
|
|
64
|
-
if isinstance(data, dict)
|
|
65
|
-
|
|
66
|
-
page += 1
|
|
90
|
+
# Follow the next URL from the response — don't construct it ourselves
|
|
91
|
+
next_url = data.get("next") if isinstance(data, dict) else None
|
|
92
|
+
logger.debug(f"Catalog sync page {page}: seen={stats['seen']} next={next_url!r}")
|
|
67
93
|
|
|
68
94
|
await self._db.finish_sync_log(log_id, stats, "completed")
|
|
69
|
-
logger.info(f"Catalog sync: {stats}")
|
|
70
|
-
except
|
|
71
|
-
logger.
|
|
95
|
+
logger.info(f"Catalog sync complete: {stats} ({page} pages)")
|
|
96
|
+
except httpx.TransportError as exc:
|
|
97
|
+
logger.error(_describe_httpx_error(exc, f"{self._url}/api/v1/media"))
|
|
98
|
+
stats["errors"] += 1
|
|
99
|
+
await self._db.finish_sync_log(log_id, stats, "error")
|
|
100
|
+
except Exception as exc:
|
|
101
|
+
logger.exception(f"Catalog sync failed: {type(exc).__name__}: {exc}")
|
|
72
102
|
stats["errors"] += 1
|
|
73
103
|
await self._db.finish_sync_log(log_id, stats, "error")
|
|
74
104
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/templates/catalog/browse.html
RENAMED
|
File without changes
|
|
File without changes
|
{kryten_webqueue-0.2.4 → kryten_webqueue-0.2.6}/kryten_webqueue/templates/user/dashboard.html
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|