Skip to content

Commit

Permalink
added colon filter to SDH tags
Browse files Browse the repository at this point in the history
added additional author tags
  • Loading branch information
m-lyon committed Apr 11, 2021
1 parent 0edf8f9 commit fd131ea
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -3,7 +3,7 @@
from os import path
from setuptools import setup

version = '1.4.0'
version = '1.4.1'
this_dir = path.abspath(path.dirname(__file__))
with open(path.join(this_dir, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
Expand Down
6 changes: 4 additions & 2 deletions subtitle_filter/libs/subtitle.py
Expand Up @@ -10,6 +10,8 @@
'encoded and released by',
'opensubtitles.org',
'please rate this subtitle',
'captioning sponsored by',
'captioned by',
)


Expand Down Expand Up @@ -128,12 +130,12 @@ def remove_sound_effects(self):
self._contents_to_list()
for idx, _ in enumerate(self._contents):
self._contents[idx] = re.sub(
r'[\(\[][\S ]*[\)\]][\s]*', '', self._contents[idx]
r'[\(\[][\S ]*[\)\]][\s:]*', '', self._contents[idx]
)
self._remove_lone_symbols()
self._contents_to_str()
# Remove multi-line brackets
self._contents = re.sub(r'[\(\[][\S\s]*[\)\]][\s]*', '', self._contents)
self._contents = re.sub(r'[\(\[][\S\s]*[\)\]][\s:]*', '', self._contents)
self._filter_empty()

def replace_names(self):
Expand Down
13 changes: 12 additions & 1 deletion tests/data/subtitle_author_before.srt
Expand Up @@ -13,4 +13,15 @@ www.OpenSubtitles.org

3
00:00:00,062 --> 00:00:02,507
Synced and Corrected by Your Mum.
Synced and Corrected by Your Mum.

976
00:42:12,094 --> 00:42:15,054
Captioning sponsored by
CBS

978
00:42:18,884 --> 00:42:21,060
Captioned by
Media Access Group at WGBH
access.wgbh.org
4 changes: 4 additions & 0 deletions tests/data/subtitle_parenthesis_after.srt
Expand Up @@ -5,3 +5,7 @@ Examples are tough.
2
00:00:57,088 --> 00:00:58,788
- <i>And not me?</i>

3
00:11:31,995 --> 00:11:35,346
I'm raising a teenage boy.
7 changes: 6 additions & 1 deletion tests/data/subtitle_parenthesis_before.srt
Expand Up @@ -14,4 +14,9 @@ Examples are tough.
398
00:20:36,309 --> 00:20:39,277
[Roxette's "Listen to
Your Heart" plays softly]
Your Heart" plays softly]

262
00:11:31,995 --> 00:11:35,346
[chuckles softly]:
I'm raising a teenage boy.

0 comments on commit fd131ea

Please sign in to comment.