mirror of
https://github.com/asapach/peerflix-server.git
synced 2026-04-25 14:45:50 +03:00
[GH-ISSUE #154] How i can add new torrent from magnet link? #343
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @MindOnFire93 on GitHub (Oct 9, 2018).
Original GitHub issue: https://github.com/asapach/peerflix-server/issues/154
How i can add new torrent using the magnet link from shell command or php cli?
@asapach commented on GitHub (Oct 9, 2018):
Try using REST API -
POST /torrentsPHP must have an HTTP client, so you can send the request that way.
Otherwise you could use something like curl from the shell.
@MindOnFire93 commented on GitHub (Oct 10, 2018):
Hello, i try to send the POST through html, using JSON, like that code:
function show_alert() {
alert("Sending Request");
var xhr = new XMLHttpRequest();
xhr.open(form.method, form.action, true);
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
var j = {
"link":"magnet:?xt=urn:btih:hash",
};
xhr.send(JSON.stringify(j));
}
but i got the error page;
"
TypeError: path must be a string or Buffer
at TypeError (native)
at Object.fs.readFile (fs.js:305:11)
at readTorrent (/usr/lib/node_modules/peerflix-server/node_modules/read-torrent/index.js:54:8)
at EventEmitter.add (/usr/lib/node_modules/peerflix-server/server/store.js:36:5)
at /usr/lib/node_modules/peerflix-server/server/index.js:69:9
at callbacks (/usr/lib/node_modules/peerflix-server/node_modules/express/lib/router/index.js:164:37)
at param (/usr/lib/node_modules/peerflix-server/node_modules/express/lib/router/index.js:138:11)
at pass (/usr/lib/node_modules/peerflix-server/node_modules/express/lib/router/index.js:145:5)
at Router._dispatch (/usr/lib/node_modules/peerflix-server/node_modules/express/lib/router/index.js:173:5)
at Object.router (/usr/lib/node_modules/peerflix-server/node_modules/express/lib/router/index.js:33:10)"
so please help me understand how to send it the magnet link data, or using shell or php-cli or simple post from input box.. Thanks
@asapach commented on GitHub (Oct 10, 2018):
Judging by the stacktrace it's not able to parse the magnet link. Are you sure it's valid?
If you can debug locally try adding a console log here to see what the value of
req.body.linkis:github.com/asapach/peerflix-server@733b6c22b1/server/index.js (L69)@MindOnFire93 commented on GitHub (Oct 10, 2018):
exaple i try post like this, but nothing, what is the syntax of this magnet..
'magnet:?xt=urn:btih:hash_info' ); $json = json_encode($data); $client = new Zend_Http_Client($uri); $client->setRawData($json, 'application/json')->request('POST'); ?>@asapach commented on GitHub (Oct 10, 2018):
I've tried your original example and it worked fine for me:
Unfortunately I'm not familiar with PHP to help you with your http client.
@MindOnFire93 commented on GitHub (Oct 10, 2018):
I can do it in html page too, sending it with input box and function, i try, but it don't work..., i don't have some experience with JSON, probably i call it in wrong way :( Really idk..
@MindOnFire93 commented on GitHub (Oct 10, 2018):
Fine it finally work, i wrong to call the function, Thanks you a lot :)..
@asapach commented on GitHub (Oct 10, 2018):
No problem.
@MindOnFire93 commented on GitHub (Oct 10, 2018):
Antoher question, the download and upload of peer-flix can be limited, I MEAN THE SEED AND LEECH of any file, like utorrent, speed limit to max (number)?
And if how to config this? Maybe if you send me the configuration syntax in one url, I would be grateful to you. Thanks, Mind
@asapach commented on GitHub (Oct 10, 2018):
There's no way to throttle the speed, unfortunately. The only things you can configure are (https://github.com/mafintosh/torrent-stream#full-api):
connectionsanduploads.You can set them using the configuration file
@MindOnFire93 commented on GitHub (Oct 11, 2018):
Thank you so much. Have a nice day :)