Add an HTTP endopoint to resolve magnet URL to bytes (address #177)#181
Add an HTTP endopoint to resolve magnet URL to bytes (address #177)#181
Conversation
josecelano
left a comment
There was a problem hiding this comment.
Hi @ikatson Thank you so much! Looks good! Just a couple of things:
Missing info key
I've tried with a torrent, and the response is:
{
"length": 4932407296,
"name": "ubuntu-23.04-desktop-amd64.iso",
"piece length": 262144,
"pieces": "<hex>OMITTED</hex>"
}and it should be:
{
"info": {
"length": 4932407296,
"name": "ubuntu-23.04-desktop-amd64.iso",
"piece length": 262144,
"pieces": "<hex>OMITTED</hex>"
}
}That's the torrent file in JSON format (by using https://chocobo1.github.io/bencode_online/).
Timeout for the endpoint
It seems there is no timeout if the client can't find the torrent. That's not a problem for me because I can't put the timeout in the API client, but it would be good for the server. Some examples: torrust/torrust-index#467
|
Fixed the first one, please check For the timeout one, there are no timeouts anywhere in HTTP API, so this would be a separate issue / PR |
Hi @ikatson, It works! Just for the record, I'm testing this way: Run the client with: cargo run server start ~/Downloads/TorrentSeeds/Download the torrent from the magnet link: curl -v --data-raw 'magnet:?xt=urn:btih:443c7602b4fde83d1154d6d9da48808418b181b6' http://localhost:3030/torrents/resolve_magnet > ~/Downloads/Torrents/2024-08-13-ubuntu-23.04-desktop-amd64.iso.torrentThe downloaded torrent ( {
"announce": "",
"announce-list": [
[]
],
"info": {
"length": 4932407296,
"name": "ubuntu-23.04-desktop-amd64.iso",
"piece length": 262144,
"pieces": "<hex>OMITTED. TOO BIG</hex>"
}
} |
curl -v --data-raw 'magnet:?...' http://localhost:3030/torrents/resolve_magnet > /tmp/file.torrent