从.srt文件中筛选SDH条目和更多条目
subtitle-filter的Python项目详细描述
字幕过滤器
过滤.srt
字幕文件以删除SDH(耳聋或听力障碍)条目和其他标记。在
安装
pip install subtitle-filter
使用
subtitle-filter
可以用作脚本或模块。在
默认情况下,此模块按顺序过滤以下内容:
- 删除字体标记和其中包含的文本,例如
<font color="#DF01D7">Hey\</font>
被删除。在 - 删除包含星号的子标题项:
*
。在 - 删除包含
♪
的子标题行。在 - 删除声音效果:包含括号
(BANG)
和方括号[boom]
的文本。在 - 将名称替换为短划线,例如
GARY: Hey
或Gary: Hey
到- Hey
。在 - 删除作者标记,例如
XoXo Subtitles by PwnedDude967 XoXo
。在 - 删除单独的符号,如
?
、-
、#
、_
。在
脚本用法
显示帮助显示:
^{pr2}$使用默认选项就地过滤字幕(覆盖原始字幕)。在
filter-subtitles.py -s /path/to/sub.srt
打印输出,而不是保存到磁盘。在
filter-subtitles.py -s /path/to/sub.srt -p
将输出保存到其他文件路径。在
filter-subtitles.py -s /path/to/sub.srt -o /path/to/outsub.srt
自定义筛选器标志。在
--keep-fonts Do not remove font tags and text contained within.
--keep-ast Do not remove subtitles containing asterisks: (*).
--keep-music Do not lines containing 1 or more "♪" symbols.
--keep-effects Do not remove text between and including parenthesis
() or brackets []
--keep-names Do not replace names in CAPITALS with "-" tags
--keep-author Do not remove author tags, eg. Subtitles by some guy.
模块使用
使用默认选项就地过滤字幕(覆盖原始字幕)
fromsubtitle_filterimportSubtitlessubs=Subtitles('/path/to/sub.srt')subs.filter()subs.save()
打印输出,而不是保存到磁盘。在
subs.print()
将输出保存到其他文件路径。在
subs.save('/path/to/newsub.srt')
使用自定义筛选器标志。在
subs.filter(rm_fonts=True,rm_ast=False,rm_music=True,rm_effects=True,rm_names=False,rm_author=False,)
问题
如果您发现过滤后的字幕有任何问题,或者希望请求新功能,请在GitHub上创建一个问题。在
- 项目
标签: