Compare commits

...

5 Commits

Author SHA1 Message Date
Augusto Gunsch 46db1ef5eb
Update release 2021-11-21 14:08:37 -03:00
Augusto Gunsch 310743a498
Fix --stdout 2021-11-21 14:07:17 -03:00
Augusto Gunsch 3a709aa4d6
Update external API 2021-11-21 13:45:50 -03:00
Augusto Gunsch 723f43ad48
Update version number 2021-11-21 13:38:16 -03:00
Augusto Gunsch 56d04b6636
Update README.md 2021-11-19 22:44:25 -03:00
4 changed files with 22 additions and 9 deletions

View File

@ -9,6 +9,8 @@ pip install fsub
# Usage
```
usage: fsub [-h] [-f F] [-c] [-s MS] [-n] [-j] [-u] [-r | -p] [-b B] [-e E] file [file ...]
Fix, edit and clean SubRip (.srt) files.
positional arguments:
@ -53,6 +55,14 @@ python -m unittest tests.unit
python -m unittest tests.integration
```
# Scripted API
An example of calling the program from Python:
```
import fsub
fsub.run('-c', 'test.srt')
```
# Features
- Fixes subtitle numbering
- Converts files to UTF-8 encoding
@ -62,3 +72,4 @@ python -m unittest tests.integration
- May strip HTML
- May join files together
- May edit files in-place
- May cut sections out

View File

@ -1,6 +1,6 @@
[metadata]
name = fsub
version = 1.0.2
version = 1.0.4
author = Augusto Lenz Gunsch
author_email = augustogunsch@tutanota.com
description = CLI SubRip editor

View File

@ -1,6 +1,6 @@
import fsub
import fsub.fsub as fsub
# External interface
def run(args):
def run(*args):
fsub.run(args)

View File

@ -303,7 +303,7 @@ class SubripFile:
self.subs = new_subs
self.write_file(args.replace)
self.write_file(in_place=args.replace, stdout=args.stdout)
def write_file(self, in_place=False, stdout=False):
self.renumber()
@ -456,16 +456,18 @@ def parse_args(args):
# Flags that require section
if args.cut_out:
if not args.begin and not args.end:
panic('You must specify a section to work with', 64)
parser.print_usage(file=sys.stderr)
panic('fsub: error: You must specify a section to work with', 64)
# Validate options
if not args.clean and args.config:
parser.print_usage(file=sys.stderr)
panic('fsub: error: --config requires --clean', 64)
# Make sure --clean is the default
if not any((args.shift, args.no_html, args.join, args.cut_out)):
args.clean = True
# Validate options
if not args.clean and args.config:
panic('-f requires -c', 64)
if args.begin:
args.begin = SectionMarker(args.begin)