{"id":26423353,"url":"https://github.com/switchupcb/srt3","last_synced_at":"2025-03-18T02:49:21.766Z","repository":{"id":57470755,"uuid":"359265021","full_name":"switchupcb/srt3","owner":"switchupcb","description":"srt3 is a simple library for parsing, modifying, and composing SRT files.","archived":false,"fork":false,"pushed_at":"2021-07-12T16:50:10.000Z","size":528,"stargazers_count":14,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2024-05-02T03:16:46.515Z","etag":null,"topics":["captions","subtitles"],"latest_commit_sha":null,"homepage":"https://srt3.readthedocs.io/","language":"Python","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/switchupcb.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-18T22:22:55.000Z","updated_at":"2022-05-23T23:17:02.000Z","dependencies_parsed_at":"2022-09-26T17:31:39.763Z","dependency_job_id":null,"html_url":"https://github.com/switchupcb/srt3","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/switchupcb%2Fsrt3","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/switchupcb%2Fsrt3/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/switchupcb%2Fsrt3/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/switchupcb%2Fsrt3/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/switchupcb","download_url":"https://codeload.github.com/switchupcb/srt3/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243769950,"owners_count":20345215,"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":["captions","subtitles"],"created_at":"2025-03-18T02:49:21.269Z","updated_at":"2025-03-18T02:49:21.762Z","avatar_url":"https://github.com/switchupcb.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"|ghactions| |lgtm| |codecov| |libraries|\n\n.. |ghactions| image:: https://github.com/switchupcb/srt3/actions/workflows/python-package.yml/badge.svg\n  :target: https://github.com/switchupcb/srt3/actions\n  :alt: Github Actions\n\n.. |lgtm| image:: https://img.shields.io/lgtm/grade/python/github/switchupcb/srt3.svg?label=code%20quality\n  :target: https://lgtm.com/projects/g/switchupcb/srt3/overview/\n  :alt: LGTM\n\n.. |codecov| image:: https://codecov.io/gh/switchupcb/srt3/branch/develop/graph/badge.svg?token=YINLIN42N1\n  :target: https://codecov.io/gh/switchupcb/srt3\n  :alt: Coverage\n\n.. |libraries| image:: https://img.shields.io/librariesio/github/switchupcb/srt3.svg?label=dependencies\n  :target: https://libraries.io/github/switchupcb/srt3\n  :alt: Dependencies\n\nsrt3 is a simple yet featureful Python library for parsing, modifying, and\ncomposing `SRT files`_. Take a look at the quickstart_ for a basic overview of\nthe library. `Detailed API documentation`_ is also available.\n\nWant to see some examples of its use? Take a look at the `tools shipped with\nthe library`_.\n\nWhy choose this library?\n------------------------\n\n- Parses broken SRT files other libraries can't and fixes them\n- Support for Asian-style SRT formats (ie. \"fullwidth\" SRT format)\n- Extremely lightweight with a `Well Documented API`_\n- Includes tools that allow you to perform tasks using the library\n- No Dependencies outside of the Standard Library\n- High quality test suite using Hypothesis_\n- `~30% faster than pysrt on typical workloads`_\n- 100% Unicode Compliant\n- Portable — runs on Windows, OSX, and Linux\n- Released under a highly permissive license (MIT)\n\n.. _quickstart: http://srt3.readthedocs.org/en/latest/quickstart.html\n.. _`SRT files`: https://en.wikipedia.org/wiki/SubRip#SubRip_text_file_format\n.. _Hypothesis: https://github.com/DRMacIver/hypothesis\n.. _`Well Documented API`: http://srt3.readthedocs.org/en/latest/index.html\n.. _`~30% faster than pysrt on typical workloads`: https://paste.pound-python.org/raw/8nQKbDW0ROWvS7bOeAb3/\n\nUsage\n-----\n\nTools\n=====\n\nThere are a number of `tools shipped with the library`_ to manipulate, process,\nand fix SRT files. Here's an example using `hanzidentifier`_ to strip out\nnon-Chinese lines:\n\n.. code::\n\n    $ cat pe.srt\n    1\n    00:00:33,843 --\u003e 00:00:38,097\n    Only 3% of the water on our planet is fresh.\n    地球上只有3%的水是淡水\n\n    2\n    00:00:40,641 --\u003e 00:00:44,687\n    Yet, these precious waters are rich with surprise.\n    可是这些珍贵的淡水中却充满了惊奇\n\n    $ srt match -m hanzidentifier -fm hanzidentifier.has_chinese -i pe.srt\n    1\n    00:00:33,843 --\u003e 00:00:38,097\n    地球上只有3%的水是淡水\n\n    2\n    00:00:40,641 --\u003e 00:00:44,687\n    可是这些珍贵的淡水中却充满了惊奇\n\n\nThese tools are easy to chain together. For example, you have a subtitle\ncontaining Chinese and English, and another containing French. You only want Chinese\nFrench. The Chinese and English subtitle is also 5 seconds late. That's easy enough\nto sort out:\n\n.. code::\n\n   $ srt match -m hanzidentifier -fm hanzidentifier.has_chinese -i chs+eng.srt |\n   \u003e     srt fixed_timeshift --seconds -5 |\n   \u003e     srt mux --input - --input fra.srt\n\nSee the srt/tools/ directory for more information.\n\n.. _hanzidentifier: https://github.com/tsroten/hanzidentifier\n\nLibrary\n=======\n\n`Detailed API documentation`_ is available, but here are the basics:\n\n.. code:: python\n\n    \u003e\u003e\u003e # list() is needed as srt.parse creates a generator\n    \u003e\u003e\u003e subs = list(srt.parse('''\\\n    ... 1\n    ... 00:00:33,843 --\u003e 00:00:38,097\n    ... 地球上只有3%的水是淡水\n    ...\n    ... 2\n    ... 00:00:40,641 --\u003e 00:00:44,687\n    ... 可是这些珍贵的淡水中却充满了惊奇\n    ...\n    ... 3\n    ... 00:00:57,908 --\u003e 00:01:03,414\n    ... 所有陆地生命归根结底都依赖於淡水\n    ...\n    ... '''))\n    \u003e\u003e\u003e subs\n    [Subtitle(index=1, start=datetime.timedelta(0, 33, 843000), end=datetime.timedelta(0, 38, 97000), content='地球上只有3%的水是淡水', proprietary=''),\n     Subtitle(index=2, start=datetime.timedelta(0, 40, 641000), end=datetime.timedelta(0, 44, 687000), content='可是这些珍贵的淡水中却充满了惊奇', proprietary=''),\n     Subtitle(index=3, start=datetime.timedelta(0, 57, 908000), end=datetime.timedelta(0, 63, 414000), content='所有陆地生命归根结底都依赖於淡水', proprietary='')]\n    \u003e\u003e\u003e print(srt.compose(subs))\n    1\n    00:00:33,843 --\u003e 00:00:38,097\n    地球上只有3%的水是淡水\n\n    2\n    00:00:40,641 --\u003e 00:00:44,687\n    可是这些珍贵的淡水中却充满了惊奇\n\n    3\n    00:00:57,908 --\u003e 00:01:03,414\n    所有陆地生命归根结底都依赖於淡水\n\nInstallation\n------------\n\nTo install the latest stable version from PyPi:\n\n.. code::\n\n    pip install -U srt3\n\nTo install the latest development version directly from GitHub:\n\n.. code::\n\n    pip install -U git+https://github.com/switchupcb/srt3.git@develop\n\nContribute\n----------\nYou can contribute to this repository using its `Contribution Guidelines`_.\n\n.. _`Detailed API documentation`: http://srt3.readthedocs.org/en/latest\n.. _`tools shipped with the library`: https://github.com/switchupcb/srt3/tree/develop/srt/tools\n.. _`Contribution Guidelines`: https://github.com/switchupcb/srt3/blob/5011e36336134eedf281bbab60279c988b54e07f/.github/CONTRIBUTING.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswitchupcb%2Fsrt3","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswitchupcb%2Fsrt3","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswitchupcb%2Fsrt3/lists"}