-
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
24 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
language: node_js | ||
node_js: | ||
- 'node' | ||
- lts/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,24 @@ | ||
// var WebTorrent = require('webtorrent-hybrid') | ||
var WebTorrent = require('../index') | ||
var fs = require('fs') | ||
const WebTorrent = require('../index') | ||
const fs = require('fs') | ||
|
||
var client = new WebTorrent() | ||
const client = new WebTorrent() | ||
|
||
var torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d' | ||
const torrentId = 'magnet:?xt=urn:btih:6a9759bffd5c0af65319979fb7832189f4f3c35d' | ||
|
||
console.log('torrentId:\t', torrentId) | ||
|
||
client.add(torrentId, function (torrent) { | ||
var files = torrent.files | ||
var length = files.length | ||
client.add(torrentId, torrent => { | ||
const files = torrent.files | ||
let length = files.length | ||
// Stream each file to the disk | ||
files.forEach(function (file) { | ||
var source = file.createReadStream() | ||
var destination = fs.createWriteStream(file.name) | ||
source.on('end', function () { | ||
files.forEach(file => { | ||
const source = file.createReadStream() | ||
const destination = fs.createWriteStream(file.name) | ||
source.on('end', () => { | ||
console.log('file:\t\t', file.name) | ||
// close after all files are saved | ||
if (!--length) process.exit() | ||
length -= 1 | ||
if (!length) process.exit() | ||
}).pipe(destination) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,11 @@ | ||
// var WebTorrent = require('webtorrent-hybrid') | ||
var WebTorrent = require('../index') | ||
const WebTorrent = require('../index') | ||
|
||
var client = new WebTorrent() | ||
|
||
var filePath = './node-seed.js' | ||
const client = new WebTorrent() | ||
const filePath = __filename | ||
|
||
console.log('filePath:', filePath) | ||
|
||
client.seed(filePath, function (torrent) { | ||
client.seed(filePath, torrent => { | ||
console.log('torrentId (info hash):', torrent.infoHash) | ||
// console.log('torrentId (magnet link):', torrent.magnetURI) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
var createTorrent = require('create-torrent') | ||
const createTorrent = require('create-torrent') | ||
const wrtc = require('wrtc') | ||
|
||
global.WEBTORRENT_ANNOUNCE = createTorrent.announceList | ||
.map(function (arr) { | ||
return arr[0] | ||
}) | ||
.filter(function (url) { | ||
return url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0 | ||
}) | ||
|
||
var wrtc = require('wrtc') | ||
.map(arr => arr[0]) | ||
.filter(url => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0) | ||
|
||
global.WRTC = wrtc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters