Laev.RD (laev v0.1.40)

Copy Markdown View Source

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.

Summary

Functions

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.

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 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.

Magnet in, playable URL out.

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

Functions

add_magnet(magnet)

configured?()

delete_torrent(id)

download_magnet(magnet, opts \\ [])

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(query)

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(download_id)

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, opts \\ [])

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(id, file_ids)

torrent_info(id)

transcode_hls(download_id)

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(link)