LinuxCommandLibrary

webtorrent

Download and seed torrent files

TLDR

Download a torrent

$ webtorrent download "[torrent_id]"
copy

Stream a torrent to VLC media player
$ webtorrent download "[torrent_id]" --vlc
copy

Stream a torrent to a Digital Living Network Alliance (DLNA) device
$ webtorrent download "[torrent_id]" --dlna
copy

Display a list of files for a specific torrent
$ webtorrent download "[torrent_id]" --select
copy

Specify a file index from the torrent to download
$ webtorrent download "[torrent_id]" --select [index]
copy

Seed a specific file or directory
$ webtorrent seed [path/to/file_or_directory]
copy

Create a new torrent file for the specified file path
$ webtorrent create [path/to/file]
copy

Display information for a magnet URI or .torrent file
$ webtorrent info [path/to/file_or_magnet]
copy

SYNOPSIS

webtorrent [command] [options] [arguments]

Common commands:
webtorrent download [magnet_uri | .torrent_file | info_hash] [options]
webtorrent seed [path/to/file_or_folder] [options]
webtorrent info [magnet_uri | .torrent_file | info_hash]
webtorrent create [path/to/file_or_folder] [options]

PARAMETERS

--help, -h
    Displays usage information and available options for the command.

--version, -v
    Shows the installed WebTorrent CLI version number.

--path <path>, -o <path>
    Specifies the directory where downloaded files will be saved. Defaults to the current working directory.

--port <port>
    Sets the peer listening port for incoming connections (default is 6881).

--upload-limit <bytes/sec>, --ul <bytes/sec>
    Limits the maximum upload speed for the torrent to the specified rate in bytes per second.

--download-limit <bytes/sec>, --dl <bytes/sec>
    Limits the maximum download speed for the torrent to the specified rate in bytes per second.

--files <index | range>, -s <index | range>
    Selects specific files to download from a multi-file torrent (e.g., '1' for the first file, '2-5' for files 2 through 5).

--stdout
    Pipes the first file of the torrent directly to standard output, enabling streaming to other command-line tools or media players.

--quiet, -q
    Suppresses all non-essential output, showing only critical errors.

--verbose
    Enables verbose logging, providing more detailed operational output for debugging.

--keep-seeding
    Instructs the client to continue seeding the torrent even after the download has fully completed.

--remove
    Deletes the downloaded files from disk when the webtorrent command exits (primarily for download command).

--force
    Forces overwrite of existing files or directories without prompting for confirmation.

DESCRIPTION

webtorrent is a command-line interface (CLI) for WebTorrent, a peer-to-peer streaming torrent client written in JavaScript. It allows users to download and stream torrents directly from the terminal without fully downloading them first. The tool supports magnet links, .torrent files, and info hashes. Its key features include instant playback of media files while they are still downloading, thanks to its ability to connect with both traditional BitTorrent peers via TCP and browser-based WebRTC peers.

Beyond streaming, webtorrent can also seed local files and create new torrents, making it a versatile tool for sharing and consuming large media files. It provides options for managing bandwidth, selecting specific files within a multi-file torrent, and piping content directly to standard output for integration with other command-line tools and media players.

CAVEATS

webtorrent relies on Node.js and npm for its execution environment, meaning these prerequisites must be installed on the system. While excellent for streaming, its performance for very large torrents or complex file management might not always match highly optimized native BitTorrent clients. Streaming capabilities often benefit from piping output to external media players like VLC or MPV for optimal playback.

WEBTORRENT DESKTOP APPLICATION

In addition to the CLI, WebTorrent offers a full-featured desktop application. This GUI client provides an intuitive interface for streaming and downloading torrents, built upon the same core WebTorrent technology and offering a user-friendly experience for non-CLI users.

BROWSER INTEGRATION VIA WEBRTC

A fundamental innovation of WebTorrent is its ability to connect directly to WebRTC peers. This means webtorrent can download and upload data with web browsers and other WebTorrent clients that support WebRTC, enabling new paradigms for distributed web applications and live content sharing.

STREAMING PLAYBACK WITH EXTERNAL PLAYERS

The primary strength of webtorrent is its instant streaming capability. Users can effectively play video and audio content as it downloads by using the --stdout option and piping the output to media players like VLC, MPV, or other tools that can read from standard input, providing a seamless viewing or listening experience.

HISTORY

WebTorrent was initiated by Feross Aboukhadijeh with the ambitious goal of bringing BitTorrent to the browser using WebRTC, enabling true peer-to-peer file transfer directly within web pages. The webtorrent command-line interface emerged as a natural extension, allowing the same innovative streaming and P2P capabilities to be utilized directly from the terminal. Its development has focused on instant playback and efficient resource management, setting it apart from traditional BitTorrent clients by prioritizing immediate access to content over full download completion. It has evolved to support connections with both browser-based (WebRTC) and traditional (TCP/uTP) BitTorrent peers.

SEE ALSO

Copied to clipboard