torlink Documentation

repository·main·Indexed 25 days ago

https://github.com/baairon/torlink

A terminal-based torrent finder and downloader (version 1.5.1) that searches curated reputable sources. It features a TUI for searching and managing torrents, as well as headless modes including a directory watcher, an HTTP API for queuing torrents via /add and /control endpoints, and a read-only HTTP file server for streaming downloads.

Tokens
4.6K
Snippets
8
Records
37
Agent score
90%

What's inside torlink

  1. Install torlink system-wide (configuration.nix)

    main

    To install torlink system-wide on NixOS, add inputs.torlink.packages.${pkgs.system}.default to your environment.systemPackages list in configuration.nix.

    # configuration.nix
    { pkgs, inputs, ... }: 
    
    { 
      environment.systemPackages = with pkgs; [ 
        ... 
        inputs.torlink.packages.${pkgs.system}.default 
        ... 
      ]; 
    }
  2. Install torlink in home-manager (home.nix)

    main

    To install torlink for a specific user using home-manager, add inputs.torlink.packages.${pkgs.system}.default to your home.packages list in home.nix.

    # home.nix
    { pkgs, inputs, ... }: 
    
    { 
      home.packages = with pkgs; [ 
        ... 
        inputs.torlink.packages.${pkgs.system}.default 
        ... 
      ]; 
    }
  3. Setup torlink for local development

    main

    To contribute to or work on torlink locally, follow these steps:

    1. Clone the repository.
    2. Install dependencies using npm install.
    3. Run the development version using npm run dev.
    4. Alternatively, build and run the bundled version:
      npm run build
      npx torlnk
    npm install
    npm run dev
  4. Install torlink via Nix Flake

    main

    To use torlink, add the repository as an input to your flake.nix. Note that the package is built using the unstable channel. If you are using a stable channel (e.g., 26.05) and wish to avoid using unstable dependencies, you can overwrite this by setting inputs.nixpkgs.follows = "nixpkgs" in your flake configuration.

    Once installed, the binary is executed using the command torlnk.

    inputs = {
      ...
      torlink.url = "github:baairon/torlink";
      ...
    }
  5. Search and download torrents in the TUI

    main

    Once torlink is running, you can interact with it using the following keyboard shortcuts:

    • Search: Type your query and press Enter.
    • Browse: Press Enter on an empty search bar to browse the curated library.
    • Download: Arrow to a result and press d to save it to your default downloads folder.
    • Custom Download Location: Arrow to a result and press shift+d to pick a specific folder for that download.
    • Change Default Downloads Folder: Press o in the Downloads pane.
    • Help: Press ? to view the full list of commands.
    • Seeding Control: Open the Seeding tab and press p to pause or stop an item.
  6. Use torlnk CLI commands

    main

    The torlnk CLI provides several modes for searching, downloading, and managing torrents. Use the following commands to interact with the application:

    • torlnk: Opens the terminal-native search TUI (Terminal User Interface).
    • torlnk "magnet:?xt=...": Starts a download immediately upon launch using a magnet link (ensure you quote magnet links to handle & characters).
    • torlnk path/to/file.torrent: Opens and starts a .torrent file on launch.
    • torlnk watch <dir>: Headless mode. Monitors a directory for new .torrent files, .magnet files, or .txt files containing magnet/info hashes. It automatically downloads and seeds them.
    • torlnk serve: Headless mode. Starts an HTTP API for adding torrents via POST /add.
    • torlnk files: Headless mode. Starts a read-only HTTP server to stream downloaded files.
    • torlnk attach: Opens or reattaches the TUI within a persistent tmux session.
    • torlnk update [--force]: Updates to the latest release and restarts any running daemons.
    • torlnk --version: Prints the current version.
  7. Use the Headless HTTP API to control torlnk

    main

    The torlnk daemon exposes a local HTTP server that allows external programs (scripts, web apps, or curl) to manage torrents without interactive keypresses.

    Security Note: By default, the server binds to 127.0.0.1. If you attempt to bind to a public interface, you must provide a token to authorize requests. You can set this via the --token CLI flag or the TORLINK_API_TOKEN environment variable.

    Default Port: 9161

  8. Configure concurrent download limits

    main

    The maximum number of active downloads can be configured in two ways:

    1. Constructor: Pass maxDownloads in the options object when instantiating DownloadQueue.
    2. Environment Variable: Set TORLINK_MAX_DOWNLOADS to a positive integer. If unset or invalid, the limit is 0 (unlimited).
  9. Relocate application state using TORLINK_STATE_DIR

    main

    You can relocate all persisted application state (data and configuration) by setting the TORLINK_STATE_DIR environment variable.

    When this environment variable is set:

    • The configuration directory is moved to $TORLINK_STATE_DIR/config.
    • The data directory is moved to $TORLINK_STATE_DIR/data.

    This is useful for portable-state setups or for redirecting application data to a temporary directory during testing.

  10. Configure the torlnk daemon server

    main

    When running the server via runServe, you can provide a ServeOptions object to customize the runtime behavior:

    OptionTypeDefaultDescription
    portnumber9161The port to listen on.
    hoststring127.0.0.1The host interface to bind to.
    tokenstringnullSecurity token required for non-loopback access.
    downloadDirstring-Directory where downloads are stored.
    seedTimeMsnumber0How long (in ms) to seed after finishing before stopping.
    deleteFilesbooleanfalseIf true, files are deleted when seedTimeMs expires.
  11. Torlink search sources by category

    main

    torlink searches a curated list of reputable sources. If a source is offline, the search continues with the remaining sources.

    | Category | Sources |
    | --- | --- |
    | Games | FitGirl |
    | Movies | YTS, The Pirate Bay, 1337x, BitTorrented |
    | TV | EZTV, The Pirate Bay, 1337x, BitTorrented |
    | Anime | Nyaa, SubsPlease |