# `Laev.RD`
[🔗](https://github.com/alexdont/laev/blob/main/lib/laev/rd.ex#L1)

Real-Debrid REST API client.

Core flow: `resolve_magnet/1` takes a magnet link and returns a direct
HTTPS stream URL, going through addMagnet -> selectFiles -> unrestrict.

# `add_magnet`

# `configured?`

# `delete_torrent`

# `download_magnet`

Download a source on Real-Debrid (for non-cached torrents), fetching only the
requested episode file — not the whole batch — and reporting progress through
`opts[:notify]` as `{:progress, percent, status, speed}`. Blocks (polling)
until RD finishes, then returns `{:ok, stream}`. Instant for cached torrents.

`opts`: `:episode` (file to select from a batch), `:notify`, `:max_wait_ms`.

# `library`

Torrents already downloaded in the user's account whose filename contains
every word of `query` — instant, guaranteed-playable sources (the same trick
DMM-style Stremio addons use to surface "definite" streams).

# `media_info`

Media details for an unrestricted download id (`stream.id`): RD probes
the container server-side and lists every audio/subtitle track with its
language — one ~300ms call, not a byte of the file fetched locally.

Runs inside source probing, where a slow answer costs more than a
missing one: no retries, short timeout, caller treats errors as "unknown".

# `resolve_magnet`

Magnet in, playable URL out.

Returns `{:ok, %{url: url, filename: name, filesize: bytes}}` when the
torrent is cached on RD (near-instant), or `{:error, {:not_cached, status, progress}}`
when RD has started downloading it server-side (it will be available later),
or `{:error, reason}` for API failures.

# `select_files`

# `torrent_info`

# `transcode_hls`

HLS transcode URL (AAC audio) for an unrestricted download id.

This is the fix for releases whose audio the browser can't decode
(DTS, TrueHD, AC3): RD re-muxes to HLS and transcodes audio to AAC.

# `unrestrict`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
