All Projects → webtorrent → Magnet Uri

webtorrent / Magnet Uri

Licence: mit
Parse a magnet URI and return an object of keys/values

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Magnet Uri

Parse Torrent
Parse a torrent identifier (magnet uri, .torrent file, info hash)
Stars: ✭ 325 (+77.6%)
Mutual labels:  parse, torrent, bittorrent, webtorrent, browser
Torrent Discovery
Discover BitTorrent and WebTorrent peers
Stars: ✭ 177 (-3.28%)
Mutual labels:  torrent, bittorrent, webtorrent, browser
Webtorrent
⚡️ Streaming torrent client for the web
Stars: ✭ 25,554 (+13863.93%)
Mutual labels:  torrent, bittorrent, webtorrent, browser
Create Torrent
Create .torrent files
Stars: ✭ 264 (+44.26%)
Mutual labels:  torrent, bittorrent, webtorrent, browser
Bittorrent Tracker
🌊 Simple, robust, BitTorrent tracker (client & server) implementation
Stars: ✭ 1,184 (+546.99%)
Mutual labels:  torrent, bittorrent, webtorrent, browser
parse-torrent-file
DEPRECATED: Parse a .torrent file and return an object of keys/values
Stars: ✭ 62 (-66.12%)
Mutual labels:  torrent, parse, bittorrent, webtorrent
Bittorrent Protocol
Simple, robust, BitTorrent peer wire protocol implementation
Stars: ✭ 279 (+52.46%)
Mutual labels:  torrent, bittorrent, webtorrent, browser
Webtorrent Hybrid
WebTorrent (with WebRTC support in Node.js)
Stars: ✭ 422 (+130.6%)
Mutual labels:  torrent, bittorrent, webtorrent, browser
torrent-spider
基于DHT的p2p网络资源爬虫
Stars: ✭ 65 (-64.48%)
Mutual labels:  torrent, bittorrent, magnet-link
Diffy
🎞️💓🍿 Love streaming - It's always best to watch a movie together ! 🤗
Stars: ✭ 37 (-79.78%)
Mutual labels:  torrent, bittorrent, webtorrent
CheckWebPeer
Check WebRTC peers of torrents.
Stars: ✭ 19 (-89.62%)
Mutual labels:  torrent, bittorrent, webtorrent
Torrent
Full-featured BitTorrent client package and utilities
Stars: ✭ 4,138 (+2161.2%)
Mutual labels:  torrent, bittorrent, magnet-link
Bittorrent Dht
🕸 Simple, robust, BitTorrent DHT implementation
Stars: ✭ 1,004 (+448.63%)
Mutual labels:  torrent, bittorrent, webtorrent
Wt Tracker
High-performance WebTorrent tracker
Stars: ✭ 144 (-21.31%)
Mutual labels:  torrent, bittorrent, webtorrent
Aria2.sh
Aria2 一键安装管理脚本 增强版
Stars: ✭ 1,276 (+597.27%)
Mutual labels:  torrent, bittorrent, magnet-link
Torrentpier
Main project repository
Stars: ✭ 166 (-9.29%)
Mutual labels:  torrent, bittorrent, webtorrent
torrent-hound
Search torrents from multiple websites via the CLI
Stars: ✭ 28 (-84.7%)
Mutual labels:  torrent, bittorrent, magnet-link
ut pex
Implementation of ut_pex bittorrent protocol (PEX) for webtorrent
Stars: ✭ 54 (-70.49%)
Mutual labels:  torrent, bittorrent, webtorrent
Bittorrent Peerid
Map a BitTorrent peer ID to a human-readable client name and version
Stars: ✭ 47 (-74.32%)
Mutual labels:  torrent, bittorrent, webtorrent
Ut metadata
BitTorrent Extension for Peers to Send Metadata Files (BEP 9)
Stars: ✭ 98 (-46.45%)
Mutual labels:  bittorrent, webtorrent, browser

magnet-uri travis npm downloads javascript style guide

Parse a magnet URI and return an object of keys/values.

Also works in the browser with browserify! This module is used by WebTorrent.

install

npm install magnet-uri

usage

decode

Parse a magnet URI and return an object of keys/values.

const magnet = require('magnet-uri')

// "Leaves of Grass" by Walt Whitman
const uri = 'magnet:?xt=urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36&dn=Leaves+of+Grass+by+Walt+Whitman.epub&tr=udp%3A%2F%2Ftracker.example4.com%3A80&tr=udp%3A%2F%2Ftracker.example5.com%3A80&tr=udp%3A%2F%2Ftracker.example3.com%3A6969&tr=udp%3A%2F%2Ftracker.example2.com%3A80&tr=udp%3A%2F%2Ftracker.example1.com%3A1337'

const parsed = magnet.decode(uri)
console.log(parsed.dn) // "Leaves of Grass by Walt Whitman.epub"
console.log(parsed.infoHash) // "d2474e86c95b19b8bcfdb92bc12c9d44667cfa36"

The parsed magnet link object looks like this:

  {
    "xt": "urn:btih:d2474e86c95b19b8bcfdb92bc12c9d44667cfa36",
    "dn": "Leaves of Grass by Walt Whitman.epub",
    "tr": [
      "udp://tracker.example1.com:1337",
      "udp://tracker.example2.com:80",
      "udp://tracker.example3.com:6969",
      "udp://tracker.example4.com:80",
      "udp://tracker.example5.com:80"
    ],

    // added for convenience:
    "infoHash": "d2474e86c95b19b8bcfdb92bc12c9d44667cfa36",
    "infoHashBuffer": ...,
    "name": "Leaves of Grass by Walt Whitman.epub",
    "announce": [
      "udp://tracker.example1.com:1337",
      "udp://tracker.example2.com:80",
      "udp://tracker.example3.com:6969",
      "udp://tracker.example4.com:80",
      "udp://tracker.example5.com:80"
    ]
  }

encode

Convert an object of key/values into a magnet URI string.

const magnet = require('magnet-uri')

const uri = magnet.encode({
  xt: [
    'urn:ed2k:354B15E68FB8F36D7CD88FF94116CDC1',
    'urn:tree:tiger:7N5OAMRNGMSSEUE3ORHOKWN4WWIQ5X4EBOOTLJY',
    'urn:btih:QHQXPYWMACKDWKP47RRVIV7VOURXFE5Q'
  ],
  xl: '10826029',
  dn: 'mediawiki-1.15.1.tar.gz',
  tr: [
    'udp://tracker.openbittorrent.com:80/announce'
  ],
  as: 'http://download.wikimedia.org/mediawiki/1.15/mediawiki-1.15.1.tar.gz',
  xs: [
    'http://cache.example.org/XRX2PEFXOOEJFRVUCX6HMZMKS5TWG4K5',
    'dchub://example.org'
  ]
})

console.log(uri) // the magnet uri

The returned magnet uri will be:

magnet:?xt=urn:ed2k:354B15E68FB8F36D7CD88FF94116CDC1&xt=urn:tree:tiger:7N5OAMRNGMSSEUE3ORHOKWN4WWIQ5X4EBOOTLJY&xt=urn:btih:QHQXPYWMACKDWKP47RRVIV7VOURXFE5Q&xl=10826029&dn=mediawiki-1.15.1.tar.gz&tr=udp%3A%2F%2Ftracker.openbittorrent.com%3A80%2Fannounce&as=http%3A%2F%2Fdownload.wikimedia.org%2Fmediawiki%2F1.15%2Fmediawiki-1.15.1.tar.gz&xs=http%3A%2F%2Fcache.example.org%2FXRX2PEFXOOEJFRVUCX6HMZMKS5TWG4K5&xs=dchub%3A%2F%2Fexample.org

You can also use convenience key names like name (dn), infoHash (xt), infoHashBuffer (xt), publicKey (xs), publicKeyBuffer (xs), announce (tr), and keywords (kt).

license

MIT. Copyright (c) Feross Aboukhadijeh and WebTorrent, LLC.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].