Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
}
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();
function init () {
if (!WebTorrent.WEBRTC_SUPPORT) {
util.error('This browser is unsupported. Please use a browser with WebRTC support.')
}
// For performance, create the client immediately
getClient(function () {})
// Seed via upload input element
var upload = document.querySelector('input[name=upload]')
if (upload) {
uploadElement(upload, function (err, files) {
if (err) return util.error(err)
files = files.map(function (file) { return file.file })
onFiles(files)
})
}
peerPublicKey: peerPublicKey,
amount: incoming.destinationAmount
})
// Unchoke all of this peer's wires
for (let wire of this.peerWires[peerPublicKey]) {
wire.unchoke()
wire.bidAmount = wire.bidAmount.times(this.bidIncreaseFactor)
this._checkUnchokeWire(wire)
}
}
}
// Note that using module.exports instead of export const here is a hack
// to make this work with https://github.com/59naga/babel-plugin-add-module-exports
module.exports.WEBRTC_SUPPORT = WebTorrent.WEBRTC_SUPPORT
import React from 'react'
import WebTorrent from 'webtorrent/webtorrent.min'
import Auth from '../modules/Auth'
import { formatVideoTime, BytestoSize, uuidv8 } from '../modules/Library'
var torrentID = ''
var playlist = []
// Disable DHT
var client = new WebTorrent({
dht: false
})
// Announces list
// global.WEBTORRENT_ANNOUNCE = [
// 'ws://localhost:6969'
// ]
// Display webtorrent video
var displayVideo = (props) => {
// Show overlay
$('#video-components .fs-overlay').css({ 'visibility': 'visible', 'opacity': '1', 'width': '100vw', 'height': '100vh' })
$('#video-topbar .title').html(props.title)
// Reset loader
$('#video-loader .loader-inner').show()
// property on Windows, and `CFBundleShortVersionString` on Mac.
appVersion: pkg.version,
// Package the application's source code into an archive, using Electron's archive
// format. Mitigates issues around long path names on Windows and slightly speeds up
// require().
asar: {
// A glob expression, that unpacks the files with matching names to the
// "app.asar.unpacked" directory.
unpack: 'WebTorrent*'
},
// The build version of the application. Maps to the FileVersion metadata property on
// Windows, and CFBundleVersion on Mac. Note: Windows requires the build version to
// start with a number. We're using the version of the underlying WebTorrent library.
buildVersion: require('webtorrent/package.json').version,
// The application source directory.
dir: config.ROOT_PATH,
// Pattern which specifies which files to ignore when copying files to create the
// package(s).
ignore: /^\/src|^\/dist|\/(appveyor.yml|\.appveyor.yml|\.github|appdmg|AUTHORS|CONTRIBUTORS|bench|benchmark|benchmark\.js|bin|bower\.json|component\.json|coverage|doc|docs|docs\.mli|dragdrop\.min\.js|example|examples|example\.html|example\.js|externs|ipaddr\.min\.js|Makefile|min|minimist|perf|rusha|simplepeer\.min\.js|simplewebsocket\.min\.js|static\/screenshot\.png|test|tests|test\.js|tests\.js|webtorrent\.min\.js|\.[^/]*|.*\.md|.*\.markdown)$/,
// The application name.
name: config.APP_NAME,
// The base directory where the finished package(s) are created.
out: DIST_PATH,
// Replace an already existing output directory.
overwrite: true,
// property on Windows, and `CFBundleShortVersionString` on OS X.
'app-version': pkg.version,
// Package the application's source code into an archive, using Electron's archive
// format. Mitigates issues around long path names on Windows and slightly speeds up
// require().
asar: true,
// A glob expression, that unpacks the files with matching names to the
// "app.asar.unpacked" directory.
'asar-unpack': 'WebTorrent*',
// The build version of the application. Maps to the FileVersion metadata property on
// Windows, and CFBundleVersion on OS X. Note: Windows requires the build version to
// start with a number. We're using the version of the underlying WebTorrent library.
'build-version': require('webtorrent/package.json').version,
// The application source directory.
dir: config.ROOT_PATH,
// Pattern which specifies which files to ignore when copying files to create the
// package(s).
ignore: /^\/dist|\/(appveyor.yml|\.appveyor.yml|\.github|appdmg|AUTHORS|CONTRIBUTORS|bench|benchmark|benchmark\.js|bin|bower\.json|component\.json|coverage|doc|docs|docs\.mli|dragdrop\.min\.js|example|examples|example\.html|example\.js|externs|ipaddr\.min\.js|Makefile|min|minimist|perf|rusha|simplepeer\.min\.js|simplewebsocket\.min\.js|static\/screenshot\.png|test|tests|test\.js|tests\.js|webtorrent\.min\.js|\.[^\/]*|.*\.md|.*\.markdown)$/,
// The application name.
name: config.APP_NAME,
// The base directory where the finished package(s) are created.
out: DIST_PATH,
// Replace an already existing output directory.
overwrite: true,
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)
})
}
}
import WebTorrent from 'webtorrent/webtorrent.min';
const client = new WebTorrent();
client.on('error', err => console.error(err));
const torrents = {};
export const addTorrent = url => {
if (torrents[url]) {
return torrents[url];
}
torrents[url] = client.add(url);
return torrents[url];
};
export default client;
constructor(config) {
this._config = config || {};
this.torrents = [];
this._client = new WebTorrent();
this._client.on('error', (err) => {
console.log('[WebTorrent Error]', err)
});
}