Restructure project
This commit is contained in:
parent
7120d76aad
commit
cb142d3e30
|
@ -0,0 +1,3 @@
|
||||||
|
dist/
|
||||||
|
*.egg-info/
|
||||||
|
__pycache__/
|
|
@ -1,6 +1,12 @@
|
||||||
# fsub
|
# fsub
|
||||||
`fsub` is a Python script for cleaning, editing and fixing a SubRip (.srt) file
|
`fsub` is a Python script for cleaning, editing and fixing a SubRip (.srt) file
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
Through Python's pip:
|
||||||
|
```
|
||||||
|
pip install fsub
|
||||||
|
```
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
```
|
```
|
||||||
usage: fsub [-h] [-c] [-s MS] [-n] [-f FILE] file [file ...]
|
usage: fsub [-h] [-c] [-s MS] [-n] [-f FILE] file [file ...]
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/sh
|
||||||
|
rm -rv dist
|
||||||
|
python3 -m build
|
||||||
|
|
||||||
|
# Upload to PyPI with:
|
||||||
|
# python3 -m twine upload --repository pypi dist/*
|
|
@ -0,0 +1,6 @@
|
||||||
|
[build-system]
|
||||||
|
requires = [
|
||||||
|
"setuptools>=42",
|
||||||
|
"wheel"
|
||||||
|
]
|
||||||
|
build-backend = "setuptools.build_meta"
|
|
@ -0,0 +1,28 @@
|
||||||
|
[metadata]
|
||||||
|
name = fsub
|
||||||
|
version = 0.0.1
|
||||||
|
author = Augusto Lenz Gunsch
|
||||||
|
author_email = augustogunsch@tutanota.com
|
||||||
|
description = CLI SubRip editor
|
||||||
|
long_description = file: README.md
|
||||||
|
long_description_content_type = text/markdown
|
||||||
|
url = https://github.com/augustogunsch/fsub
|
||||||
|
project_urls =
|
||||||
|
Bug Tracker = https://github.com/augustogunsch/fsub/issues
|
||||||
|
classifiers =
|
||||||
|
Programming Language :: Python :: 3
|
||||||
|
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
||||||
|
Operating System :: OS Independent
|
||||||
|
|
||||||
|
[options]
|
||||||
|
package_dir =
|
||||||
|
= src
|
||||||
|
packages = find:
|
||||||
|
python_requires = >=3.9
|
||||||
|
|
||||||
|
[options.packages.find]
|
||||||
|
where = src
|
||||||
|
|
||||||
|
[options.entry_points]
|
||||||
|
console_scripts =
|
||||||
|
fsub = fsub.fsub:main
|
|
@ -188,67 +188,72 @@ def process_file(args, file):
|
||||||
output.write(os.linesep)
|
output.write(os.linesep)
|
||||||
|
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(
|
def main():
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
description='Fix, edit and clean SubRip (.srt) files.',
|
description='Fix, edit and clean SubRip (.srt) files.',
|
||||||
add_help=True
|
add_help=True
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-c', '--clean',
|
'-c', '--clean',
|
||||||
help='removes subtitles matching regular expressions ' +
|
help='removes subtitles matching regular expressions ' +
|
||||||
'listed in ~/.config/fsubrc (this is the default ' +
|
'listed in ~/.config/fsubrc (this is the default ' +
|
||||||
'behavior if no other flag is passed)',
|
'behavior if no other flag is passed)',
|
||||||
action='store_true'
|
action='store_true'
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-s', '--shift',
|
'-s', '--shift',
|
||||||
help='shifts all subtitles by MS milliseconds, which ' +
|
help='shifts all subtitles by MS milliseconds, which ' +
|
||||||
'may be positive or negative',
|
'may be positive or negative',
|
||||||
metavar='MS',
|
metavar='MS',
|
||||||
action='store',
|
action='store',
|
||||||
type=int
|
type=int
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-n', '--no-html',
|
'-n', '--no-html',
|
||||||
help='strips HTML tags from subtitles content',
|
help='strips HTML tags from subtitles content',
|
||||||
action='store_true'
|
action='store_true'
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-f', '--config-file',
|
'-f', '--config-file',
|
||||||
help='overwrites the default config file (~/.config/fsubrc)',
|
help='overwrites the default config file (~/.config/fsubrc)',
|
||||||
metavar='FILE',
|
metavar='FILE',
|
||||||
action='store',
|
action='store',
|
||||||
type=argparse.FileType('r')
|
type=argparse.FileType('r')
|
||||||
)
|
)
|
||||||
|
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'files',
|
'files',
|
||||||
help='list of input files (they all must be SubRip files)',
|
help='list of input files (they all must be SubRip files)',
|
||||||
metavar='file',
|
metavar='file',
|
||||||
type=argparse.FileType('rb+'),
|
type=argparse.FileType('rb+'),
|
||||||
nargs='+'
|
nargs='+'
|
||||||
)
|
)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Make sure --clean is the default
|
# Make sure --clean is the default
|
||||||
if not args.shift and not args.no_html:
|
if not args.shift and not args.no_html:
|
||||||
args.clean = True
|
args.clean = True
|
||||||
|
|
||||||
# Validate options
|
# Validate options
|
||||||
if not args.clean and args.config_file:
|
if not args.clean and args.config_file:
|
||||||
print('-f requires -c', file=sys.stderr)
|
print('-f requires -c', file=sys.stderr)
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
# Check if all files are .srt
|
# Check if all files are .srt
|
||||||
for file in args.files:
|
for file in args.files:
|
||||||
if file.name[-4:] != '.srt':
|
if file.name[-4:] != '.srt':
|
||||||
print('File {} is not a SubRip file'.format(file.name),
|
print('File {} is not a SubRip file'.format(file.name),
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
for file in args.files:
|
for file in args.files:
|
||||||
process_file(args, file)
|
process_file(args, file)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue