torrust-index icon indicating copy to clipboard operation
torrust-index copied to clipboard

Torrents exporter

Open josecelano opened this issue 1 year ago • 1 comments

Parent issue: https://github.com/torrust/torrust-index/issues/767

A console command to export the index data (torrents) to a directory in a basic format (no zip).

Proposals are welcome. I will add a simple reference proposal.

cc @da2ce7

josecelano avatar Nov 14 '24 12:11 josecelano

Include Metadata in metainfo file

Here’s a JSON representation of the torrent file with a root-level "metadata" field (outside the "info" dictionary) that won’t affect the info-hash:

JSON Format Example

{
  "announce": "http://tracker.example.com/announce",
  "info": {
    "name": "example_file.mp4",
    "piece length": 524288,
    "pieces": "<binary piece hashes>"
  },
  "metadata": {
    "id": 12345,
    "title": "Sample Torrent Title",
    "description": "This is a **sample description** in basic markdown.",
    "category": "Movies",
    "tags": ["Drama", "Classic", "Public Domain"]
  }
}

Bencoded Format Example

In bencode, the format would look like this:

d8:announce25:http://tracker.example.com/announce
4:info
d4:name12:example_file.mp4
12:piece lengthi524288e
6:pieces<binary piece hashes>e
8:metadata
d2:idi12345e
5:title20:Sample Torrent Title
11:description45:This is a **sample description** in basic markdown.
8:category6:Movies
4:tagsl5:Drama7:Classic12:Public Domaineee

Pros and Cons of This Approach

Pros
  1. Info-Hash Stability: By placing metadata outside the "info" dictionary, you keep the torrent's info-hash unchanged, making it compatible with existing peers.
  2. Non-intrusive Metadata: Other clients that don’t support or require the metadata will still interpret the file as a standard torrent without issue.
  3. Ease of Export/Import: Having a single torrent file with embedded metadata allows seamless export/import across indexes without needing additional files.
Cons
  1. Non-standard Extension: This structure deviates from the traditional BitTorrent specification, so some torrent clients might not recognize or handle the "metadata" field, potentially ignoring it or producing errors.
  2. Compatibility Risks: While the added metadata should be harmless, some older or stricter torrent clients may not fully support it.
  3. Limited Searchability: Since this metadata is only accessible within each torrent file, it won't be easily searchable by torrent clients that lack custom handling for the "metadata" field.

This setup should offer a good balance of usability and compatibility for admins needing to transfer metadata across indexes.

cc @da2ce7

josecelano avatar Nov 14 '24 15:11 josecelano