This commit is contained in:
2026-11-15 17:34:41 -08:00
parent bc7c89b528
commit 46152a464d
37 changed files with 1413 additions and 3919 deletions

View File

@@ -4,7 +4,7 @@
## Health Check: `GET /health`
Runs responsiveness checks across registered scraper modules.
Runs responsiveness checks across registered scraper modules. Both `/health` and `/api/health` are supported.
```http
GET /health HTTP/1.1
@@ -18,82 +18,110 @@ Host: api.vyla.cc
### Response Payload
```json
{
"note": "This is a health check endpoint. This is extremely unreliable, be sure to test sources directly.",
"status": "ok",
"timestamp": "2026-11-14T20:30:00.000Z",
"tmdb": true,
"cache": 142,
"probe_id": 155,
"timestamp": "2026-11-15T12:00:00.000Z",
"sources": {
"vidlink": { "ok": true, "ms": 420 },
"vixsrc": { "ok": true, "ms": 610 },
"cinecat": { "ok": true, "ms": 890 },
"movy": { "ok": false, "ms": null }
"vidlink": { "ok": true, "latency": 350 },
"vixsrc": { "ok": true, "latency": 480 },
"cinecat": { "ok": false, "latency": 15000 }
}
}
```
**Key Fields:**
- `status`: Overall state (`"ok"` or `"degraded"`).
- `timestamp`: ISO 8601 probe timestamp.
- `tmdb`: True if `TMDB_API_KEY` is configured and responding.
- `cache`: Current number of active cached titles in LRU memory.
- `probe_id`: The TMDB ID used for the probe query.
- `sources`: Dictionary of per-source availability (`ok`) and roundtrip latency in milliseconds (`ms`).
---
## Direct Source Testing: `GET /test/:source`
## Test Directory: `GET /test`
Tests a single scraper directly without triggering all other providers:
Calling `GET /test` or `GET /api/test` returns auto-generated test URLs for every registered source:
```http
GET /test/vidlink?id=155 HTTP/1.1
GET /test HTTP/1.1
Host: api.vyla.cc
```
For television episodes, include season and episode:
```http
GET /test/vixsrc?id=1396&s=1&e=1 HTTP/1.1
```
### Response
Returns the raw candidate stream resolved by that scraper:
```json
{
"source": "vidlink",
"url": "https://upstream.example.com/playlist.m3u8",
"quality": "1080p",
"type": "hls",
"server": "vidlink-cf"
"vidlink": {
"movie": "/api/test/155?source=vidlink",
"tv": "/api/test/1396?season=1&episode=1&source=vidlink"
},
"vixsrc": {
"movie": "/api/test/155?source=vixsrc",
"tv": "/api/test/1396?season=1&episode=1&source=vixsrc"
}
}
```
---
## Deep Debug Route: `GET /debug/:source`
## Direct Source Testing: `GET /test/:tmdb_id`
Exposes diagnostic internals when `ENABLE_DEBUG_ROUTE=true` is set:
Tests a single scraper directly without triggering all other providers. Supports `/test/:id` and `/api/test/:id`.
### Movie Test
```http
GET /debug/vidlink?id=155 HTTP/1.1
GET /api/test/155?source=vidlink HTTP/1.1
Host: api.vyla.cc
```
**Output details:**
- Raw HTML or JSON received from upstream hosts.
- Time spent solving tokens and parsing DOM.
- Status code and headers from Phase 1 verification (`HEAD` check).
- First 500 bytes of the master M3U8 manifest.
- Preview of rewritten segment URLs.
**Parameters:**
- `tmdb_id` *(path, required)* — Numeric TMDB ID (e.g. `155`).
- `source` *(query, required)* — Source key to test (e.g. `vidlink`).
### TV Episode Test
```http
GET /api/test/1396?season=1&episode=1&source=vidlink HTTP/1.1
Host: api.vyla.cc
```
**Parameters:**
- `tmdb_id` *(path, required)* — Numeric TMDB Series ID (e.g. `1396`).
- `source` *(query, required)* — Source key to test (e.g. `vidlink`).
- `season` or `s` *(query, required)* — Season number (e.g. `1`).
- `episode` or `e` *(query, required)* — Episode number (e.g. `1`).
### Response Example
```json
{
"source": "vidlink",
"ok": true,
"stream": {
"url": "https://api.vyla.cc/api?url=https%3A%2F%2Fupstream.example.com%2Fmaster.m3u8",
"quality": "1080p",
"type": "hls",
"server": "vidlink-cf"
}
}
```
---
## Deep Debug Route: `GET /debug/:tmdb_id`
Exposes diagnostic internals when `ENABLE_DEBUG_ROUTE=true` is enabled in `.env`:
```http
GET /api/debug/155?source=vidlink HTTP/1.1
Host: api.vyla.cc
```
**Diagnostics Returned:**
- Raw HTML and JSON payloads from upstream providers.
- Resolution latency and DOM parsing metrics.
- Upstream HTTP status codes and headers from probe checks.
- First 500 bytes of upstream playlist manifests.
- Rewritten proxy segment URLs.
:::callout-warning
Keep `ENABLE_DEBUG_ROUTE=false` in production to prevent leaking upstream tokens or credentials.
Keep `ENABLE_DEBUG_ROUTE=false` in production to prevent leaking upstream tokens and API keys.
:::
---
## Cluster & Cache Architecture
- **In-Memory Cache**: Up to 1,500 verified titles stored in an LRU cache with a 5-minute TTL.
- **Cache Pruner**: Runs every 30 seconds to evict expired keys.
- **Worker Lifecycle**: The supervisor process maintains workers matching CPU core count, automatically replacing crashed processes.
- **IPC Messaging**: Workers coordinate via `cache:get` and `cache:set` messages, allowing instant cache hits across worker boundaries without an external database.
- **In-Memory Cache**: Up to 1,500 entries stored in primary process memory with a 5-minute TTL (`CACHE_TTL`).
- **Pruning Timer**: Runs automatically every 30 seconds to purge expired entries and maintain cache boundaries.
- **Worker Management**: Cluster primary supervises worker processes, automatically respawning workers on process exit.
- **IPC Synchronization**: Workers communicate through `cache:get`, `cache:set`, and `cache:push` IPC messages for fast cross-process cache hits.