字幕非常干净

cleanit的Python项目详细描述


字幕非常干净。

Latest VersionTravis CI build statusLicense
Project page:https://github.com/ratoaq2/cleanit

cleanit是一个命令行工具(用python编写),可以帮助您保持字幕的干净。您可以指定规则来检测要删除的字幕条目或要替换的模式。可以使用简单的文本匹配或复杂的正则表达式。

用法

cli

干净的字幕:

$ cleanit --config my-config.yml my-subtitle.srt
Collected 1 subtitles
Saving <Subtitle [my-subtitle.srt]>
Saved <Subtitle [my-subtitle.srt]>

如何使用特定配置清除特定路径中的字幕:

fromcleanit.apiimportclean_subtitle,save_subtitlefromcleanit.configimportConfigfromcleanit.subtitleimportSubtitlesubtitle=Subtitle('/subtitle/path')config=Config.from_file('/config/path')ifclean_subtitle(subtitle,config.rules):save_subtitle(subtitle)

yaml配置文件

yaml配置文件有两个主要部分:templatesgroups

  • templates可以帮助您定义要在多个组中使用的公共配置片段。
  • groups:您可以在其中定义规则。
# Reference:#   type: [text*, regex]#   match: [contains*, exact, startswith, endswith]#   flags: [ignorecase, dotall, multiline, locale, unicode, verbose]#   whitelist: no*#   rules:#   - sometext#   - (\b)(\d{1,2})x(\d{1,2})(\b): {replacement: \1S\2E\3\4, type: regex, match: contains, flags: [unicode], whitelist: no}templates:common:type:textmatch:containsgroups:# Groups can have any name, in this case 'blacklist' we have all the rules to remove subtitle  entriesblacklist:template:commonrules:# Removes any subtitle entry that contains the word FooBar-FooBar# Removes any subtitle entry that contains the pattern S00E00# Example:#   My Series S01E02-\bs\d{2}\s?e\d{2}\b:{type:regex, flags:ignorecase}# Removes any subtitle entry that is exactly the word: 'Ah' or 'Oh' (with 1 or more h)# Example:#   Ohhh!-((Ah+)|(Oh+))\W?:{match:exact}# The group 'tidy' has all rules to replace certain patterns in your subtitles.tidy:template:commontype:regexrules:# Description: Replace extra spaces to a single space# Example:#   Foo     bar.# to#   Foo bar.-\s{2,}:''# Description: Add space when starting phrase with '-'. It ignores tags, such as <i>, <b># Example:#   <i>-Francine, what has happened?#   -What has happened? You tell me!</i># to#   <i>- Francine, what has happened?#   - What has happened? You tell me!</i>-'(?:^(|(?:\<\w\>)))-([''"]?\w+)':{ replacement:'\1-\2', flags:[multiline,unicode]}

*如果未定义任何值,则为默认值

如果未定义配置文件,cleanit将尝试从~/.config/cleanit/config.yml加载配置文件。

更改日志

0.2.1

发布日期:2016-02-28 *在没有python魔术依赖的情况下添加guess编码。

0.2

发布日期:2016-02-27 *正在删除chardet和python magic依赖项。指定了编码,或者应该由pysrt猜测编码

0.1

发布日期:2015-10-16

  • 初始版本

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java Spring数据JPA保存更新父实体   java Spring在从文件系统加载配置文件时无法解析占位符   java我可以从一个对象创建一个类吗?   在中加载图像时发生java NullPointerException。贾菲尔   Spring中Guice Provider的java等价性   Java中的安卓旋转控件   泛型<ClassName>在Java中代表什么?   java谁真正实现了可序列化方法?   java如何打印单个索引?   java Phonegap应用程序在运行Android ICS 4.0时抛出错误,但在Android 2.3及以下版本上运行良好   适合java的设计   带月份的java Switch语句   java检查父节点是否有特定的子节点   从我的jsp中引用外部项目的java问题“ExternalClass无法解析为类型”