# Debrid service accounts

A debrid service, such as Real-Debrid, AllDebrid or Premiumize, is a paid account that downloads files from file hosts
on its own servers. It hands back a plain direct link, without the host's waits, speed caps
and captchas. With your account in Grabbit, a link from a host your service supports is unlocked
through the service, then downloaded by Grabbit like any file: all its connections, pause and
resume.

Grabbit supports three services: **Real-Debrid**, **AllDebrid** and **Premiumize**.

> **Experimental:** built from each service's public API documentation, not yet confirmed with a
> real paid account. AllDebrid's answers were also checked against its real API with the public
> demo key from its documentation, which answers with sample data, not a real file. If something
> doesn't work with your account, please
> [open an issue](https://github.com/HUMBLEF0OL/grabbit/issues) (never paste your
> token or key in it).

## Add your account

1. **Options → Accounts → Add...**
2. Pick the service, then either:
   - **Sign in in the browser** (Real-Debrid and AllDebrid): Grabbit shows a code and opens the
     service's page. Type the code there (AllDebrid's page already has it) and allow Grabbit. The
     dialog notices on its own.
   - or paste your **API token** (**Find my token** opens the service's page that shows it),
     then **Use the token**. Premiumize signs in this way only: paste the API key from its
     Account page.
3. Grabbit checks the account and shows its name and whether it is premium. **OK** keeps it.

The list's order is the order accounts are asked: a link goes through the first account
whose service supports its host. **Up** and **Down** change it.

**Download supported file-host links through these accounts** turns it all off and on.

## Torrents through the service

Tick **Send torrents and magnet links to the first account instead of to peers** in
**Options → Accounts**. A magnet link (Add, the browser, the clipboard, a drop) or a
`.torrent` file (Add torrent's **Download now** or **Later**) then goes to the first account in
the list:

1. The service downloads the torrent on its own servers. The list shows how far it is, such as
   **45% at Real-Debrid**. A torrent the service already has is ready at once.
2. Grabbit then downloads its files from the service over HTTP, as any download, into the
   **Torrents** folder. A torrent of several files gets a folder of its own there.
3. Once every file is here, Grabbit removes the torrent from the account's list. On Premiumize,
   only the transfer's record goes: its files stay in your cloud.

- Your computer never connects to the torrent's peers.
- A `.torrent` file is sent as its magnet link (its hash, its name and its trackers). Every file
  of the torrent is downloaded; the service fetches the whole torrent.
- Stopped, or after a restart, the download continues where it was: the service isn't sent the
  torrent again, and files already downloaded aren't downloaded again.
- A file name that would land outside the torrent's folder (`../`) stops the download, and
  nothing is written.
- If the service can't get the torrent (no peers, too big, refused), the list says why.

## What happens to a link

- Add, the clipboard, the browser's **Download with Grabbit** link menu,
  and batch downloads go through the account when its service supports
  the link's host.
- A download the browser had already started (Grabbit took it over from the browser) is
  downloaded as it is: the host is already sending the file.
- The command line's `get` and `resume` use the same accounts, and say `through Real-Debrid`;
  `--direct` downloads the address itself ([command line](https://humblef0ol.github.io/grabbit/help/command-line.html)).
- The list keeps the host's link. The direct link is never shown or copied: the services
  forbid sharing it. It lives only in the download's resume data, and when it expires Grabbit asks
  the service for a new one.
- A link the service can't give says why in the list: sign in again, premium needed, the host
  is down (Grabbit tries again later), the file is gone, and so on.
- AllDebrid sometimes needs a while to prepare a link. Grabbit waits for it, up to 10 minutes,
  and the list says so.
- Grabbit asks each service well under its request limit: Real-Debrid at most 120 times a minute
  (it allows 250), AllDebrid 300 (it allows 600), Premiumize 60 (it publishes no limit). When
  a service says it's asked too often, Grabbit waits.

## Download one link directly instead

- **Download file info** says which account a link goes through: **Download through
  Real-Debrid (your account)**, ticked. Untick it to download that one link directly, without
  the service. Grabbit looks the address up again the new way, so the name and size shown are the
  ones you will get. A download the browser had already started shows it unticked.
- For a download already in the list, **File properties** has the same choice beside the login:
  **Through Real-Debrid**. It can be changed while the download isn't running. The next start
  goes the new way, and continues from what is already downloaded when the file is the same.
- Grabbit keeps the choice with the download, after a restart too.

## Your account, your rules

- Use only your own account. Sharing an account or its links breaks the services' terms and
  can get the account suspended.
- Grabbit sends the service only the links you download through it, and your account's token or
  key. Nothing else.
- Grabbit ships no list of hosts or links; the service says which hosts it supports.

## Where the sign-in is kept

In **Windows Credential Manager**, as are Site logins' passwords and the proxy's. Grabbit's
settings keep only a reference to it. **Options → Accounts** says where they are on your computer.

- **Installed or the plain zip**: in **Windows Credential Manager** (Control Panel → Credential Manager → Windows
  Credentials), as entries named `Grabbit/…`, for your Windows account. They
  roam with your profile, as Grabbit's settings folder does.
- **A portable copy** writes nothing outside its folder: it keeps them in its own settings,
  encrypted for your Windows account.

Sign-ins saved by an earlier version move to Credential Manager on the next start; the settings
keep the old copy until Credential Manager has it. A removed account's entry leaves Credential
Manager with it.

**Uninstalling** with **remove the download list and settings** removes Grabbit's entries from
Credential Manager too. To remove them yourself:
`grabbit --forget-sign-ins` (only Grabbit's own entries).

Grabbit never writes the token to its event log, crash reports, the automation API or the
command line's output.
