Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display the total downloads/completed downloads of a torrent #671

Open
1 task
josecelano opened this issue Nov 26, 2024 Discussed in #521 · 0 comments
Open
1 task

Display the total downloads/completed downloads of a torrent #671

josecelano opened this issue Nov 26, 2024 Discussed in #521 · 0 comments
Labels
- User - Enjoyable to Use our Software Easy Good for Newcomers Enhancement / Feature Request Something New good first issue Good for newcomers

Comments

@josecelano
Copy link
Member

Discussed in #521

Originally posted by josecelano April 11, 2024
Proposed on: #519 by @ty5e3a45.

Currently, we only show the number of seeders and leechers for a torrent.

The Index API endpoint does not contain that info:

{
    "data": {
        "torrent_id": 987,
        "uploader": "admin",
        "info_hash": "a158dcb05854578f37f4fc79ef2206547143a0f5",
        "title": "title-e2fc03f9-f7be-4b4c-aa9d-65da0cedbed4",
        "description": "description-e2fc03f9-f7be-4b4c-aa9d-65da0cedbed4",
        "category": {
            "id": 6,
            "category_id": 6,
            "name": "test",
            "num_torrents": 1000
        },
        "upload_date": "2024-03-13 09:49:25",
        "file_size": 37,
        "seeders": 0,
        "leechers": 0,
        "files": [
            {
                "path": [
                    "file-e2fc03f9-f7be-4b4c-aa9d-65da0cedbed4.txt"
                ],
                "length": 37,
                "md5sum": null
            }
        ],
        "trackers": [
            "udp://localhost:6969"
        ],
        "magnet_link": "magnet:?xt=urn:btih:a158dcb05854578f37f4fc79ef2206547143a0f5&dn=title-e2fc03f9-f7be-4b4c-aa9d-65da0cedbed4&tr=udp%3A%2F%2Flocalhost%3A6969",
        "tags": [],
        "name": "file-e2fc03f9-f7be-4b4c-aa9d-65da0cedbed4.txt",
        "comment": null,
        "creation_date": null,
        "created_by": null,
        "encoding": null,
        "canonical_info_hash_group": [
            "a158dcb05854578f37f4fc79ef2206547143a0f5"
        ]
    }
}

It only contains the number of seeders and leechers. It does not contain the number of complete downloads because the Index does not have that number now. The Index imports that info from the tracker and stores the stats in this table:

CREATE TABLE "torrust_torrent_tracker_stats" (
	"torrent_id"	INTEGER NOT NULL,
	"tracker_url"	VARCHAR(256) NOT NULL,
	"seeders"	INTEGER NOT NULL DEFAULT 0,
	"leechers"	INTEGER NOT NULL DEFAULT 0,
	"updated_at"	TEXT DEFAULT 1000-01-01 00:00:00,
	FOREIGN KEY("torrent_id") REFERENCES "torrust_torrents"("torrent_id") ON DELETE CASCADE,
	UNIQUE("torrent_id","tracker_url"),
	PRIMARY KEY("torrent_id")
);

There is a background task to import statistics from the tracker that uses this tracker endpoint:

http://localhost:1212/api/v1/torrents?infohash=9c38422213e30bff212b30c360d26f9a02136422&token=MyAccessToken

[
  {
    "info_hash": "9c38422213e30bff212b30c360d26f9a02136422",
    "seeders": 1,
    "completed": 0,
    "leechers": 0
  }
]

In order to implement this feature we need to:

Screenshot

image

I'll open the issues because it's a good first issue for new contributors.

Subtasks

@josecelano josecelano added Enhancement / Feature Request Something New Easy Good for Newcomers - User - Enjoyable to Use our Software good first issue Good for newcomers labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- User - Enjoyable to Use our Software Easy Good for Newcomers Enhancement / Feature Request Something New good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant