How to use the parse-torrent.remote 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 alanzhangzm / Photon / src / renderer / components / Main / NewTask.vue View on Github external
if (that.type === 'torrent' || that.type === 'metalink') {
          let reader = new FileReader()
          reader.onload = (e) => {
            that.file = e.target.result.replace(/^.*base64,/, '')
            that.filename = file.name
          }
          reader.onerror = (error) => {
            console.error(error.message)
            that.file = undefined
            that.filename = ''
            that.type = 'http'
          }
          reader.readAsDataURL(file)

          if (that.type === 'torrent') {
            parseTorrent.remote(file, (err, parsedTorrent) => {
              if (err) {
                that.filesInTorrent = []
                console.error(err)
              } else {
                that.filesInTorrent = parsedTorrent.files.map((file, index) => {
                  return {
                    // aria2's select-file uses starting index 1
                    index: index + 1,
                    name: file.name,
                    extension: file.name.includes('.') ? file.name.split('.').pop() : '',
                    size: file.length,
                    selected: true
                  }
                })
              }
            })
github dcposch / webtorrent-remote / server.js View on Github external
function handleAddTorrent (server, message) {
  var clientKey = message.clientKey
  var torrentKey = message.torrentKey

  // First, see if we've already joined this swarm
  parseTorrent.remote(message.torrentId, function (err, parsedTorrent) {
    if (err) {
      sendSubscribed(server, null, clientKey, torrentKey)
    } else {
      var infoHash = parsedTorrent.infoHash
      var torrent = server._torrents.find(function (t) {
        return t.infoHash === infoHash
      })

      // If not, add the torrent to the client
      if (!torrent) {
        debug('add torrent: ' + infoHash + ' ' + (parsedTorrent.name || ''))
        torrent = server.webtorrent().add(message.torrentId, message.opts)
        torrent.clients = []
        server._torrents.push(torrent)
        addTorrentEvents(server, torrent)
      }
github webtorrent / webtorrent / lib / torrent.js View on Github external
if (this.destroyed) return

    let parsedTorrent
    try { parsedTorrent = parseTorrent(torrentId) } catch (err) {}
    if (parsedTorrent) {
      // Attempt to set infoHash property synchronously
      this.infoHash = parsedTorrent.infoHash
      this._debugId = parsedTorrent.infoHash.toString('hex').substring(0, 7)
      process.nextTick(() => {
        if (this.destroyed) return
        this._onParsedTorrent(parsedTorrent)
      })
    } else {
      // If torrentId failed to parse, it could be in a form that requires an async
      // operation, i.e. http/https link, filesystem path, or Blob.
      parseTorrent.remote(torrentId, (err, parsedTorrent) => {
        if (this.destroyed) return
        if (err) return this._destroy(err)
        this._onParsedTorrent(parsedTorrent)
      })
    }
  }
github franciscofsales / node-macflix / src / bin / app.js View on Github external
const startTorrent = (magnetLink) => {
  clivas.line(`{green: starting download ...}`);
  parsetorrent.remote(magnetLink, (err, parsedtorrent) => {
    if (err) {
      console.error(err.message);
      process.exit(1);
    }
    ontorrent(parsedtorrent);
  });
}
github G-Ray / candyflix / app.js View on Github external
getport(function (err, port) {
      if (err) console.log(err);

      var process = {};
      var child = spawn('peerflix', [torrent, '--port='+ port, '--tmp=./tmp', '--remove'], {});
      process.child = child;
      process.port = port;
      process.spectators = 0;

      processes[torrent] = process;
      processes[torrent].spectators++;

      parseTorrent.remote(torrent, function (err, parsedTorrent) {
        if (err) throw err
        processes[torrent].name = parsedTorrent.name;
        printProcesses();
      })

      socket.playing = torrent;
      socket.emit('port', port);

      child.stdout.on('data', function(data) {
        //console.log('stdout: ' + data);
      });
      child.stderr.on('data', function(data) {
        console.log('stderr: ' + data);
      });
      child.on('close', function (code, signal) {
        console.log('child closed');
github simionrobert / BitInsight / BitInsight / src / lib / Services / MetadataResolver.js View on Github external
_downloadMetadataFromTracker(infohash) {
        parseTorrent.remote(this.torcacheURL + infohash + ".torrent", function (err, parsedTorrent) {
            if (err || typeof parsedTorrent === "undefined") {

            } else {
                if (this.semaphore!=0 && parsedTorrent.infoHash == this.currentInfohash) {
                    this._unregister();
                    var torrent = utils.parseMetadataTracker(parsedTorrent)
                    this.emit('metadata', torrent);
                }
            }
        }.bind(this))
    }
github Mrigank11 / embetacloud / server / server.js View on Github external
client.on('addTorrent', function (data) {
        var dupes = Object.keys(torrents).filter(function (key) {
            return magnet.decode(data.magnet).infoHash == torrents[key].infoHash;
        });
        if (dupes.length > 0) {
            return false;
        }
        var uniqid = shortid();
        parsetorrent.remote(data.magnet, function (err, parsedtorrent) {
            if (err) {
                debug("Failed to load magnet from torrent: " + err.message);
                client.emit("setObj", {
                    name: 'magnetLoading',
                    value: false
                });
                client.emit("alert", "Unable to load the .torrent");
                return;
            }
            addTorrent(parsedtorrent, uniqid, client);
        });
    });
    client.on('getDirStructure', function (data) {
github popcorn-official / popcorn-api / src / CLI.js View on Github external
return new Promise((resolve, reject) => {
      return parseTorrent.remote(link, (err, remote) => {
        if (err) {
          return reject(err)
        }

        const magnet = parseTorrent.toMagnetURI(remote)
        return webtorrentHealth(magnet).then(health => resolve(
          this[`_${type}Torrent`](magnet, health, remote)
        ))
      })
    })
  }

parse-torrent

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

MIT
Latest version published 4 months ago

Package Health Score

72 / 100
Full package analysis