New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bep9-metadata-dl

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bep9-metadata-dl

BEP-9 Metadata Downloader

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-71.43%
Maintainers
1
Weekly downloads
 
Created
Source

bep9-metadata-dl

Download the metadata from peers using infohash only

This module uses bittorrent-protocol, ut_metadata and torrent-discovery modules of WebTorrent to download the info-dictionary part of a .torrent file using infohash of magnet links only.

features

  • simple API
  • find peers from the DHT network
  • support callbacks and Promise

install

npm install bep9-metadata-dl

API

fetchMetadata(infohash, [opts], [callbackFn])

fetchMetadata.fromPeer(infohash, peerAddress, [opts], [callbackFn])

Example:

const fetchMetadata = require('bep9-metadata-dl');

// infohash of ubuntu-16.04.1-server-amd64.iso
const INFO_HASH = '90289fd34dfc1cf8f316a268add8354c85334458'; 

fetchMetadata(INFO_HASH, { maxConns: 10, fetchTimeout: 30000, socketTimeout: 5000 },
  (err, metadata) => {
  if (err) {
    console.log(err);
    return;
  }
  console.log(`[Callback] ${metadata.name.toString('utf-8')}`);
});

Or Promise based:

const fetchMetadata = require('bep9-metadata-dl');

// infohash of ubuntu-16.04.1-server-amd64.iso
const INFO_HASH = '90289fd34dfc1cf8f316a268add8354c85334458'; 

fetchMetadata(INFO_HASH, { maxConns: 10, fetchTimeout: 30000, socketTimeout: 5000 })
.then(metadata => {
  console.log(`[Promise] ${metadata.name.toString('utf-8')}`);
}).catch(err => {
  console.log(err);
});

Download directly from a peer:

const fetchMetadata = require('bep9-metadata-dl');

// infohash of ubuntu-16.04.1-server-amd64.iso
const INFO_HASH = '90289fd34dfc1cf8f316a268add8354c85334458'; 

fetchMetadata.fromPeer(INFO_HASH, '88.166.72.111:5', { timeout: 5000 }, 
  (err, metadata) => {
  if (err) {
    console.log(err);
    return;
  }
  console.log(`[Callback] ${metadata.name.toString('utf-8')}`);
});

Download directly from a peer, Promise based:

const fetchMetadata = require('bep9-metadata-dl');

// infohash of ubuntu-16.04.1-server-amd64.iso
const INFO_HASH = '90289fd34dfc1cf8f316a268add8354c85334458'; 

fetchMetadata.fromPeer(INFO_HASH, '88.166.72.111:5', { timeout: 5000 })
.then(metadata => {
  console.log(`[Promise] ${metadata.name.toString('utf-8')}`);
}).catch(err => {
  console.log(err);
});

License

MIT. Copyright (c) Hong Yan.

Keywords

FAQs

Package last updated on 05 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc