npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

scrape-torrent-stats

v0.0.2

Published

Scrape information from the bittorrent trackers and the distributed hash table. Given a bittorrent magnet URI, scrapeTorrentStats can check both tracker and the DHT for downloads and peers.

Downloads

4

Readme

scrapeTorrentStats

Scrape information from the bittorrent trackers and the distributed hash table.

Given a bittorrent magnet URI, scrapeTorrentStats can check both tracker and the DHT for downloads and peers.

This project uses two great projects from the wizards that brought us WebTorrent. We use their DHT client bittorrent-dht, and their tracker client bittorrent-tracker.

This project uses native promises.

WARNING

By running this code you are connecting to users and systems that are sharing whatever file(s) you are requesting. For free legally distributed content this is not an issue. For copyrighted content, this code base does NOT download any portion of the requested files. This means this software only attempts to discover peers and does not in any way initiate or support downloading or uploading of any files. This does not mean you will not show up on another system for having connected to or requested information from a system holding the requested content.

Run this at your own risk.

Example Use

lets install the component

yarn add scrape-torrent-stats

We have 3 ways to interact with this library. The Discovery function allows access to both DHT and Tracker scrapes. The other two ways are functions used to specifically to get data from DHT or trackers: getDHTData and getTrackerData. For more information and examples see our examples folder.

This example is for scraping DHT sources for a torrent. The discover function takes two arguments, both are required!. The first is a magnet URI as a string. The second argument is a configuration object. The configuration object MUST include a source key. The source key can have one of three values: 'both', 'dht' or 'tracker'. The configuration object has an optional waitTime key that can be set how long to check for peers. You can also enable verbose console logging of the service by setting verbose key to true inside of the configuration object. By default verbose is set to false.

const { discover } = require('scrape-torrent-stats')

// ubuntu desktop magnet uri
const uri =
  'magnet:?xt=urn:btih:f07e0b0584745b7bcb35e98097488d34e68623d0&dn=ubuntu-17.10.1-desktop-amd64.iso'

const config = {
  source: 'dht',
  waitTime: 10000 // 10 second wait before closing peer search
}

discover(uri, config)
  .then(result => {
    console.log(result)
    // Structure of result object can be seen further down
     })
  .catch(err => {
    console.error(err)
  })

The result object returned above is structured as:

  {
    peersObj: {},
    fromsObj: {}
  }

The peersObj is an object full of peers. The keys for peersObj are a series of strings consisting of a peer's host:port. The value for the key is:

  {
    host: '69.197.183.44',
    port: 39639
  }

The fromsObj is an object full of peer sources. The keys for fromsObj are a series of strings consisting of a peer source's address:port. The value for the key is:

  {
    address: '163.172.57.150',
    family: 'IPv4',
    port: 6881,
    size: 339
  }

When using the Discover you can also enable verbose logging. For example:

const { discover } = require('scrape-torrent-stats')

// ubuntu desktop magnet uri
const uri =
  'magnet:?xt=urn:btih:f07e0b0584745b7bcb35e98097488d34e68623d0&dn=ubuntu-17.10.1-desktop-amd64.iso'

const config = {
  source: 'dht',
  waitTime: 10000, // 10 second wait before closing peer search
  verbose: true,
}

discover(uri, config)