{"analyzedAt":"2022-07-08T17:22:29.054Z","collected":{"metadata":{"name":"locate-torrent-data","scope":"unscoped","version":"0.2.3","description":"Find the location of files that match the contents of a torrent file.","keywords":["bittorrent",".torrent","torrent","file","index","locate","search"],"date":"2016-12-08T10:48:28.662Z","author":{"name":"vonthar","email":"vonthar@tfwno.gf"},"publisher":{"username":"vonthar","email":"vonthar@tfwno.gf"},"maintainers":[{"username":"vonthar","email":"vonthar@hotmail.com"}],"repository":{"type":"git","url":"git+https://github.com/vonthar/node-locate-torrent-data.git"},"links":{"npm":"https://www.npmjs.com/package/locate-torrent-data","homepage":"https://github.com/vonthar/node-locate-torrent-data","repository":"https://github.com/vonthar/node-locate-torrent-data","bugs":"https://github.com/vonthar/node-locate-torrent-data/issues"},"license":"MPL-2.0","dependencies":{"async":"^2.0.0-rc.4","cartesian":"^1.0.0","isstream":"^0.1.2","parse-torrent-file":"^4.0.0","private":"^0.1.6","simple-sha1":"^2.0.8","walkdir":"0.0.11"},"devDependencies":{"@vonthar/pkgdev":"git+https://github.com/vonthar/pkgdev.git","coveralls":"^2.11.12","create-torrent":"^3.25.1","eslint":"^2.13.1","eslint-config-xo":"^0.15.3","fs-extra":"^1.0.0","nyc":"^8.1.0","random-string":"^0.1.2","tape":"^4.6.0"},"releases":[{"from":"2022-06-08T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":1},{"from":"2022-04-09T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":1},{"from":"2022-01-09T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":1},{"from":"2021-07-08T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":1},{"from":"2020-07-08T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":1}],"hasTestScript":true,"readme":"node-locate-torrent-data\n==========================================================================================\n[![NPM Package](https://img.shields.io/npm/v/locate-torrent-data.svg)](https://www.npmjs.org/package/locate-torrent-data)\n[![Build Status](https://travis-ci.org/vonthar/node-locate-torrent-data.svg?branch=master)](https://travis-ci.org/vonthar/node-locate-torrent-data/branches)\n[![Coverage Status](https://coveralls.io/repos/github/vonthar/node-locate-torrent-data/badge.svg?branch=master)](https://coveralls.io/github/vonthar/node-locate-torrent-data?branch=master)\n[![Dependency Status](https://david-dm.org/vonthar/node-locate-torrent-data.svg)](https://david-dm.org/vonthar/node-locate-torrent-data)\n\n**Example**  \n```js\nvar locateTorrentData = require(\"locate-torrent-data\");\nvar fileIndex = locateTorrentData.index(\"D:\\\\Files\");\nvar torrentPath = \"C:\\\\Torrents\\\\memes.torrent\";\nfileIndex.search(torrentPath, function (error, files) {\n  var found = files.reduce(function (count, file) {\n    if (file.location) {\n      return count + 1;\n    }\n    return count;\n  }, 0);\n  console.log(\"Files found: \" + found + \" / \" + files.length);\n});\n```\n \nInstallation\n------------\n`npm i locate-torrent-data`\n\n\nAPI Reference\n-------------\n\n* [locate-torrent-data](#module_locate-torrent-data)\n    * [.index(path, [options], [callback])](#module_locate-torrent-data.index) ⇒ <code>[FileIndex](#FileIndex)</code>\n    * [.load(source, [callback])](#module_locate-torrent-data.load) ⇒ <code>[FileIndex](#FileIndex)</code>\n\n<a name=\"module_locate-torrent-data.index\"></a>\n\n### locate-torrent-data.index(path, [options], [callback]) ⇒ <code>[FileIndex](#FileIndex)</code>\nCreate a searchable file index from the contents of specified folder(s).\n\n**Kind**: static method of <code>[locate-torrent-data](#module_locate-torrent-data)</code>  \n**Emits**: <code>[error](#FileIndex+event_error)</code>, <code>[update](#FileIndex+event_update)</code>  \n**Params**\n\n- path <code>string</code> | <code>Array.&lt;string&gt;</code>\n- [options] <code>Object</code>\n    - [.maxdepth] <code>number</code>\n    - [.dereference] <code>boolean</code>\n- [callback] <code>function</code>\n    - .error <code>Error</code>\n\n**Example**  \n```js\nvar fileIndex = locateTorrentData.index(\"D:\\\\Files\");\n```\n \n<a name=\"module_locate-torrent-data.load\"></a>\n\n### locate-torrent-data.load(source, [callback]) ⇒ <code>[FileIndex](#FileIndex)</code>\nImport a file index from disk or read from specified stream.\n\n**Kind**: static method of <code>[locate-torrent-data](#module_locate-torrent-data)</code>  \n**Emits**: <code>[error](#FileIndex+event_error)</code>, <code>[update](#FileIndex+event_update)</code>  \n**See**: [save](#FileIndex+save)  \n**Params**\n\n- source <code>string</code> | <code>Readable</code>\n- [callback] <code>function</code>\n    - .error <code>Error</code>\n\n**Example**  \n```js\nvar fileIndex = locateTorrentData.load(\"~/fileindex.csv\");\n```\n<a name=\"FileIndex\"></a>\n\n## FileIndex\n**Kind**: global class  \n\n* [FileIndex](#FileIndex)\n    * [.search(torrent, [forEach], [callback])](#FileIndex+search) ↩︎\n    * [.on(event, callback)](#FileIndex+on) ↩︎\n    * [.add(path, [options], [callback])](#FileIndex+add) ↩︎\n    * [.remove(path, [callback])](#FileIndex+remove) ↩︎\n    * [.save(destination, [callback])](#FileIndex+save) ↩︎\n    * [\"error\" (error)](#FileIndex+event_error)\n    * [\"match\" (file, torrent)](#FileIndex+event_match)\n    * [\"notFound\" (file, torrent)](#FileIndex+event_notFound)\n    * [\"end\" (files, torrent)](#FileIndex+event_end)\n    * [\"update\"](#FileIndex+event_update)\n\n<a name=\"FileIndex+search\"></a>\n\n### fileIndex.search(torrent, [forEach], [callback]) ↩︎\nSearch file index for files that match the contents of specified torrent.\n\n**Kind**: instance method of <code>[FileIndex](#FileIndex)</code>  \n**Chainable**  \n**Emits**: <code>[error](#FileIndex+event_error)</code>, <code>[match](#FileIndex+event_match)</code>, <code>[notFound](#FileIndex+event_notFound)</code>, <code>[end](#FileIndex+event_end)</code>, <code>[update](#FileIndex+event_update)</code>  \n**Params**\n\n- torrent <code>string</code> | <code>[ParsedTorrent](https://www.npmjs.com/package/parse-torrent-file)</code>\n- [forEach] <code>function</code>\n    - .file <code>[TorrentFile](#TorrentFile)</code>\n    - .callback <code>function</code>\n- [callback] <code>function</code>\n    - .error <code>Error</code>\n    - .files <code>[Array.&lt;TorrentFile&gt;](#TorrentFile)</code>\n\n**Example**  \n```js\nvar torrentPath = \"C:\\\\Torrents\\\\memes.torrent\";\nvar savePath = \"D:\\\\Seeding\";\nvar torrent = parseTorrentFile(fs.readFileSync(torrentPath));\nfileIndex.search(torrent, function (file, callback) {\n  var dest = path.join(savePath, torrent.name, file.path);\n  fs.rename(file.location, dest, callback);\n}, function (error, files) {\n  if (error) {\n    console.error(error);\n    return;\n  }\n  fs.unlinkSync(torrentPath);\n});\n```\n \n<a name=\"FileIndex+on\"></a>\n\n### fileIndex.on(event, callback) ↩︎\nAdd event listener.\n\n**Kind**: instance method of <code>[FileIndex](#FileIndex)</code>  \n**Chainable**  \n**Params**\n\n- event <code>string</code>\n- callback <code>function</code>\n\n**Example**  \n```js\nfileIndex\n  .on(\"error\", function (error) {\n    console.error(error);\n  })\n  .on(\"match\", function (file, torrent) {\n    var dest = path.join(\"D:\\\\Seeding\", torrent.name, file.path);\n    fs.rename(file.location, dest, function () {\n      console.log(\"File located and moved: \" + file.name);\n    });\n  })\n  .on(\"notFound\", function (file, torrent) {\n    console.log(\"File not found: \" + file.name);\n  })\n  .on(\"end\", function (files, torrent) {\n    var found = files.reduce(function (count, file) {\n      if (file.location) {\n        return count + 1;\n      }\n      return count;\n    }, 0);\n    console.log(\"Files found: \" + found + \" / \" + files.length);\n  })\n  .on(\"update\", function () {\n    console.log(\"File index updated.\");\n  });\nvar torrentPath = \"C:\\\\Torrents\";\nfs.readdirSync(torrentPath).forEach(function (file) {\n  if (file.endsWith(\".torrent\")) {\n    fileIndex.search(path.join(torrentPath, file));\n  }\n});\n```\n \n<a name=\"FileIndex+add\"></a>\n\n### fileIndex.add(path, [options], [callback]) ↩︎\nAdd contents of specified folder(s) to the file index.\n\n**Kind**: instance method of <code>[FileIndex](#FileIndex)</code>  \n**Chainable**  \n**Emits**: <code>[error](#FileIndex+event_error)</code>, <code>[update](#FileIndex+event_update)</code>  \n**Params**\n\n- path <code>string</code> | <code>Array.&lt;string&gt;</code>\n- [options] <code>Object</code>\n    - [.maxdepth] <code>number</code>\n    - [.dereference] <code>boolean</code>\n- [callback] <code>function</code>\n    - .error <code>Error</code>\n\n**Example**  \n```js\nvar fileIndex = locateTorrentData.index(\"D:\\\\Files\");\nfileIndex.add(\"D:\\\\Files2\");\n```\n \n<a name=\"FileIndex+remove\"></a>\n\n### fileIndex.remove(path, [callback]) ↩︎\nRemove contents of specified folder(s) from the file index.\n\n**Kind**: instance method of <code>[FileIndex](#FileIndex)</code>  \n**Chainable**  \n**Emits**: <code>[update](#FileIndex+event_update)</code>  \n**Params**\n\n- path <code>string</code> | <code>Array.&lt;string&gt;</code>\n- [callback] <code>function</code>\n\n**Example**  \n```js\nvar fileIndex = locateTorrentData.index(\"D:\\\\Files\");\nfileIndex.remove(\"D:\\\\Files\\\\Secret Files\");\n```\n \n<a name=\"FileIndex+save\"></a>\n\n### fileIndex.save(destination, [callback]) ↩︎\nExport file index as csv file to disk at specified path or write to specified stream.\n\n**Kind**: instance method of <code>[FileIndex](#FileIndex)</code>  \n**Chainable**  \n**Emits**: <code>[error](#FileIndex+event_error)</code>  \n**See**: [load](#module_locate-torrent-data.load)  \n**Params**\n\n- destination <code>string</code> | <code>Writable</code>\n- [callback] <code>function</code>\n    - .error <code>Error</code>\n\n**Example**  \n```js\nfileIndex.save(\"~/fileindex.csv\");\n```\n<a name=\"FileIndex+event_error\"></a>\n\n### \"error\" (error)\n**Kind**: event emitted by <code>[FileIndex](#FileIndex)</code>  \n**See**: [on](#FileIndex+on)  \n**Params**\n\n- error <code>Error</code>\n\n<a name=\"FileIndex+event_match\"></a>\n\n### \"match\" (file, torrent)\n**Kind**: event emitted by <code>[FileIndex](#FileIndex)</code>  \n**See**: [on](#FileIndex+on)  \n**Params**\n\n- file <code>[TorrentFile](#TorrentFile)</code>\n- torrent <code>[ParsedTorrent](https://www.npmjs.com/package/parse-torrent-file)</code>\n\n<a name=\"FileIndex+event_notFound\"></a>\n\n### \"notFound\" (file, torrent)\n**Kind**: event emitted by <code>[FileIndex](#FileIndex)</code>  \n**See**: [on](#FileIndex+on)  \n**Params**\n\n- file <code>[TorrentFile](#TorrentFile)</code>\n- torrent <code>[ParsedTorrent](https://www.npmjs.com/package/parse-torrent-file)</code>\n\n<a name=\"FileIndex+event_end\"></a>\n\n### \"end\" (files, torrent)\n**Kind**: event emitted by <code>[FileIndex](#FileIndex)</code>  \n**See**: [on](#FileIndex+on)  \n**Params**\n\n- files <code>[Array.&lt;TorrentFile&gt;](#TorrentFile)</code>\n- torrent <code>[ParsedTorrent](https://www.npmjs.com/package/parse-torrent-file)</code>\n\n<a name=\"FileIndex+event_update\"></a>\n\n### \"update\"\n**Kind**: event emitted by <code>[FileIndex](#FileIndex)</code>  \n**See**: [on](#FileIndex+on)  \n<a name=\"TorrentFile\"></a>\n\n## TorrentFile\n**Kind**: global class  \n**Properties**\n\n- offset <code>number</code> - Offset of file inside torrent.  \n- length <code>number</code> - File size in bytes.  \n- name <code>string</code> - File name inside torrent.  \n- path <code>string</code> - Path of file inside torrent.  \n- location <code>string</code> - Location on disk of matching file if found.  \n\n\n\nLicense\n-------\nMPL 2.0"},"npm":{"downloads":[{"from":"2022-07-07T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":0},{"from":"2022-07-01T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":1},{"from":"2022-06-08T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":11},{"from":"2022-04-09T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":68},{"from":"2022-01-09T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":107},{"from":"2021-07-08T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":230}],"starsCount":0},"github":{"starsCount":1,"forksCount":0,"subscribersCount":2,"issues":{"count":0,"openCount":0,"distribution":{"3600":0,"10800":0,"32400":0,"97200":0,"291600":0,"874800":0,"2624400":0,"7873200":0,"23619600":0,"70858800":0,"212576400":0},"isDisabled":false},"contributors":[{"username":"vonthar","commitsCount":6}],"commits":[{"from":"2022-07-01T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":0},{"from":"2022-06-08T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":0},{"from":"2022-04-09T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":0},{"from":"2022-01-09T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":0},{"from":"2021-07-08T00:00:00.000Z","to":"2022-07-08T00:00:00.000Z","count":0}],"statuses":[{"context":"coverage/coveralls","state":"success"},{"context":"continuous-integration/travis-ci/push","state":"success"}]},"source":{"files":{"readmeSize":9624,"testsSize":7990},"badges":[{"urls":{"original":"https://img.shields.io/npm/v/locate-torrent-data.svg","shields":"https://img.shields.io/npm/v/locate-torrent-data.svg","content":"https://img.shields.io/npm/v/locate-torrent-data.json"},"info":{"service":"npm","type":"version","modifiers":{"type":"v"}}},{"urls":{"original":"https://travis-ci.org/vonthar/node-locate-torrent-data.svg?branch=master","service":"https://api.travis-ci.org/vonthar/node-locate-torrent-data.svg?branch=master","shields":"https://img.shields.io/travis/vonthar/node-locate-torrent-data/master.svg","content":"https://img.shields.io/travis/vonthar/node-locate-torrent-data/master.json"},"info":{"service":"travis","type":"build","modifiers":{"branch":"master"}}},{"urls":{"original":"https://coveralls.io/repos/github/vonthar/node-locate-torrent-data/badge.svg?branch=master","service":"https://coveralls.io/repos/github/vonthar/node-locate-torrent-data/badge.svg?branch=master","shields":"https://img.shields.io/coveralls/vonthar/node-locate-torrent-data/master.svg","content":"https://img.shields.io/coveralls/vonthar/node-locate-torrent-data/master.json"},"info":{"service":"coveralls","type":"coverage","modifiers":{"branch":"master"}}},{"urls":{"original":"https://david-dm.org/vonthar/node-locate-torrent-data.svg","service":"https://david-dm.org/vonthar/node-locate-torrent-data.svg","shields":"https://img.shields.io/david/vonthar/node-locate-torrent-data.svg","content":"https://img.shields.io/david/vonthar/node-locate-torrent-data.json"},"info":{"service":"david","type":"dependencies","modifiers":{"statusType":"normal"}}}],"linters":["eslint"],"coverage":0.99,"outdatedDependencies":{"simple-sha1":{"required":"^2.0.8","stable":"3.1.0","latest":"3.1.0"},"walkdir":{"required":"0.0.11","stable":"0.4.1","latest":"0.4.1"},"async":{"required":"^2.0.0-rc.4","stable":"3.2.4","latest":"3.2.4"}}}},"evaluation":{"quality":{"carefulness":0.42,"tests":0.9984999999999999,"health":0.5,"branding":0.6},"popularity":{"communityInterest":4,"downloadsCount":22.666666666666668,"downloadsAcceleration":-0.07479071537290714,"dependentsCount":0},"maintenance":{"releasesFrequency":0.7591609589041095,"commitsFrequency":0,"openIssues":0.7,"issuesDistribution":0.7}},"score":{"final":0.4339389049299325,"detail":{"quality":0.8319560081962787,"popularity":0.02918248153518739,"maintenance":0.4975378112392379}}}