{"id":21814331,"url":"https://github.com/snawoot/trusearch","last_synced_at":"2025-04-13T23:46:15.185Z","repository":{"id":49580496,"uuid":"376269577","full_name":"Snawoot/trusearch","owner":"Snawoot","description":"Perform advanced search on unofficial rutracker.org (ex torrents.ru) XML database","archived":false,"fork":false,"pushed_at":"2021-06-13T16:23:47.000Z","size":46,"stargazers_count":11,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-27T13:51:21.024Z","etag":null,"topics":["dump","rutracker","rutracker-org","torrents-ru","utility","xml","xml-dump"],"latest_commit_sha":null,"homepage":"","language":"Go","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/Snawoot.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}},"created_at":"2021-06-12T11:07:40.000Z","updated_at":"2025-03-02T20:32:22.000Z","dependencies_parsed_at":"2022-09-18T20:32:06.282Z","dependency_job_id":null,"html_url":"https://github.com/Snawoot/trusearch","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Snawoot%2Ftrusearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Snawoot%2Ftrusearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Snawoot%2Ftrusearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Snawoot%2Ftrusearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Snawoot","download_url":"https://codeload.github.com/Snawoot/trusearch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799695,"owners_count":21163398,"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":["dump","rutracker","rutracker-org","torrents-ru","utility","xml","xml-dump"],"created_at":"2024-11-27T14:37:46.895Z","updated_at":"2025-04-13T23:46:14.922Z","avatar_url":"https://github.com/Snawoot.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# trusearch\n\nCLI tool to perform advanced search on [unofficial rutracker.org (ex torrents.ru) XML database](https://rutracker.org/forum/viewtopic.php?t=5591249). It doesn't require mandatory conversion of unofficial XML into own indexed format. Binary builds are available for Windows/MacOS/Linux/\\*BSD/Android.\n\n## Installation\n\n#### Binaries\n\nPre-built binaries are available [here](https://github.com/Snawoot/trusearch/releases/latest).\n\n#### Build from source\n\nAlternatively, you may install trusearch from source. Run the following within the source directory:\n\n```\nmake install\n```\n\n## Modes of operation\n\n* `scan` - Scan XML and apply JS function defined by script file\n* `forums` - Scan XML and print CSV with forum IDs and names\n* `split` - Divide XML file into smaller ones by Forum ID\n* `help` - Print CLI synopsis\n\n### Split\n\nExample:\n\n```sh\ntrusearch split --dir=/arc/user/tru ~/rutracker-20210601.xml\n```\n\nIt may take a long time to split whole collection (about 10 minutes). However, after splitting search over specific forums runs within few seconds.\n\n### Forums\n\nExample:\n\n```sh\ntrusearch forums ~/rutracker-20210601.xml \u003e ~/forums.csv\n```\n\n### Scan\n\nSearch with inline script:\n\n```sh\ntrusearch scan --inline 'let re = /Жанр:.*(adventure|приключение)/iu; (function (elem) { if (strip_bbcode(elem.Content).match(re)) { print(\"https://rutracker.org/forum/viewtopic.php?t=\" + elem.ID) } })' /arc/user/tru/forum_1992.xml\n```\n\nSame with script in file:\n\n```sh\ntrusearch scan 1.js /arc/user/tru/forum_1992.xml\n```\n\n, having `1.js` content as follows:\n\n```js\nlet re = /Жанр:.*(adventure|приключение)/iu;\n\n(function (elem) {\n\tif (strip_bbcode(elem.Content).match(re)) {\n\t\tprint(\"https://rutracker.org/forum/viewtopic.php?t=\" + elem.ID)\n\t}\n})\n```\n\nSee `trusearch --help` for more help on commands and `trusearch COMMAND --help` for help on specific command.\n\n## JS runtime\n\ntrusearch uses JavaScript to allow user implement any matching or aggregation logic they want. JS interpreter used by program is [goja](https://github.com/dop251/goja), pure-Go implementation of ECMAScript 5.1. trusearch extends JS runtime with few native built-ins for user's convenience.\n\n### Functions\n\n| Function       | Arguments    | Return value | Description                                                 |\n| -------------- | ------------ | ------------ | ----------------------------------------------------------- |\n| `perror`       | `value, ...` | None         | Prints values to stderr                                     |\n| `print`        | `value, ...` | None         | Prints values to stdout                                     |\n| `strip_bbcode` | `string`     | `string`     | Renders text with BBCode tags into plain text (strips tags) |\n\n### Scan mode\n\nIn scan mode program expects provided script to be evaluated into a function. So, minimal example of such script is:\n\n```js\n(function (torrent) {})\n```\n\nFor each torrent scanned torrent record trusearch invokes such function with a single argument holding object with torrent record:\n\n| Property                    | Type   | Description                                                                                    |\n| --------------------------- | ------ | ---------------------------------------------------------------------------------------------- |\n| `torrent.ID`                | string | Topic ID at rutracker forum                                                                    |\n| `torrent.RegisteredAt`      | string | Torrent registration date in same format as in XML                                             |\n| `torrent.Size`              | string | Torrent size                                                                                   |\n| `torrent.Torrent.Hash`      | string | Bittorrent info hash. Can be used to generate DHT magnet link, not depending on tracker        |\n| `torrent.Torrent.TrackerID` | string | rutracker tracker server ID                                                                    |\n| `torrent.Forum.ID`          | string | Forum ID                                                                                       |\n| `torrent.Forum.Name`        | string | Forum name                                                                                     |\n| `torrent.Content`           | string | Post contents in BBCode. Use `strip_bbcode` function if you need plain text with tags stripped |\n| `torrent.Deleted`           | int    | `1` if deleted and `0` otherwise                                                               |\n\nScript may store state between function invocations in variables or objects defined outside function. In examples presented above we reuse RegExp compiled once across all function invokations.\n\nAlso user may define optional `begin` and `end` functions in script. If defined, `begin()` will be invoked before iteration and `end()` will be invoked after. It's correct to define either of them, both, or none. Example:\n\n```js\nfunction begin() {\n\tprint(\"begin\")\n}\n\nfunction end() {\n\tprint(\"end\")\n}\n\n(function () {\n\tprint(\"record\")\n})\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnawoot%2Ftrusearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnawoot%2Ftrusearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnawoot%2Ftrusearch/lists"}