# MediaFilez Worker

Run media execution without a Discord bot or frontend.

The [open-source worker](https://github.com/MediaFilez/media-worker) contains a reusable Media Core, an execution runtime, storage adapters, and an optional queue consumer. It does not contain a Discord client, an HTTP API server, or a website.

## Choose an entry point

| Entry point                 | Use it when                                              | Needs Redis?          |
| --------------------------- | -------------------------------------------------------- | --------------------- |
| Hosted HTTP API             | You want managed downloads from another application      | No Redis on your side |
| `WorkerRuntime.execute()`   | You want jobs with limits, storage, retries, and cleanup | No                    |
| `createMediaCore()`         | You need lower-level download and processing functions   | No                    |
| `pnpm start` queue consumer | You operate an API/worker deployment                     | Yes                   |

```mermaid
flowchart TD
    accTitle: Worker architecture
    accDescr: Queue, CLI and Node callers enter the runtime; Media Core handles execution and the storage adapter commits output.
    Q[Queue consumer] --> R[WorkerRuntime]
    C[CLI job] --> R
    N[Your Node application] --> R
    R --> M[Media Core: download and validate]
    M --> P[Optional processing]
    P --> S[Storage adapter]
    S --> O[Structured result]
    A[AbortSignal and execution limits] -.-> R
```

## Responsibilities

The worker selects an execution plan, tries configured fallbacks, downloads within byte and time limits, checks the file, and optionally converts or fits it. Output goes through a storage adapter after processing.

Instagram collections can return every resolved item. Other native extractor playlists are restricted to one item; use explicit batch jobs for multiple source links.

Self-hosting requires storage capacity, tool availability, and a retention policy. Use only sources and optional providers you are permitted to access. Guarded URL checks and deadlines are not a complete operating-system sandbox. Apply process/container isolation appropriate to the users who can submit jobs.

Start with [runtime jobs](/docs/en/worker/jobs), [Media Core](/docs/en/worker/media-core), or [queue deployment](/docs/en/worker/self-hosting). The repository uses AGPL-3.0-only; read its license before reusing it in your service.
