{"id":17032325,"url":"https://github.com/cbenoit/subfilter-rs","last_synced_at":"2025-07-29T19:10:10.349Z","repository":{"id":57668949,"uuid":"267490819","full_name":"CBenoit/subfilter-rs","owner":"CBenoit","description":"Subtitle filter utility","archived":false,"fork":false,"pushed_at":"2020-05-29T18:43:57.000Z","size":19,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T14:34:16.044Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CBenoit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-05-28T04:13:14.000Z","updated_at":"2023-10-11T21:08:31.000Z","dependencies_parsed_at":"2022-08-27T03:51:22.725Z","dependency_job_id":null,"html_url":"https://github.com/CBenoit/subfilter-rs","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBenoit%2Fsubfilter-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBenoit%2Fsubfilter-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBenoit%2Fsubfilter-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CBenoit%2Fsubfilter-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CBenoit","download_url":"https://codeload.github.com/CBenoit/subfilter-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248569578,"owners_count":21126255,"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":[],"created_at":"2024-10-14T08:28:01.195Z","updated_at":"2025-04-12T12:43:21.987Z","avatar_url":"https://github.com/CBenoit.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Crates.io](https://img.shields.io/crates/v/subfilter.svg)](https://crates.io/crates/subfilter)\n[![docs.rs](https://docs.rs/subfilter/badge.svg)](https://docs.rs/subfilter)\n![Crates.io](https://img.shields.io/crates/l/subfilter)\n\n# subfilter\n\nCLI tool to process and filter out stuff from subtitle files.\n\nI use it to get pre-processed clean output from subtitle files.\nThis tool is similar to `grep` or `rip-grep` and alike, but has knowledge\nof subtitle file formats. In the context of this tool, a \"line\" is equivalent\nto a full subtitle entry (might contains several new lines).\nYou can also request to print context lines by duration difference from the\nmatched line.\n\n## Usage\n\n```\n    subfilter [FLAGS] [OPTIONS] \u003cfile-path\u003e [pattern]\n\nFLAGS:\n    -h, --help         Prints help information\n        --hide-time    Whether timecode should be shown for the first line\n        --no-color     Disable color output for matching part\n    -V, --version      Prints version information\n    -v, --verbose      Verbose output\n\nOPTIONS:\n    -A, --after-context \u003cafter-context\u003e                  Number of lines to show after each match [default: 0]\n    -C, --context \u003caround-context\u003e\n            Number of lines to show before and after each match. This overrides both the -B/--before-context and\n            -A/--after-context flags\n    -B, --before-context \u003cbefore-context\u003e                Number of lines to show after each match [default: 0]\n        --post-replace-pattern \u003cpost-replace-pattern\u003e\n            Pattern to replace after pattern matching (see https://docs.rs/regex/1.3.7/regex/)\n\n        --post-replace-with \u003cpost-replace-with\u003e\n            Replacement string after pattern matching (see https://docs.rs/regex/1.3.7/regex/)\n\n        --pre-replace-pattern \u003cpre-replace-pattern\u003e\n            Pattern to replace before pattern matching (see https://docs.rs/regex/1.3.7/regex/)\n\n        --pre-replace-with \u003cpre-replace-with\u003e\n            Replacement string before pattern matching (see https://docs.rs/regex/1.3.7/regex/)\n\n    -i, --sep-interval \u003cseparation-interval-ms\u003e\n            Separate blocks if next timecode is later by an offset of this value in milliseconds [default: 5000]\n\n        --time-after \u003ctime-after-context\u003e\n            Duration threshold in milliseconds to decide whether we show a line after a match. This overrides\n            -C/--context -B/--before-context and -A/--after-context flags\n        --time-around \u003ctime-around-context\u003e\n            Duration threshold in milliseconds to decide whether we show a line around a match. This overrides --time-\n            after, --time-before, -C/--context -B/--before-context and -A/--after-context flags\n        --time-before \u003ctime-before-context\u003e\n            Duration threshold in milliseconds to decide whether we show a line before a match. This overrides\n            -C/--context -B/--before-context and -A/--after-context flags\n\nARGS:\n    \u003cfile-path\u003e    Input file\n    \u003cpattern\u003e      Pattern to find (see https://docs.rs/regex/1.3.7/regex/)\n```\n\n## Demo\n\nBasic usage:\n\n![Basic usage](https://i.imgur.com/bPwrNC9.png)\n\nWith some regex preprocessing step:\n\n![With preprocessing](https://i.imgur.com/c50IsqX.png)\n\n## Examples\n\nPrint all lines containing \"hello\"\n```\nsubfilter subs.srt hello\n```\n\nPrint all lines containing \"hello\" or \"hi\"\n```\nsubfilter subs.ass \"(hello|hi\")\"\n```\n\nPrint all lines containing \"hello\" with the previous line and the next one as context. \n```\nsubfilter -A 10 -B 1 subs.ass hello\n```\n\nPrint all lines containing \"hello world\" but apply a match and replace regex before to strip html tags.\nThat way, `\u003cspan\u003ehello\u003c/span\u003e world` is also matched by the filtering pattern.\n```\nsubfilter --pre-replace-pattern=\"\u003c\\s*[\\.a-zA-Z]+[^\u003e]*\u003e(.*?)\u003c\\s*/\\s*[\\.a-zA-Z]+\u003e\" --pre-replace-with=\"\\$1\" subs.ass \"hello world\"\n```\n\nPrint all lines containing \"hello world\" but replace \"hello\" by \"hi\".\n```\nsubfilter --post-replace-pattern=\"hello\" --post-replace-with=\"hi\" subs.srt \"hello world\"\n```\n\n# Install\n\n- [Install Rust toolchain](https://www.rust-lang.org/tools/install)\n- Download and compile by running following command:\n    ```\n    $ cargo install subfilter\n    ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbenoit%2Fsubfilter-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcbenoit%2Fsubfilter-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbenoit%2Fsubfilter-rs/lists"}