DEV Community

Crane Zhou
Crane Zhou

Posted on

Building an Open-Source AI Agent for Self-Hosted Media Acquisition & Multi-Drive Routing

If you run a home media server with Infuse, VidHub, Emby, or Jellyfin, you probably know the pain of maintaining a traditional automation stack.

Tools like Sonarr, Radarr, and MoviePilot are fantastic when your entire pipeline runs on clean private trackers or Usenet indexers with predictable scene naming. But if you use cloud drives (like 115, Quark, UC Drive, 123Pan, Guangya, or Tianyi) or public share/magnet indexers, regex rules break down quickly:

  1. Dead links and fake files: Public share links and uncached magnets fail half the time or unpack into promotional spam images.
  2. Unstandardized season/episode numbering: Anime and multi-season shows frequently use continuous episode numbers or non-standard folder trees that confuse mechanical parsers.
  3. Storage fragmentation: Free cloud drive tiers fill up fast, forcing you to manually juggle which show lives on which drive.
  4. Missing subtitles: Raw 4K REMUX or WEB-DL releases often ship without Chinese/localized external subtitles.

To solve this, I built Mediary Scout (GitHub), an open-source (MIT) AI agent workflow engine for self-hosted media tracking and cloud drive organization.

Mediary Scout Demo


How the Agentic Workflow Replaces Brittle Regex Rules

Instead of relying on static regular expressions to guess whether a candidate link matches your library, Mediary Scout gives an LLM agent a sandboxed set of storage and verification tools:

1. Natural-Language Discovery & Web Verification

Don't remember the exact title? You can type a plot description like "sci-fi movie where a soldier relives the same day" and the agent cross-references TMDB and web search to resolve Edge of Tomorrow (2014). It also checks actual aired episode dates so it never wastes tokens hunting for episodes that haven't aired yet.

Read more: AI Source Selection & External Subtitle Matching

2. Black-Box Staging Verification (Zero Library Pollution)

When the agent picks a share link or magnet candidate, it never writes directly to your media library.

  • It transfers the resource into an isolated _staging directory first.
  • It inspects the landed directory tree, checks actual video file extensions and sizes, verifies which episodes are really inside, and strips out promotional spam.
  • Only verified video files are renamed into clean Movies/, TV/, or Anime/ structures and moved into your production library. If a transfer fails or turns out to be fake, the staging folder is cleanly discarded.

3. Unified Multi-Drive Pooling & Space-Aware Routing

In our latest release (v2026.10.29), we introduced a unified MultiDriveStorageV2 architecture:

  • 6 Native Cloud Drives: Connect Quark, UC Drive, 115, 123Pan, Guangya Cloud, and Tianyi Cloud simultaneously via QR code or token.
  • Real-Time Quota Gate: Before transferring a large 4K package, the agent probes and caches each drive's remaining capacity (with a hard SANDBOX_DRIVE_OUT_OF_SPACE gate) so it never hammers a full drive.
  • Cross-Drive Season Completion: Ongoing shows default to the drive where earlier episodes already live, but if that drive runs out of space—or if missing episodes only exist on another provider—the agent seamlessly lands the remaining episodes on a second connected drive.

Deep dive: Multi-Drive Joint Acquisition & Space-Aware Routing and Which Cloud Drive Is Best for Media Tracking?

4. One-Sentence Source Replacement & Agent Memory

If you open your player and notice Episode 3 has hardcoded ads or low bitrate, you don't need to ssh into your NAS or edit exclusion regexes. Just leave a note for the agent on the show page:

"Episode 3 has no subtitles, replace it with a 4K source with Chinese subtitles."

The agent blacklists the old resource link key, searches for a replacement, verifies it in staging, swaps the file in place, and writes a post-mortem note into its persistent memory so future patrols remember your preference.

5. Built-In Agent API for Claude Code, Codex & OpenClaw

Mediary Scout also exposes a clean REST API with an X-API-Key header so your personal coding or desktop agents (Claude Code, Codex, OpenClaw) can query your library, trigger acquisitions, or inspect patrol status directly from your terminal or chat client.

API overview: Mediary Scout Agent API


Mediary Scout vs. MoviePilot vs. Sonarr

We wrote a detailed architectural comparison for self-hosters deciding which tool fits their stack:
👉 Mediary Scout vs. MoviePilot vs. Sonarr Comparison

Dimension Mediary Scout MoviePilot Sonarr + Radarr
Core Engine Sandboxed AI Agent Workflow PT / Rules + Plugins Usenet / BitTorrent Regex Profiles
Primary Storage 6 Cloud Drives (Quark, UC, 115, 123, Guangya, Tianyi) Local NAS + Selected Cloud Plugins Local Disk / NAS Array
Setup Time ~5 mins (Built-in free AI pool + QR login) High (PT sites, cookies, rules) Medium-High (Prowlarr + download clients)
Desktop & Docker Native macOS / Windows App + Docker Compose Docker Desktop + Docker

Try It Out (Live Demo & 5-Minute Docker Setup)

Feedback, bug reports, and PRs are very welcome!

Top comments (0)