{"id":15366775,"url":"https://github.com/scttcper/torrent-file","last_synced_at":"2025-07-17T16:35:07.848Z","repository":{"id":37906290,"uuid":"187411715","full_name":"scttcper/torrent-file","owner":"scttcper","description":"TypeScript torrent file parser","archived":false,"fork":false,"pushed_at":"2025-01-20T22:42:39.000Z","size":804,"stargazers_count":12,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-14T16:13:42.100Z","etag":null,"topics":["bencode","torrent","torrent-files"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/scttcper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-18T22:41:10.000Z","updated_at":"2025-01-20T22:42:43.000Z","dependencies_parsed_at":"2024-03-10T16:29:09.517Z","dependency_job_id":"a718681c-7943-4e17-adb3-4b31ddff39a9","html_url":"https://github.com/scttcper/torrent-file","commit_stats":{"total_commits":84,"total_committers":5,"mean_commits":16.8,"dds":0.3928571428571429,"last_synced_commit":"86ebc6543d1a8716b270224b2d15a718cb1f6330"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scttcper%2Ftorrent-file","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scttcper%2Ftorrent-file/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scttcper%2Ftorrent-file/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/scttcper%2Ftorrent-file/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/scttcper","download_url":"https://codeload.github.com/scttcper/torrent-file/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248914115,"owners_count":21182359,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bencode","torrent","torrent-files"],"created_at":"2024-10-01T13:19:48.934Z","updated_at":"2025-04-14T16:13:50.603Z","avatar_url":"https://github.com/scttcper.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# torrent-file [![npm](https://badgen.net/npm/v/@ctrl/torrent-file)](https://www.npmjs.com/package/@ctrl/torrent-file) [![coverage](https://badgen.net/codecov/c/github/scttcper/torrent-file)](https://codecov.io/gh/scttcper/torrent-file) [![bundlesize](https://badgen.net/bundlephobia/min/@ctrl/torrent-file)](https://bundlephobia.com/result?p=@ctrl/torrent-file)\n\n\u003e Parse a torrent file and read encoded data. \n\nThis project is based on [parse-torrent](https://www.npmjs.com/package/parse-torrent) and [node-bencode](https://github.com/themasch/node-bencode) to parse the data of a torrent file. This library implements its own [bencode](http://www.bittorrent.org/beps/bep_0003.html) encoder and decoder that does not use `Buffer`.\n\n### Install\n```console\nnpm install @ctrl/torrent-file\n```\n\n### API\n\n##### info\nThe content of the metainfo file.\n```ts\nimport fs from 'fs';\nimport { info } from '@ctrl/torrent-file';\n\nconst torrentInfo = info(fs.readFileSync('myfile'));\nconsole.log({ torrentInfo });\n```\n\n##### files\ndata about the files described in the torrent file, includes hashes of the pieces\n```ts\nimport fs from 'fs';\nimport { files } from '@ctrl/torrent-file';\n\nconst torrentFiles = files(fs.readFileSync('myfile'));\nconsole.log({ torrentFiles });\n```\n\n##### hash\nsha1 of torrent file info. This hash is commenly used by torrent clients as the ID of the torrent. It is async and sha1 encoding is handled by [crypto-hash](https://github.com/sindresorhus/crypto-hash)\n```ts\nimport fs from 'fs';\nimport { hash } from '@ctrl/torrent-file';\n\n(async () =\u003e {\n  const torrentHash = await hash(fs.readFileSync('myfile'));\n  console.log({ torrentHash });\n})()\n```\n\n\n### See Also\n[parse-torrent](https://www.npmjs.com/package/parse-torrent) - \"@ctrl/torrent-file\" torrent parsing based very heavily off this project  \n[node-bencode](https://github.com/themasch/node-bencode) - bencoder built into this project heavily based off this project   \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscttcper%2Ftorrent-file","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fscttcper%2Ftorrent-file","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fscttcper%2Ftorrent-file/lists"}