Permalink
Browse files

Fix chunkpath for testing

  • Loading branch information...
pldubouilh committed Mar 7, 2018
1 parent b2a0d17 commit 6a346036eefa5bad4bad2f599377b10c10d96d79
Showing with 8 additions and 13 deletions.
  1. +1 −1 client/fake-video.html
  2. +6 −11 lib/wtManifest.js
  3. +1 −1 package.json
@@ -13,7 +13,7 @@
const chunksDone = {}
const manifestName = 'manifest.m3u8'
const manifestURL = 'http://127.0.0.1:8008/'
const chunksLocation = 'https://live.computer/'
const chunksLocation = ''
const dlManifest = async () => {
const m = await fetch(manifestURL + manifestName)
@@ -17,6 +17,7 @@ function wtManifest (fullManifestPath = '', makeFromFolder = '', delay, loop = f
// Torrent from local folder
if (this.isLocalStream) {
this.chunksLoc = ''
this.localPath = addTrailingSlash(makeFromFolder)
this.sm = makeFromFolder ? new StreamMaker(makeFromFolder, delay, loop) : null
} else {
@@ -42,7 +43,7 @@ wtManifest.prototype.computeMagnet = function (file, cn) {
createTorrent(file, { announceList: this.announceList }, (err, t) => {
if (err) return console.log(err)
const magnet = parseTorrent.toMagnetURI(parseTorrent(t))
resolve('###' + magnet + '\n')
resolve(magnet)
})
})
}
@@ -54,19 +55,13 @@ wtManifest.prototype.makeMagnet = async function (f) {
if (self.fileToMagnet[cn]) return
// Fetch payload and compute magnet
let payload
if (self.isLocalStream) {
payload = await fs.readFile(self.localPath + f)
} else {
// Use url if one's been provided. Otherwise use chunksLoc
const url = isUrl(f) ? f : self.chunksLoc + removeDanglingSlash(f)
payload = await request(url, { encoding: null })
}
const url = isUrl(f) ? f : self.chunksLoc + removeDanglingSlash(f)
const payload = self.isLocalStream ? await fs.readFile(self.localPath + f) : await request(url, { encoding: null })
const magnet = await self.computeMagnet(payload, cn)
// Store magnet computed
self.fileToMagnet[cn] = magnet
self.fileToMagnet[cn] = '###' + magnet + '\n' + url
self.magnetsOrder.push(cn)
if (self.magnetsOrder.length > 10) {
@@ -97,7 +92,7 @@ wtManifest.prototype.makeManifest = async function (manifest) {
await self.makeAllMagnets(files)
// Pop manifest back, inject magnet links alongside TS files
self.manifest = split.map(l => l.includes('.ts') ? self.fileToMagnet[chunkName(l)] + l : l).join('\n')
self.manifest = split.map(l => l.includes('.ts') ? self.fileToMagnet[chunkName(l)] : l).join('\n')
self.sequence = sequence
return self.manifest
}
@@ -1,6 +1,6 @@
{
"name": "live-torrent",
"version": "0.0.4",
"version": "0.0.5",
"description": "",
"main": "index.js",
"scripts": {

0 comments on commit 6a34603

Please sign in to comment.