项目作者: GitBib

项目描述 :
Convert ASS subtitle to SRT format
高级语言: Python
项目地址: git://github.com/GitBib/pyasstosrt.git
创建时间: 2020-04-12T19:34:49Z
项目社区:https://github.com/GitBib/pyasstosrt

开源协议:Apache License 2.0

下载


pyasstosrt

Downloads codecov

pyasstosrt – this tool will help you convert Advanced SubStation Alpha (ASS/SSA) subtitle files to SubRip (SRT) files.

Support for str path:

  1. from pyasstosrt import Subtitle
  2. sub = Subtitle('sub.ass')
  3. sub.export()

Support for all Path-like objects, instead of only pathlib’s Path:

  1. from pathlib import Path
  2. from pyasstosrt import Subtitle
  3. path = Path('sub.ass')
  4. sub = Subtitle(path)
  5. sub.export()

You can get a sheet with dialogue by specifying output_dialogues.

  1. from pathlib import Path
  2. from pyasstosrt import Subtitle
  3. path = Path('sub.ass')
  4. sub = Subtitle(path)
  5. sub.export(output_dialogues=True)

If you want to remove effects from text, you can use the removing_effects.

  1. from pyasstosrt import Subtitle
  2. sub = Subtitle('sub.ass', removing_effects=True)
  3. sub.export()

You can enable the deletion of duplicate lines with the rearrangement of start and end times.

  1. from pyasstosrt import Subtitle
  2. sub = Subtitle('sub.ass', remove_duplicates=True)
  3. sub.export()

CLI

  1. pyasstosrt export /Users/user/sub/sub.ass

Optional You can specify an export folder.

  1. pyasstosrt export /Users/user/sub/sub.ass --output-dir /Users/user/sub/srt

Optional If you want to remove effects from text, you can use the —remove-effects flag.

  1. pyasstosrt export /Users/user/sub/sub.ass --remove-effects --output-dir /Users/user/sub/srt

Optional If you need to remove duplicates, you can use the —remove-duplicates flag.

  1. pyasstosrt export /Users/user/sub/sub.ass --remove-duplicates

Optional You can use the flags together —remove-duplicates —remove-effects

  1. pyasstosrt export /Users/user/sub/sub.ass --remove-duplicates --remove-effects

Installation

Most users will want to simply install the latest version, hosted on PyPI:

  1. $ pip install 'pyasstosrt[cli]'

If you just want to use it as a library and don’t need the CLI, you can omit the [cli] extra.