Coder Social home page Coder Social logo

webtorrent / parse-torrent-file Goto Github PK

View Code? Open in Web Editor NEW
64.0 7.0 25.0 120 KB

DEPRECATED: Parse a .torrent file and return an object of keys/values

Home Page: https://webtorrent.io

License: MIT License

JavaScript 100.00%
torrent javascript bittorrent webtorrent nodejs browser parse

parse-torrent-file's Introduction

parse-torrent-file travis npm downloads javascript style guide

DEPRECATED: Use the parse-torrent package instead.

Parse a .torrent file and return an object of keys/values

Sauce Test Status

Works in node and the browser (with browserify). This module is used by WebTorrent!

install

npm install parse-torrent-file

usage

var parseTorrentFile = require('parse-torrent-file')
var path = require('path')

var torrent = fs.readFileSync(path.join(__dirname, 'torrents/leaves.torrent'))
var parsed
try {
  parsed = parseTorrentFile(torrent)
} catch (e) {
  // the torrent file was corrupt
  console.error(e)
}

console.log(parsed.name) // Prints "Leaves of Grass by Walt Whitman.epub"

The parsed torrent object looks like this:

{
  "infoHash": "d2474e86c95b19b8bcfdb92bc12c9d44667cfa36",
  "infoHashBuffer": ...,
  "name": "Leaves of Grass by Walt Whitman.epub",
  "private": false,
  "created": "2013-08-01T13:27:46.000Z",
  "announce": [
    "http://tracker.example.com/announce"
  ],
  "urlList": [],
  "files": [
    {
      "path": "Leaves of Grass by Walt Whitman.epub",
      "name": "Leaves of Grass by Walt Whitman.epub",
      "length": 362017,
      "offset": 0
    }
  ],
  "length": 362017,
  "pieceLength": 16384,
  "lastPieceLength": 1569,
  "pieces": [
    "1f9c3f59beec079715ec53324bde8569e4a0b4eb",
    "ec42307d4ce5557b5d3964c5ef55d354cf4a6ecc",
    "7bf1bcaf79d11fa5e0be06593c8faafc0c2ba2cf",
    "76d71c5b01526b23007f9e9929beafc5151e6511",
    "0931a1b44c21bf1e68b9138f90495e690dbc55f5",
    "72e4c2944cbacf26e6b3ae8a7229d88aafa05f61",
    "eaae6abf3f07cb6db9677cc6aded4dd3985e4586",
    "27567fa7639f065f71b18954304aca6366729e0b",
    "4773d77ae80caa96a524804dfe4b9bd3deaef999",
    "c9dd51027467519d5eb2561ae2cc01467de5f643",
    "0a60bcba24797692efa8770d23df0a830d91cb35",
    "b3407a88baa0590dc8c9aa6a120f274367dcd867",
    "e88e8338c572a06e3c801b29f519df532b3e76f6",
    "70cf6aee53107f3d39378483f69cf80fa568b1ea",
    "c53b506159e988d8bc16922d125d77d803d652c3",
    "ca3070c16eed9172ab506d20e522ea3f1ab674b3",
    "f923d76fe8f44ff32e372c3b376564c6fb5f0dbe",
    "52164f03629fd1322636babb2c014b7dae582da4",
    "1363965261e6ce12b43701f0a8c9ed1520a70eba",
    "004400a267765f6d3dd5c7beb5bd3c75f3df2a54",
    "560a61801147fa4ec7cf568e703acb04e5610a4d",
    "56dcc242d03293e9446cf5e457d8eb3d9588fd90",
    "c698de9b0dad92980906c026d8c1408fa08fe4ec"
  ]
}

To convert a parsed torrent back into a .torrent file buffer, call parseTorrentFile.encode.

var parseTorrentFile = require('parse-torrent-file')

// parse a torrent
var parsed = parseTorrentFile(/* some buffer */)

// convert parsed torrent back to a buffer
var buf = parseTorrentFile.encode(parsed)

credit

This was originally based on read-torrent by mafintosh. It's basically a pared-down version of that, but it works in the browser (so WebTorrent can use it), doesn't have huge npm dependencies like request (saving on file size), and it has tests. Thanks for publishing good modules, mafintosh!

license

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

parse-torrent-file's People

Contributors

astro avatar diegorbaquero avatar feross avatar greenkeeper[bot] avatar greenkeeperio-bot avatar olalonde avatar reklatsmasters avatar transitive-bullshit avatar ualtinok avatar yashikno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

parse-torrent-file's Issues

An in-range update of brfs is breaking the build 🚨

☝️ Greenkeeper’s updated Terms of Service will come into effect on April 6th, 2018.

Version 1.6.0 of brfs was just published.

Branch Build failing 🚨
Dependency brfs
Current Version 1.5.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

brfs is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 4 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of brfs is breaking the build 🚨

☝️ Greenkeeper’s updated Terms of Service will come into effect on April 6th, 2018.

Version 1.5.0 of brfs was just published.

Branch Build failing 🚨
Dependency brfs
Current Version 1.4.4
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

brfs is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v1.5.0

the brfs transform now generates source maps in --debug mode.

Commits

The new version differs by 4 commits.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because we are using your CI build statuses to figure out when to notify you about breaking changes.

Since we did not receive a CI status on the greenkeeper/initial branch, we assume that you still need to configure it.

If you have already set up a CI for this repository, you might need to check your configuration. Make sure it will run on all new branches. If you don’t want it to run on every branch, you can whitelist branches starting with greenkeeper/.

We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

Once you have installed CI on this repository, you’ll need to re-trigger Greenkeeper’s initial Pull Request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

An in-range update of tape is breaking the build 🚨

Version 4.9.0 of tape was just published.

Branch Build failing 🚨
Dependency tape
Current Version 4.8.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

tape is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 27 commits.

  • ea6d91e v4.9.0
  • 6867840 [Deps] update object-inspect, resolve
  • 4919e40 [Tests] on node v9; use nvm install-latest-npm
  • f26375c Merge pull request #420 from inadarei/global-depth-env-var
  • 17276d7 [New] use process.env.NODE_TAPE_OBJECT_PRINT_DEPTH for the default object print depth.
  • 0e870c6 Merge pull request #408 from johnhenry/feature/on-failure
  • 00aa133 Add "onFinish" listener to test harness.
  • 0e68b2d [Dev Deps] update js-yaml
  • 10b7dcd [Fix] fix stack where actual is falsy
  • 13173a5 Merge pull request #402 from nhamer/stack_strip
  • f90e487 normalize path separators in stacks
  • b66f8f8 [Deps] update function-bind
  • cc69501 Merge pull request #387 from fongandrew/master
  • bf5a750 Handle spaces in path name for setting file, line no
  • 3c2087a Test name with spaces

There are 27 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

An in-range update of standard is breaking the build 🚨

Version 11.0.0 of standard was just published.

Branch Build failing 🚨
Dependency standard
Current Version 10.0.3
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

standard is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 50 commits.

There are 50 commits in total.

See the full diff

FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.