added seeding code after downloading torrent
This commit is contained in:
parent
47c3bc61f0
commit
3cce122fb2
@ -1,6 +1,9 @@
|
|||||||
<h5>WEBTOR</h5>
|
<h5>WEBTORRENT</h5>
|
||||||
|
|
||||||
|
<p>Step 1: In server.example.js provide correct crdentials as per your flo.conf file.</p>
|
||||||
|
<p>Step 2: Rename server.example.js to server.js</p>
|
||||||
|
|
||||||
To run the file
|
To run the file
|
||||||
|
|
||||||
<p>Run npm install</p>
|
<p>Step 3: Run npm install</p>
|
||||||
<p>Run npm start</p>
|
<p>Step 4: Run npm start</p>
|
||||||
|
|||||||
3
files/.gitignore
vendored
Normal file
3
files/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*
|
||||||
|
*/
|
||||||
|
!.gitignore
|
||||||
@ -83,7 +83,14 @@ router.post('/download-magnetic-uri', (req, res)=>{
|
|||||||
source.on('end', function () {
|
source.on('end', function () {
|
||||||
console.log('file:\t\t', file.name)
|
console.log('file:\t\t', file.name)
|
||||||
|
|
||||||
|
// Seed file
|
||||||
|
client.seed(file, function (tor) {
|
||||||
|
console.log(tor);
|
||||||
|
console.log('Client is seeding ' + tor.magnetURI)
|
||||||
|
})
|
||||||
|
|
||||||
res.json({file:file.name, location:fullpath})
|
res.json({file:file.name, location:fullpath})
|
||||||
|
|
||||||
// close after all files are saved
|
// close after all files are saved
|
||||||
if (!--length) process.exit()
|
if (!--length) process.exit()
|
||||||
}).pipe(destination)
|
}).pipe(destination)
|
||||||
|
|||||||
@ -90,6 +90,14 @@
|
|||||||
// Stream the file in the browser
|
// Stream the file in the browser
|
||||||
file.appendTo('#output')
|
file.appendTo('#output')
|
||||||
|
|
||||||
|
torrent.on('done', function (file) {
|
||||||
|
// Seed file
|
||||||
|
client.seed(file, function (tor) {
|
||||||
|
console.log(tor);
|
||||||
|
console.log('Client is seeding ' + tor.magnetURI)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
// Trigger statistics refresh
|
// Trigger statistics refresh
|
||||||
torrent.on('done', onDone)
|
torrent.on('done', onDone)
|
||||||
setInterval(onProgress, 500)
|
setInterval(onProgress, 500)
|
||||||
|
|||||||
@ -33,38 +33,13 @@
|
|||||||
type: 'post',
|
type: 'post',
|
||||||
data: {job:job, torrentId:torrentId},
|
data: {job:job, torrentId:torrentId},
|
||||||
success: function(response) {
|
success: function(response) {
|
||||||
|
console.log(response);
|
||||||
|
|
||||||
// if (typeof response.file != undefined) {
|
if (response.location !== undefined) {
|
||||||
// let file = response.file;
|
document.getElementById('dwld').innerHTML = `<a href="file://${response.location}" target="_blank" download onclick="window.open('file://${response.location}')">[Download .torrent]</a>`;
|
||||||
// var a = document.createElement('a')
|
} else {
|
||||||
// filename = response.file;
|
alert("Something went wrong!");
|
||||||
// uri = `file://${response.location}`;
|
}
|
||||||
|
|
||||||
// var link = document.createElement('a');
|
|
||||||
|
|
||||||
// if (typeof link.download === 'string') {
|
|
||||||
// console.log("a");
|
|
||||||
|
|
||||||
// link.href = uri;
|
|
||||||
// link.download = filename;
|
|
||||||
|
|
||||||
// //Firefox requires the link to be in the body
|
|
||||||
// document.getElementById("dwld").appendChild(link);
|
|
||||||
|
|
||||||
// //simulate click
|
|
||||||
// link.click();
|
|
||||||
|
|
||||||
// //remove the link when done
|
|
||||||
// document.getElementById("dwld").removeChild(link);
|
|
||||||
// console.log("aa")
|
|
||||||
// } else {
|
|
||||||
// console.log("b");
|
|
||||||
// window.open(uri);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
document.getElementById('dwld').innerHTML = `<a href="file://${response.location}" target="_blank" download onclick="window.open('file://${response.location}')">[Download .torrent]</a>`;
|
|
||||||
|
|
||||||
},
|
},
|
||||||
error: function(e) {
|
error: function(e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user