Save Torrent Metadata as .torrent in aria2?

This article provides a quick overview and step-by-step guide on how to configure the aria2 download utility to automatically save torrent metadata as a local .torrent file when starting downloads from magnet links. By default, aria2 fetches this metadata to start your download but discards it afterward. By utilizing specific command-line flags or configuration file settings, you can preserve these files for backing up your torrent library, seeding from other clients, or sharing the metadata directly.

The Core Configuration Options

To force aria2 to retain the .torrent file after processing a magnet link, you need to use two specific configuration options: bt-save-metadata and bt-metadata-only.

Here is how these two settings work:

Implementing via Command Line

If you are running aria2 on an ad-hoc basis from the terminal, you can append these options directly to your execution command.

aria2c --bt-save-metadata=true "magnet:?xt=urn:btih:..."

If you only want the .torrent file and want to skip downloading the payload files, use:

aria2c --bt-save-metadata=true --bt-metadata-only=true "magnet:?xt=urn:btih:..."

Implementing via Configuration File

For a permanent solution that applies to all future magnet link downloads, you can add these parameters to your global aria2 configuration file (usually named aria2.conf).

  1. Open your aria2.conf file in a text editor.
  2. Add the following lines to the file:
# Save torrent metadata to a local .torrent file
bt-save-metadata=true

# Uncomment the line below if you only want the metadata and no data files
# bt-metadata-only=true
  1. Save and close the file.

Once configured globally, any magnet link passed to aria2 will automatically generate a corresponding .torrent file in the output directory.