Refactor API to flat root routes and WS/meta structure
This commit is contained in:
+8
-9
@@ -11,22 +11,21 @@ All media paths are scoped to a **root**, identified by a stable `root_id`.
|
||||
| `GET` | `/api/config` | Returns the current root configuration. |
|
||||
| `GET` | `/api/roots` | List all active roots with status. |
|
||||
| `PUT` | `/api/roots` | Atomically replace the full root set. |
|
||||
| `GET` | `/api/roots/{root_id}/status` | Returns scanner and library status for one root. |
|
||||
| `POST` | `/api/roots/{root_id}/scan` | Triggers a new scan for one root. |
|
||||
| `POST` | `/api/roots/{root_id}/play` | Opens a media file with the system player. |
|
||||
| `POST` | `/api/roots/{root_id}/open-folder` | Opens a folder in the system file explorer. |
|
||||
| `GET` | `/api/roots/{root_id}/playback/resume-positions` | Returns saved resume positions for one root. |
|
||||
| `POST` | `/api/play/{root_id}` | Opens a media file with the system player. |
|
||||
| `POST` | `/api/open-folder/{root_id}` | Opens a folder in the system file explorer. |
|
||||
| `GET` | `/api/meta/{root_id}/{meta_key}` | Returns allowed metadata from `<root>/.mediahive`. |
|
||||
| `GET` | `/api/player/status` | Returns whether remote player control is currently available. |
|
||||
| `GET` | `/api/mpcbe/status` | Reports whether MPC-BE's local web interface is reachable. |
|
||||
| `GET` | `/api/media/{root_id}/{file_path:path}` | Serves files from the specified root. |
|
||||
| `GET` | `/api/roots/{root_id}/assets/{asset_path:path}` | Serves files from `<root>/.mediahive` via logical asset paths. |
|
||||
| `WS` | `/api/roots/{root_id}/ws` | Streams live index updates and task progress for one root. |
|
||||
| `GET` | `/api/assets/{root_id}/{asset_type}/{asset_path:path}` | Serves typed assets from `<root>/.mediahive`. |
|
||||
| `WS` | `/api/ws/{root_id}` | Streams live index updates and task progress for one root. |
|
||||
|
||||
## Notes
|
||||
|
||||
- `PUT /api/roots` accepts `{ "roots": { "name": "/absolute/path", ... } }`, validates paths, and atomically swaps the active set.
|
||||
- `POST /api/roots/{root_id}/play` and `POST /api/roots/{root_id}/open-folder` expect JSON request bodies with `file_path` / `folder_path` relative to the root.
|
||||
- `POST /api/play/{root_id}` and `POST /api/open-folder/{root_id}` expect JSON request bodies with `file_path` / `folder_path` relative to the root.
|
||||
- `GET /api/media/{root_id}/{file_path:path}` is constrained to the specified root; path traversal outside the root is rejected.
|
||||
- `GET /api/roots/{root_id}/assets/{asset_path:path}` is constrained to `<root>/.mediahive`; metadata image URLs should use this endpoint.
|
||||
- `GET /api/assets/{root_id}/{asset_type}/{asset_path:path}` is constrained to `<root>/.mediahive/{asset_type}` where `asset_type` is one of `movies`, `series`, `people`.
|
||||
- `GET /api/meta/{root_id}/{meta_key}` supports metadata keys currently limited to `playback-state` and `scanignore`.
|
||||
- `GET /api/player/status` returns `{ "remote": true|false }`.
|
||||
- `GET /api/mpcbe/status` returns `false` on non-Windows platforms.
|
||||
|
||||
@@ -47,14 +47,12 @@ Each active root gets an isolated `RootContext` managed by the `Supervisor`:
|
||||
|----------|-------------|
|
||||
| `GET /api/roots` | List all roots (name, path, root_id, status) |
|
||||
| `PUT /api/roots` | Atomically replace full root map `{name: path}` |
|
||||
| `GET /api/roots/{root_id}/status` | Per-root scanning/loading/error state |
|
||||
| `POST /api/roots/{root_id}/scan` | Trigger scan for one root |
|
||||
| `WS /api/roots/{root_id}/ws` | Per-root WebSocket (init/upsert/remove/task) |
|
||||
| `WS /api/ws/{root_id}` | Per-root WebSocket (init/upsert/remove/task + status/task events) |
|
||||
| `GET /api/media/{root_id}/{path:path}` | Serve media file scoped to root |
|
||||
| `GET /api/roots/{root_id}/assets/{asset_path:path}` | Serve `.mediahive` assets via logical paths |
|
||||
| `POST /api/roots/{root_id}/play` | Play file within root |
|
||||
| `POST /api/roots/{root_id}/open-folder` | Open folder within root |
|
||||
| `GET /api/roots/{root_id}/playback/resume-positions` | Per-root resume positions |
|
||||
| `GET /api/assets/{root_id}/{asset_type}/{asset_path:path}` | Serve `.mediahive/{asset_type}` assets (`movies`, `series`, `people`) |
|
||||
| `POST /api/play/{root_id}` | Play file within root |
|
||||
| `POST /api/open-folder/{root_id}` | Open folder within root |
|
||||
| `GET /api/meta/{root_id}/{meta_key}` | Per-root metadata (for example `playback-state`) |
|
||||
| `POST /api/ui/pick-folder` | Native OS folder picker (returns path) |
|
||||
|
||||
> **Removed legacy endpoints**: `/api/change-folder`, `/api/index`, `/api/scan`, `/api/status`, `/api/playback/resume-positions`. No backwards compatibility is maintained.
|
||||
@@ -93,4 +91,4 @@ All stored and transmitted paths use forward slashes exclusively:
|
||||
- `App.vue` merges per-root `movieMap`/`seriesMap` into a single `mediaIndex`.
|
||||
- `Header.vue` provides add/remove root UI via `PUT /api/roots`.
|
||||
- Playback URLs are root-qualified (`/api/media/{root_id}/...`).
|
||||
- Metadata cache assets use logical root paths (`/api/roots/{root_id}/assets/...`) rather than exposing `.mediahive` in URLs.
|
||||
- Metadata cache assets use typed root paths (`/api/assets/{root_id}/{asset_type}/...`) rather than exposing `.mediahive` in URLs.
|
||||
|
||||
Reference in New Issue
Block a user