How to use the webtorrent function in webtorrent

To help you get started, we’ve selected a few webtorrent 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 MovieCast / desktop / src / main / TorrentEngine.js View on Github external
constructor(store) {
    // The Redux store
    this.store = store;

    // Connect to the WebTorrent and BitTorrent networks.
    // MovieCast is just like WebTorrent Desktop a hybrid
    // client, as explained here: https://webtorrent.io/faq
    this.client = new WebTorrent({ peerId: TorrentEngine.PEER_ID });

    // WebTorrent-to-HTTP streaming sever
    this.server = null;

    // Connect the store with the client
    this.connectClientEventsToStore();

    // setInterval(this.updateTorrentProgress.bind(this), 1000);
  }
github willyb321 / media_mate / app / renderjs / downloader.js View on Github external
import {createDB} from '../lib/utils';
import {RSSParse} from '../lib/rssparse.js';

require('dotenv').config({
	path: `${__dirname}/.env`
});
require('events').EventEmitter.prototype._maxListeners = 1000;

const rssTor = [];
let dupeCount = 0;
const version = remote.app.getVersion();
Raven.config('https://3d1b1821b4c84725a3968fcb79f49ea1@sentry.io/184666', {
	release: version,
	autoBreadcrumbs: true
}).install();
const client = new WebTorrent();
let i = 0;
let bar;
let db;
createDB(path.join(remote.app.getPath('userData'), 'dbTor.db').toString())
	.then(dbCreated => {
		db = dbCreated;
	});

const allTorrents = [];
const prog = _.throttle(dlProgress, 4500);
const updateDlProg = _.throttle(updateProgress, 2000);

process.on('unhandledRejection', (err, promise) => {
	log.error('Unhandled rejection: ' + (err && err.stack || err)); // eslint-disable-line
	Raven.captureException(err);
	Raven.showReportDialog();
github NyaaPantsu / Cinnamon / src / renderer / components / TorrentList.vue View on Github external
stream: function (magnetURI) {
      this.loading = true
      console.log('instructed to stream', magnetURI)
      let wt = new WebTorrent()
      let self = this
      wt.add(magnetURI, function (torrent) {
        self.videoServer = torrent.createServer()
        self.videoServer.listen(0)
        console.log('video server listening on http://localhost:' + self.videoServer.address().port)
        let file = torrent.files.find(function (file) {
          return file.name.endsWith('.mp4') || file.name.endsWith('.mkv') || file.name.endsWith('.avi')
        })
        self.$store.commit('setFilePath', file.path)
        self.mpv.loadStream('http://localhost' + ':' + self.videoServer.address().port + '/0/' + self.filePath)
      })
    }
  }
github ewnd9 / media-center / src / services / torrents-service.js View on Github external
function TorrentsService(config, models) {
  if (!(this instanceof TorrentsService)) {
    return new TorrentsService(config, models);
  }

  this.engine = new WebTorrent({ maxConns: 20 });
  this.mediaPath = config.mediaPath;
  this.torrentPort = config.torrentPort;

  this.server = null;
  this.activeTorrent = null;
}
github willyb321 / media_mate / app / renderjs / streamer.js View on Github external
import swal from 'sweetalert2';
import path from 'path';
import _ from 'underscore';
import Raven from 'raven-js';
import {createDB, isPlayable, titleCase} from '../lib/utils.js';
import {remote} from 'electron';

require('dotenv').config();
require('events').EventEmitter.prototype._maxListeners = 1000;

const version = remote.app.getVersion();
Raven.config('https://3d1b1821b4c84725a3968fcb79f49ea1@sentry.io/184666', {
	release: version,
	autoBreadcrumbs: true
}).install();
const client = new WebTorrent();
let filesAll;
let db;
let server;
createDB(path.join(require('electron').remote.app.getPath('userData'), 'dbStream.db').toString())
	.then(dbCreated => {
		db = dbCreated;
	});

client.on('error', err => {
	Raven.captureException(err);
	Raven.showReportDialog();
});

/**
 * On keypress on the input
 * @param e {object} - the event
github MovieCast / desktop / src / main / streamer.js View on Github external
getInstance() {
    if (this.client === null) {
      const announce = announceList
        .map((arr) => arr[0])
        .filter((url) => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0);

      this.client = new WebTorrent({
        peerId: Streamer.PEER_ID,
        tracker: { announce }
      });
    }
    return this.client;
  }
}
github SomeoneWeird / aergia / app / containers / ctrtransfer / setup / index.js View on Github external
import config from '../../../config'

import section from '../../cssModules/section.scss'
import content from '../../cssModules/content.scss'

import styles from './index.css'

const magnetLinks = {
  eur: 'magnet:?xt=urn:btih:89acc9c1b488b8b38251de0ddf07975d6bd354a1&dn=2.1.0-4E%5Fctrtransfer%5Fo3ds.zip&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=http%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fzer0day.ch%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=http%3A%2F%2Fexplodie.org%3A6969%2Fannounce&tr=udp%3A%2F%2Fexplodie.org%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2710%2Fannounce&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=http%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.aletorrenty.pl%3A2710%2Fannounce&tr=http%3A%2F%2Ftracker.aletorrenty.pl%3A2710%2Fannounce&tr=http%3A%2F%2Ftracker1.wasabii.com.tw%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.baravik.org%3A6970%2Fannounce&tr=http%3A%2F%2Ftracker.tfile.me%2Fannounce&tr=udp%3A%2F%2Ftorrent.gresille.org%3A80%2Fannounce&tr=http%3A%2F%2Ftorrent.gresille.org%2Fannounce&tr=udp%3A%2F%2Ftracker.yoshi210.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.tiny-vps.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.filetracker.pl%3A8089%2Fannounce',
  jpn: 'magnet:?xt=urn:btih:3dbb9c9c85a33c6242f424dcbaebcacdd8a5912b&dn=2.1.0-4J%5Fctrtransfer%5Fo3ds.zip&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=http%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fzer0day.ch%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=http%3A%2F%2Fexplodie.org%3A6969%2Fannounce&tr=udp%3A%2F%2Fexplodie.org%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2710%2Fannounce&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=http%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.aletorrenty.pl%3A2710%2Fannounce&tr=http%3A%2F%2Ftracker.aletorrenty.pl%3A2710%2Fannounce&tr=http%3A%2F%2Ftracker1.wasabii.com.tw%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.baravik.org%3A6970%2Fannounce&tr=http%3A%2F%2Ftracker.tfile.me%2Fannounce&tr=udp%3A%2F%2Ftorrent.gresille.org%3A80%2Fannounce&tr=http%3A%2F%2Ftorrent.gresille.org%2Fannounce&tr=udp%3A%2F%2Ftracker.yoshi210.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.tiny-vps.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.filetracker.pl%3A8089%2Fannounce',
  usa: 'magnet:?xt=urn:btih:1609ce9ee7b0ed9b6dea0b3e7cca4fc52dad6ff4&dn=2.1.0-4U%5Fctrtransfer%5Fo3ds.zip&tr=udp%3A%2F%2Ftracker.coppersurfer.tk%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=http%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fzer0day.ch%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.leechers-paradise.org%3A6969%2Fannounce&tr=http%3A%2F%2Fexplodie.org%3A6969%2Fannounce&tr=udp%3A%2F%2Fexplodie.org%3A6969%2Fannounce&tr=udp%3A%2F%2F9.rarbg.com%3A2710%2Fannounce&tr=udp%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=http%3A%2F%2Fp4p.arenabg.com%3A1337%2Fannounce&tr=udp%3A%2F%2Ftracker.aletorrenty.pl%3A2710%2Fannounce&tr=http%3A%2F%2Ftracker.aletorrenty.pl%3A2710%2Fannounce&tr=http%3A%2F%2Ftracker1.wasabii.com.tw%3A6969%2Fannounce&tr=http%3A%2F%2Ftracker.baravik.org%3A6970%2Fannounce&tr=http%3A%2F%2Ftracker.tfile.me%2Fannounce&tr=udp%3A%2F%2Ftorrent.gresille.org%3A80%2Fannounce&tr=http%3A%2F%2Ftorrent.gresille.org%2Fannounce&tr=udp%3A%2F%2Ftracker.yoshi210.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.tiny-vps.com%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.filetracker.pl%3A8089%2Fannounce'
}

const zipName = '2.1.0-4U_ctrtransfer_o3ds.zip'

const torrentClient = new Webtorrent()

let CTRTransfer = React.createClass({
  getInitialState () {
    return {
      extracting: false,
      downloading: null,
      progress: 0,
      finished: false
    }
  },
  componentDidMount () {
    this.setState({
      ...this.state,
      downloading: `CTR Transfer File (${config.region})`
    }, () => {
      this.downloadCTRfile()
github Lunik / tcloud / src / server / model / module / torrentWorker.js View on Github external
constructor (magnet) {
    this.magnet = magnet
    this.client = new WebTorrent({
      tracker: {
        getAnnounceOpts: () => {
          return {
            downloaded: 0
          }
        }
      }
    })

    this.log = new Delogger(`Peer(${process.pid})`)

    process.on('message', (message) => this.handleMessage(JSON.parse(message)))
  }