How to use the parse-torrent.toTorrentFile function in parse-torrent

To help you get started, we’ve selected a few parse-torrent examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / parse-torrent / parse-torrent-tests.ts View on Github external
//      '70cf6aee53107f3d39378483f69cf80fa568b1ea',
//      'c53b506159e988d8bc16922d125d77d803d652c3',
//      'ca3070c16eed9172ab506d20e522ea3f1ab674b3',
//      'f923d76fe8f44ff32e372c3b376564c6fb5f0dbe',
//      '52164f03629fd1322636babb2c014b7dae582da4',
//      '1363965261e6ce12b43701f0a8c9ed1520a70eba',
//      '004400a267765f6d3dd5c7beb5bd3c75f3df2a54',
//      '560a61801147fa4ec7cf568e703acb04e5610a4d',
//      '56dcc242d03293e9446cf5e457d8eb3d9588fd90',
//      'c698de9b0dad92980906c026d8c1408fa08fe4ec' ] }

const uri = parseTorrent.toMagnetURI({
    infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
});

const buf = parseTorrent.toTorrentFile({
    infoHash: 'd2474e86c95b19b8bcfdb92bc12c9d44667cfa36',
});

parseTorrent.remote('d2474e86c95b19b8bcfdb92bc12c9d44667cfa36', (err, parsedTorrent) => {
    // if (err) throw err
    // console.log(parsedTorrent)
});
github xuset / aether-torrent / lib / torrent.js View on Github external
self.createdBy = torrentMeta.createdBy
  self.announce = torrentMeta.announce
  self.urlList = self._customWebSeeds.concat(torrentMeta.urlList)
  self.length = torrentMeta.length
  self.pieceLength = torrentMeta.pieceLength
  self.lastPieceLength = torrentMeta.lastPieceLength
  self.pieces = torrentMeta.pieces
  self.info = torrentMeta.info
  self.magnetURI = parseTorrent.toMagnetURI(torrentMeta)

  // TODO is it better to check 'info' instead?
  if (torrentMeta.files && torrentMeta.pieceLength) {
    self.files = torrentMeta.files.map(function (f) { return new File(self, f) })
    self._chunkStore = self._torrentDB.createChunkStore(self.pieceLength)
    self._chunkStore._store.on('set', self._onChunkPut.bind(self))
    self.torrentMetaBuffer = parseTorrent.toTorrentFile(torrentMeta)
    self.ready = true
    self.emit('ready')
  }
}
github DiegoRBaquero / PeerTube / server.js View on Github external
r.table('videos').insert({infoHash: parsedTorrent.infoHash, name: req.body.name, torrent: parsedTorrent, peers: 0, createdAt: r.now()}).run().then((result) => {
      // lg(result)
      res.redirect('/')
    })

    try {
      fs.accessSync('public/videos/' + parsedTorrent.infoHash, fs.F_OK)
      // Do something
      return
    } catch (e) {
      console.error(e)
      // It isn't accessible
      lg("doesn't exist")
    }

    torrent = parseTorrent.toTorrentFile(parsedTorrent)

    fs.mkdir('public/videos/' + parsedTorrent.infoHash, (err) => {
      if (err) console.error(err)
      fs.writeFile('public/videos/' + parsedTorrent.infoHash + '/' + parsedTorrent.infoHash + '.torrent', torrent)
      fs.rename('tmp/' + req.file.filename, 'public/videos/' + parsedTorrent.infoHash + '/' + parsedTorrent.infoHash + '.mp4', (err) => {
        if (err) console.error(err)
      })
    })
  })
})
github webtorrent / webtorrent / lib / torrent.js View on Github external
// So `webtorrent-hybrid` can force specific trackers to be used
      parsedTorrent.announce = parsedTorrent.announce.concat(global.WEBTORRENT_ANNOUNCE)
    }

    if (this.urlList) {
      // Allow specifying web seeds via `opts` parameter
      parsedTorrent.urlList = parsedTorrent.urlList.concat(this.urlList)
    }

    uniq(parsedTorrent.announce)
    uniq(parsedTorrent.urlList)

    Object.assign(this, parsedTorrent)

    this.magnetURI = parseTorrent.toMagnetURI(parsedTorrent)
    this.torrentFile = parseTorrent.toTorrentFile(parsedTorrent)
  }
github PearInc / PearDownloader.js / src / lib / torrent.js View on Github external
// So `webtorrent-hybrid` can force specific trackers to be used
    parsedTorrent.announce = parsedTorrent.announce.concat(global.WEBTORRENT_ANNOUNCE)
  }

  if (this.urlList) {
    // Allow specifying web seeds via `opts` parameter
    parsedTorrent.urlList = parsedTorrent.urlList.concat(this.urlList)
  }

  uniq(parsedTorrent.announce)
  uniq(parsedTorrent.urlList)

  extendMutable(this, parsedTorrent)

  this.magnetURI = parseTorrent.toMagnetURI(parsedTorrent)
  this.torrentFile = parseTorrent.toTorrentFile(parsedTorrent)
}
github binux / webtorrent-share / app.js View on Github external
app.get('/torrent/:infoHash', (req, res) => {
    var infoHash = req.params.infoHash
    if (database[infoHash] === undefined) {
      res.sendStatus(404)
      return
    }

    var torrent = database[infoHash].torrent
    torrent.urlList = [
      `${req.protocol}://${req.headers.host}/file/${infoHash}`
    ]
    var torrent_file = parseTorrent.toTorrentFile(torrent)

    res.cookie('torrent', infoHash, { httpOnly: true, signed: true })
    res.set('Content-Type', 'application/x-bittorrent')
    res.send(torrent_file)
  })
github binux / webtorrent-share / app.js View on Github external
function store_database() {
    var database_cache = {}
    for (let k in database) {
      database_cache[database[k].file] = parseTorrent.toTorrentFile(database[k].torrent)
    }
    fs.writeFileSync(path.resolve(os.tmpdir(), 'database.json'), JSON.stringify(database_cache))
  }
github sidd / serene / assets / actions / TorrentActions.js View on Github external
  torrents = torrents.map(torrent => parseTorrent.toTorrentFile(torrent))
  return (dispatch, getState) => {

parse-torrent

Parse a torrent identifier (magnet uri, .torrent file, info hash)

MIT
Latest version published 5 months ago

Package Health Score

69 / 100
Full package analysis