This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Subtitles extremely clean.

Project page:https://github.com/ratoaq2/cleanit

CleanIt is a command line tool (written in python) that helps you to keep your subtitles clean. You can specify rules to detect subtitle entries to be removed or patterns to be replaced. Simple text matching or complex regex can be used.

Usage

CLI

Clean subtitles:

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

Library

How to clean subtitles in a specific path using a specific configuration:

from cleanit.api import clean_subtitle, save_subtitle
from cleanit.config import Config
from cleanit.subtitle import Subtitle

subtitle = Subtitle('/subtitle/path')
config = Config.from_file('/config/path')
if clean_subtitle(subtitle, config.rules):
    save_subtitle(subtitle)

YAML Configuration file

The yaml configuration file has 2 main sections: templates and groups.

  • Templates can help you to define common configuration snippets to be used in several groups.
  • Groups: where you can define your rules.
# 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: text
    match: contains

groups:
  # Groups can have any name, in this case 'blacklist' we have all the rules to remove subtitle  entries
  blacklist:
    template: common
    rules:
      # 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: common
    type: regex
    rules:
      # 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] }

* The default value if none is defined

CleanIt will try to load configuration file from ~/.config/cleanit/config.yml if no configuration file is defined.

Changelog

0.2.1

release date: 2016-02-28 * Adding guess encoding back without python-magic dependency.

0.2

release date: 2016-02-27 * Removing chardet and python-magic dependencies. Either encoding is specified or it should be guessed by pysrt

0.1

release date: 2015-10-16

  • Initial release
Release History

Release History

0.2.1

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
cleanit-0.2.1.tar.gz (11.6 kB) Copy SHA256 Checksum SHA256 Source Feb 28, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting