--- title: VR Media Server 2.0 emoji: 🥽 colorFrom: blue colorTo: pink sdk: docker app_port: 7860 pinned: false license: mit --- # VR Media Server 2.0 **Offcloud + TeraBox + Blomp → DEOVR → Quest 3 Passthrough** A professional GUI-based VR Media Server that runs on Hugging Face Docker Spaces. It connects directly to your Offcloud account and/or TeraBox (cookie session or official Open Platform OAuth) and/or Blomp (OpenStack Swift), runs an 11-layer metadata detection pipeline on every video, and serves a DEOVR-compatible JSON feed that your Quest 3 can consume for passthrough playback. > **Metadata-first streaming gateway.** Videos stay on Offcloud / TeraBox / Blomp. The server never downloads or permanently stores video binaries — it only fetches metadata, samples frames transiently, and serves stream URLs. --- ## How Hugging Face Docker Spaces Work HF Spaces with the `docker` SDK are just a Docker image + a git repo. The mechanics: 1. **Required files** (commit these to the Space repo): - `README.md` — must have the YAML frontmatter at the top (the `sdk: docker` line tells HF to build your Dockerfile) - `Dockerfile` — HF builds this image and runs it - All your app source code 2. **Port binding**: HF expects the app to listen on port **7860** by default. You can override via `app_port` in the README frontmatter, but 7860 is the convention. The Dockerfile in this repo sets `ENV PORT=7860` and `EXPOSE 7860`. 3. **Persistent storage**: HF Spaces are ephemeral — the filesystem is wiped on every restart. To persist data (your SQLite DB, scan history, corrections), enable **Persistent Storage** in the Space settings and mount it at `/data`. This repo's Dockerfile writes the DB to `/data/vrms.db`. 4. **Secrets**: API keys should be set as HF **Space Secrets**, not in code or env files. Go to Space → Settings → Repository secrets and add `OFFCLOUD_API_KEY` (and/or `TERABOX_COOKIE` / TeraBox OAuth credentials, and/or `BLOMP_EMAIL` + `BLOMP_PASSWORD`). The container will receive them as env vars. 5. **Resource limits** (free tier): - 16 GB RAM - 2 vCPU - 50 GB persistent storage (if enabled) - Container restarts after 48h of inactivity on free tier 6. **Build & deploy**: Every `git push` to the Space repo triggers a rebuild. Build time ~3-5 minutes. Logs are visible in the Space → Logs tab. 7. **Public URL**: Your space is accessible at `https://-.hf.space`. The DEOVR feed endpoint is at `/api/feeds/deovr`. --- ## Quick Deploy (5 minutes) ### Option A: One-click from this repo 1. Create a new Hugging Face Space at [huggingface.co/new-space](https://huggingface.co/new-space) - **Owner**: your account - **Space name**: `vr-media-server` - **License**: MIT - **SDK**: Docker - **Hardware**: CPU basic (free) - **Persistent storage**: optional but recommended (small tier is fine) 2. Clone this repo locally and push to your Space: ```bash git clone cd vr-media-server git remote add space https://huggingface.co/spaces//vr-media-server git push -u space main ``` 3. Wait ~5 minutes for the build to finish (check Space → Logs). 4. (Optional) Connect your sources: - **Offcloud** — Space → Settings → Repository secrets → New secret: `OFFCLOUD_API_KEY` (from [offcloud.com/account](https://offcloud.com/account)) - **TeraBox** — either add `TERABOX_COOKIE` as a secret, or open the app's **Settings → TeraBox Connection** and connect with a cookie or OAuth. - **Blomp** — add `BLOMP_EMAIL` + `BLOMP_PASSWORD` as secrets, or open **Settings → Blomp Connection** and sign in with your Blomp account. 5. Open the Space URL. You'll see the VR Dark Pro dashboard. Click **Scan Library** in the top bar (or **Scan TeraBox** / **Scan Blomp** in Settings) to populate the combined library. ### Option B: Without a real cloud source (mock mode) If you just want to try the UI, skip step 4 above. When neither Offcloud, TeraBox nor Blomp is configured, the server falls back to a realistic mock library of 12 sample VR videos (VR180, VR360, Fisheye, Passthrough, etc.). All 11 detection layers run on the mock data — the UI is fully demoable. As soon as one real source is connected, mock data is disabled so it never mixes with your library. --- ## Architecture ``` ┌─────────────┐ ┌──────────────────┐ ┌─────────────┐ ┌────────┐ ┌──────────┐ │ Offcloud │ → │ VR Media Server │ → │ DEOVR Feed │ → │ DEOVR │ → │ Quest 3 │ │ (CDN/API) │ │ (this app) │ │ /api/feeds/ │ │ Player │ │ Passthru │ ├─────────────┤ └──────────────────┘ └─────────────┘ └────────┘ └──────────┘ │ TeraBox │ → │ │ (cookie / │ ├─ Metadata Engine (11 layers) │ OAuth API) │ ├─ AI Analysis Platform (v3.0 stub) ├─────────────┤ ├─ Confidence Scoring (weighted) │ Blomp │ → └─ SQLite @ /data/vrms.db │ (Swift v1) │ └─────────────┘ ``` The server acts as **Content Manager + Metadata Engine + DEOVR Feed Generator**. It is explicitly NOT a storage server — videos remain on Offcloud / TeraBox / Blomp and are streamed through this server's proxy via refreshed signed URLs. All three sources are merged into one library, tagged with a **source badge**, and can be filtered by source in the Library view. The DEOVR feed groups scenes into `Offcloud Library`, `TeraBox Library`, and `Blomp Library ()` - the Blomp tab shows the folder(s) it was built from. With no root configured the scanner starts at `/deovr` and auto-detects every other folder that contains videos. --- ## TeraBox Integration TeraBox can be used **alongside** Offcloud as a second content source. There are two connection modes: ### 1. Cookie / session mode (recommended, full drive) 1. Log in to [terabox.com](https://www.terabox.com) in a desktop browser. 2. Open DevTools → **Application → Cookies → https://www.terabox.com**. 3. Copy the `ndus` cookie value (or the entire cookie header). 4. In this app: **Settings → TeraBox Connection → mode "Cookie / session"**. 5. Paste the cookie, set the **Library Root** (default `/`), then **Save TeraBox** → **Test connection**. Cookie mode walks your entire personal drive recursively and can stream any video file. The `ndus` cookie expires periodically — paste a fresh one if scanning or playback starts failing. ### 2. Official Open Platform OAuth (app folder only) The official API requires a business/partner app from [terabox.com/integrations](https://www.terabox.com/integrations): 1. Create an app and note its `client_id`, `client_secret`, and `private_secret`. 2. Enter them in **Settings → TeraBox Connection → mode "Open Platform OAuth"** and save. 3. Authenticate with either: - **QR / device-code flow** — click **Get QR code**, scan it in the TeraBox mobile app, and approve. - **Authorization code flow** — complete the OAuth login, paste the returned `code`, and click **Exchange**. 4. Access tokens last 2 days, refresh tokens 30 days; the server refreshes and persists them automatically. > **Important:** the official Open Platform API is sandboxed to the app's assigned folder — `/From: Other Applications//`. It cannot see the rest of your personal drive. Set the **Library Root** to that folder. Use cookie mode for full-drive access. ### Streaming details - TeraBox `dlink`s are temporary; the server refreshes them before every playback, ffprobe probe, and thumbnail. - The `/api/stream/...` proxy forwards the required browser User-Agent, `ndus` cookie, and `terabox.com` Referer, and preserves them across redirects. - Detection and thumbnails use the internal authenticated proxy (`?token=...`) because ffprobe/ffmpeg cannot send cookies. - OAuth dlinks get `&access_tokens=` appended as required by the official API. --- ## Blomp Integration Blomp can be used **alongside** Offcloud and TeraBox as a third content source. Blomp exposes an **OpenStack Swift** object store (it is not S3-compatible), so this integration talks to Blomp's Keystone v2 auth endpoint and the Swift storage endpoint directly. ### Setup 1. Create a free account at [blomp.com](https://www.blomp.com/) and upload your videos. 2. In this app: **Settings → Blomp Connection**. 3. Enter your Blomp **account email** and **password**, then **Save Blomp** → **Test connection**. 4. Optionally set a **Container** and **Library Root**: - **Container** — Blomp containers are usually named after your account email. Leave blank to auto-detect the email-named container (or the only container on the account). - **Library Root** - leave blank to auto-detect: the scanner starts at `/deovr` and also finds every other folder that contains videos. Enter a path to scan only that folder, or use `/` for the whole container. 5. Click **Save Blomp**. The account is indexed immediately and then checked every 60 seconds, so new videos appear and deleted videos disappear without any manual scan. **Scan Blomp** is still there for an on-demand pass. You can also preconfigure it with the `BLOMP_EMAIL`, `BLOMP_PASSWORD`, `BLOMP_CONTAINER`, and `BLOMP_ROOT` environment variables / Space Secrets. The `BLOMP_SYNC_ENABLED` and `BLOMP_SYNC_INTERVAL_SECONDS` variables control the automatic sync. ### How it works - **Auth**: `POST https://authenticate.blomp.com/v2.0/tokens` with `tenantName: "storage"` and your email/password. The returned token and object-store endpoint are cached in memory until shortly before expiry. - **Listing**: Swift container/object listings are paginated with `limit` + `marker`; the scanner walks the whole configured prefix and excludes `.file-segments/` (Static Large Object chunks). - **Objects**: Each video is stored as `source="blomp"` with `sourceId`/`sourcePath` = `/`. - **Auto-sync**: saving the Blomp connection starts a full reconcile immediately; afterwards the server polls the container every 60 seconds (configurable with `BLOMP_SYNC_INTERVAL_SECONDS`). New objects are added and queued for detection automatically, and objects deleted from Blomp are hidden from the library/feed and purged after the shared grace period. Re-uploading a removed object restores its row. - **Playback**: Blomp object URLs are stable, but objects are private. The `/api/stream/...` proxy attaches `X-Auth-Token` (and re-attaches it across redirects), forwards HTTP Range requests for seeking, and streams the body without downloading it to disk. - **Almost read-only**: this app only lists and downloads from Blomp. The only writes are the small auto-fetched thumbnail images (see below) — uploaded with `If-None-Match`, so an existing file is never overwritten. Videos are never uploaded, overwritten or deleted. - **Thumbnails / detection**: both go through the internal authenticated proxy (`?token=...`) because ffprobe/ffmpeg cannot send Swift auth headers. Blomp's upload path has historically had a per-object limit for plain Swift uploads; large files stored as Static Large Objects are served transparently by Swift, so they work here without special handling. ### Custom thumbnails from your drive Upload an image **anywhere** in your Blomp drive that is named like a video — e.g. `Trip to Mars.mp4` pairs with `trip_to_mars.JPG`, `Trip to Mars.mp4.png`, or `Trip to Mars - poster.webp` — and within one sync cycle (60 s, or immediately with **Scan Blomp**) that exact image becomes the video's thumbnail everywhere: dashboard, library, VR gallery, DEOVR feed and PLAY'A library. The bytes you uploaded are served as-is. Replace the image and the thumbnail updates; delete it and the video falls back to the auto-extracted frame. See [README-CUSTOM-THUMBNAILS.md](README-CUSTOM-THUMBNAILS.md) for the full naming and priority rules. ### Auto-fetched thumbnails from the web For videos you have **not** given a thumbnail, the server searches the public internet for one using the **video title** and uploads the best match back to your Blomp drive — automatically, the moment the video is indexed: - **Search**: the title is cleaned of file/codec/VR junk (`GTA Rampage 8K SBS.mp4` → `GTA Rampage`) and searched keyless on DuckDuckGo, then Bing, then Openverse. Results are ranked against the title (token overlap, image size, format) and the first one that downloads and sniffs as a real image wins. - **Folder**: the title also picks the destination — a folder that **already exists** on the drive whose name appears in the title. `GTA Rampage.mp4` goes to your `gta` folder, `SLR Fun.mp4` to `SLR`. Folders are never created; when no folder name matches, the thumbnail lands next to the video. - **Apply**: the image is uploaded as `