Torrent Parse icon

Torrent Parse

Parse torrent file from base64 or file path

Overview

This node parses torrent files provided either as base64-encoded content or as a file path. It extracts key metadata from the torrent, such as the info hash, magnet URI, display name, total size, main tracker URL, list of trackers, privacy flag, and file details within the torrent.

Common scenarios for this node include:

  • Extracting torrent metadata to generate magnet links for sharing.
  • Analyzing torrent contents programmatically in workflows.
  • Validating torrent files before further processing or distribution.

For example, you can input a base64 string representing a torrent file and get back its magnet URI and file list, which can then be used to automate torrent downloads or indexing.

Properties

Name Meaning
Input Type The type of input to parse. Options: "Base64" (base64 encoded torrent content), "File Path" (path to a torrent file on disk).
Base64 Content The base64 encoded torrent file content. Shown only if Input Type is "Base64".
File Path The path to the torrent file on the filesystem. Shown only if Input Type is "File Path".

Output

The node outputs an array of JSON objects, each containing parsed torrent metadata with the following structure:

  • success (boolean): Indicates if parsing was successful.
  • infohash (string): The torrent's info hash in uppercase hexadecimal.
  • magnet_uri (string): The generated magnet URI for the torrent.
  • dn (string): Display name of the torrent.
  • xl (number): Total size of the torrent content in bytes.
  • main_tracker (string): The primary announce URL (tracker).
  • tracker_list (array of strings): List of all announce URLs (trackers).
  • is_private (boolean): Whether the torrent is marked private.
  • files (array of objects): Each object has:
    • path (string): File path inside the torrent.
    • length (number): Size of the file in bytes.

If parsing fails, the output JSON will contain an error field with the error message.

The node does not output binary data.

Dependencies

  • Requires access to the Node.js fs module to read files when using the "File Path" input type.
  • Uses standard JavaScript APIs for base64 decoding and text encoding/decoding.
  • No external API keys or services are required.

Troubleshooting

  • Invalid input: If the input is not a valid base64 string or the file path does not point to a valid torrent file, the node will throw an error or return an error message in the output JSON.
  • File path issues: Ensure the file path is correct and accessible by the n8n process. Use absolute paths or resolve relative paths carefully.
  • Parsing errors: If the torrent file is corrupted or malformed, parsing will fail with an "invalid torrent file" error.
  • Continue on Fail: If enabled, the node will continue processing subsequent items even if one item fails parsing, returning error details per item.

Links and References

Discussion