How to use the create-torrent.announceList function in create-torrent

To help you get started, we’ve selected a few create-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 webtorrent / webtorrent-desktop / src / renderer / webtorrent.js View on Github external
// To keep the UI snappy, we run WebTorrent in its own hidden window, a separate
// process from the main window.
console.time('init')

const crypto = require('crypto')
const deepEqual = require('deep-equal')
const defaultAnnounceList = require('create-torrent').announceList
const electron = require('electron')
const fs = require('fs')
const mkdirp = require('mkdirp')
const mm = require('music-metadata')
const networkAddress = require('network-address')
const path = require('path')
const WebTorrent = require('webtorrent')
const zeroFill = require('zero-fill')

const crashReporter = require('../crash-reporter')
const config = require('../config')
const { TorrentKeyNotFoundError } = require('./lib/errors')
const torrentPoster = require('./lib/torrent-poster')

// Report when the process crashes
crashReporter.init()
github webtorrent / webtorrent-desktop / client / index.js View on Github external
var createTorrent = require('create-torrent')
var debug = require('debug')('instant.io')
var dragDrop = require('drag-drop')
// var listify = require('listify')
var path = require('path')
var prettyBytes = require('pretty-bytes')
var throttle = require('throttleit')
var thunky = require('thunky')
var uploadElement = require('upload-element')
var WebTorrent = require('webtorrent')
var xhr = require('xhr')

var util = require('./util')

global.WEBTORRENT_ANNOUNCE = createTorrent.announceList
  .map(function (arr) {
    return arr[0]
  })
  .filter(function (url) {
    return url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0
  })

var getClient = thunky(function (cb) {
  getRtcConfig('https://instant.io/rtcConfig', function (err, rtcConfig) {
    if (err) util.error(err)
    createClient(rtcConfig)
  })

  function createClient (rtcConfig) {
    var client = window.client = new WebTorrent({ rtcConfig: rtcConfig })
    client.on('warning', util.warning)
github webtorrent / webtorrent-desktop / src / renderer / pages / create-torrent-page.js View on Github external
// Then, use the name of the base folder (or sole file, for a single file torrent)
    // as the default name. Show all files relative to the base folder.
    let defaultName, basePath
    if (files.length === 1) {
      // Single file torrent: /a/b/foo.jpg -> torrent name 'foo.jpg', path '/a/b'
      defaultName = files[0].name
      basePath = pathPrefix
    } else {
      // Multi file torrent: /a/b/{foo, bar}.jpg -> torrent name 'b', path '/a'
      defaultName = path.basename(pathPrefix)
      basePath = path.dirname(pathPrefix)
    }

    // Default trackers
    const trackers = createTorrent.announceList.join('\n')

    this.state = {
      comment: '',
      isPrivate: false,
      pathPrefix,
      basePath,
      defaultName,
      files,
      trackers
    }

    // Create React event handlers only once
    this.setIsPrivate = (_, isPrivate) => this.setState({ isPrivate })
    this.setComment = (_, comment) => this.setState({ comment })
    this.setTrackers = (_, trackers) => this.setState({ trackers })
    this.handleSubmit = handleSubmit.bind(this)
github webtorrent / webtorrent-desktop / renderer / views / create-torrent-page.js View on Github external
defaultName = files[0].name
    basePath = pathPrefix
  } else {
    // Multi file torrent: /a/b/{foo, bar}.jpg -> torrent name "b", path "/a"
    defaultName = path.basename(pathPrefix)
    basePath = path.dirname(pathPrefix)
  }
  var maxFileElems = 100
  var fileElems = files.slice(0, maxFileElems).map(function (file) {
    var relativePath = files.length === 0 ? file.name : path.relative(pathPrefix, file.path)
    return hx`<div>${relativePath}</div>`
  })
  if (files.length &gt; maxFileElems) {
    fileElems.push(hx`<div>+ ${maxFileElems - files.length} more</div>`)
  }
  var trackers = createTorrent.announceList.join('\n')
  var collapsedClass = info.showAdvanced ? 'expanded' : 'collapsed'

  return hx`
    <div class="create-torrent-page">
      <h2>Create torrent ${defaultName}</h2>
      <p class="torrent-info">
        ${torrentInfo}
      </p>
      <p class="torrent-attribute">
        <label>Path:</label>
        </p><div class="torrent-attribute">${pathPrefix}</div>
      <p></p>
      <div class="expand-collapse ${collapsedClass}">
        ${info.showAdvanced ? 'Basic' : 'Advanced'}
      </div>
      <div class="create-torrent-advanced ${collapsedClass}"></div></div>
github webtorrent / webtorrent-hybrid / lib / global.js View on Github external
const createTorrent = require('create-torrent')
const ElectronWebRTC = require('electron-webrtc')

global.WEBTORRENT_ANNOUNCE = createTorrent.announceList
  .map(arr => arr[0])
  .filter(url => url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0)

global.WRTC = () => {
  const wrtc = ElectronWebRTC()

  const ensureCloseElectron = () => {
    process.removeListener('SIGINT', ensureCloseElectron)
    process.removeListener('SIGTERM', ensureCloseElectron)
    wrtc.close()
  }

  process.on('SIGINT', ensureCloseElectron)
  process.on('SIGTERM', ensureCloseElectron)

  wrtc.on('error', (err, source) => {
github webtorrent / webtorrent-desktop / background / index.js View on Github external
var createTorrent = require('create-torrent')
var electron = require('electron')
var path = require('path')
var prettyBytes = require('pretty-bytes')
var throttle = require('throttleit')
var thunky = require('thunky')
var torrentPoster = require('./torrent-poster')
var WebTorrent = require('webtorrent')
var xhr = require('xhr')

var ipc = electron.ipcRenderer

global.WEBTORRENT_ANNOUNCE = createTorrent.announceList
  .map(function (arr) {
    return arr[0]
  })
  .filter(function (url) {
    return url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0
  })

var getClient = thunky(function (cb) {
  getRtcConfig('https://instant.io/rtcConfig', function (err, rtcConfig) {
    if (err) onError(err)
    var client = window.client = new WebTorrent({
      rtcConfig: rtcConfig
    })
    client.on('warning', onWarning)
    client.on('error', onError)
    cb(null, client)
github webtorrent / instant.io / client / index.js View on Github external
var createTorrent = require('create-torrent')
var debug = require('debug')('instant.io')
var dragDrop = require('drag-drop')
var get = require('simple-get')
var formatDistance = require('date-fns/formatDistance')
var path = require('path')
var prettierBytes = require('prettier-bytes')
var throttle = require('throttleit')
var thunky = require('thunky')
var uploadElement = require('upload-element')
var WebTorrent = require('webtorrent')
var JSZip = require('jszip')

var util = require('./util')

global.WEBTORRENT_ANNOUNCE = createTorrent.announceList
  .map(function (arr) {
    return arr[0]
  })
  .filter(function (url) {
    return url.indexOf('wss://') === 0 || url.indexOf('ws://') === 0
  })

var DISALLOWED = [
  '6feb54706f41f459f819c0ae5b560a21ebfead8f'
]

var getClient = thunky(function (cb) {
  getRtcConfig(function (err, rtcConfig) {
    if (err) util.error(err)
    var client = new WebTorrent({
      tracker: {

create-torrent

Create .torrent files

MIT
Latest version published 6 months ago

Package Health Score

73 / 100
Full package analysis