Skip to content

Commit 9a271f2

Browse files
author
Fede Calendino
committed
Update readme
1 parent 70abfe1 commit 9a271f2

File tree

1 file changed

+32
-23
lines changed

1 file changed

+32
-23
lines changed

README.md

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,26 +29,20 @@ The method parse requires the following parameters:
2929
* `fps`: framerate (only used by `sub` files), `23.976` by default.
3030

3131
```python
32-
from pysubparser import parsers
32+
from pysubparser import parser
3333

34-
subtitles = parsers.parse('./files/space-jam.srt')
34+
subtitles = parser.parse('./files/space-jam.srt')
3535

3636
for subtitle in subtitles:
3737
print(subtitle)
3838
```
3939

4040
Output:
41-
```
41+
```text
4242
0 > [BALL BOUNCING]
4343
1 > Michael?
4444
2 > What are you doing out here, son? It's after midnight.
4545
3 > MICHAEL: Couldn't sleep, Pops.
46-
4 > Well, neither can we, with all that noise you're making.
47-
5 > Come on, let's go inside.
48-
6 > Just one more shot?
49-
7 > [CHUCKLES]
50-
8 > All right. Just one.
51-
9 > Yeah.
5246
```
5347

5448
___
@@ -70,7 +64,7 @@ for subtitle in subtitles:
7064
```
7165

7266
Output:
73-
```
67+
```text
7468
00:00:36.328000 > 00:00:38.329000
7569
[BALL BOUNCING]
7670
@@ -82,22 +76,37 @@ What are you doing out here, son? It's after midnight.
8276
8377
00:01:11.572000 > 00:01:13.072000
8478
MICHAEL: Couldn't sleep, Pops.
79+
```
8580

86-
00:01:13.240000 > 00:01:16.200000
87-
Well, neither can we, with all that noise you're making.
81+
### Cleaners
8882

89-
00:01:16.368000 > 00:01:17.577000
90-
Come on, let's go inside.
83+
Currently, 4 cleaners are provided:
84+
85+
* `ascii` will translate every unicode character to its ascii equivalent.
86+
* `brackets` will remove anything between them (e.g., `[BALL BOUNCING]`)
87+
* `formatting` will remove formatting keys like `<i>` and `</i>`.
88+
* `lower_case` will lower case all text.
89+
90+
```python
91+
from pysubparser.cleaners import ascii, brackets, formatting, lower_case
9192

92-
00:01:18.203000 > 00:01:20.163000
93-
Just one more shot?
93+
subtitles = brackets.clean(
94+
lower_case.clean(
95+
subtitles
96+
)
97+
)
9498

95-
00:01:20.330000 > 00:01:21.789000
96-
[CHUCKLES]
99+
for subtitle in subtitles:
100+
print(subtitle)
101+
```
102+
103+
```text
104+
0 >
105+
1 > michael?
106+
2 > what are you doing out here, son? it's after midnight.
107+
3 > michael: couldn't sleep, pops.
108+
```
97109

98-
00:01:21.957000 > 00:01:24.167000
99-
All right. Just one.
110+
### Writers
100111

101-
00:01:24.334000 > 00:01:25.835000
102-
Yeah.
103-
```
112+
Given any list of `Subtitle` and a path it will output those subtitles in a `srt` format.

0 commit comments

Comments
 (0)