diff --git a/docs/changelog.rst b/docs/changelog.rst index 9de457b3..2f3862b1 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,5 +1,9 @@ Changelog --------- +2.2.15 +^^^^^^ +- Always skip doubled special characters, not just in case the cue starters are doubled. + 2.2.14 ^^^^^^ - Fix an issue with WebVTT writer text positioning on break inside a cue. diff --git a/pycaption/scc/__init__.py b/pycaption/scc/__init__.py index 398745ed..5846f551 100644 --- a/pycaption/scc/__init__.py +++ b/pycaption/scc/__init__.py @@ -367,13 +367,12 @@ def _handle_double_command(self, word): # doubled special characters and doubled extended characters # with only one member of each pair being displayed. - doubled_types = word != "94a1" and word in COMMANDS or _is_pac_command(word) + doubled_types = (word != "94a1" and word in COMMANDS) or _is_pac_command(word) or word in SPECIAL_CHARS if self.double_starter: doubled_types = ( doubled_types or word in EXTENDED_CHARS or word == "94a1" - or word in SPECIAL_CHARS ) if word in CUE_STARTING_COMMAND and word != self.last_command: diff --git a/pycaption/scc/constants.py b/pycaption/scc/constants.py index c8d5cefb..e8a9f398 100644 --- a/pycaption/scc/constants.py +++ b/pycaption/scc/constants.py @@ -988,7 +988,7 @@ def _restructure_bytes_to_position_map(byte_to_pos_map): # taken from # http://www.theneitherworld.com/mcpoodle/SCC_TOOLS/DOCS/CC_CHARS.HTML -INCONVERTIBLE_TO_ASCII_EXTENDED_CHARS_ASSOCIATION = { +SUBSTITUTE_CHARACTERS = { '¡': ["!", "i"], # inverted exclamation mark '¤': ["C"], # currency '¥': ["Y"], # yen diff --git a/setup.py b/setup.py index 734017eb..fab6de50 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ setup( name="pycaption", - version="2.2.14", + version="2.2.15.dev1", description="Closed caption converter", long_description=open(README_PATH).read(), author="Joe Norton", diff --git a/tests/fixtures/scc.py b/tests/fixtures/scc.py index e09a10d3..3b60a12a 100644 --- a/tests/fixtures/scc.py +++ b/tests/fixtures/scc.py @@ -144,6 +144,14 @@ def sample_scc_roll_up_ru2(): 00:00:13;07 9425 9425 94ad 94ad 9470 9470 c1c2 c3c4 c580 91bf +00:00:13;15 9425 9425 94ad 94ad 9470 9470 9137 + +00:00:13;20 9425 9425 94ad 94ad 9470 9470 9137 9137 + +00:00:13;25 9425 9425 94ad 94ad 9470 9470 9137 9137 9137 + +00:00:13;40 9425 9425 94ad 94ad 9470 9470 9137 9137 9137 9137 + 00:00:14;07 9425 9425 94ad 94ad 9470 9470 9220 9220 92a1 92a2 92a7 00:00:17;01 9426 9426 94ad 94ad 9470 9470 57c8 4552 4520 d94f d5a7 5245 20d3 54c1 cec4 49ce c720 ce4f 572c diff --git a/tests/test_scc.py b/tests/test_scc.py index b6076202..f44a55c7 100644 --- a/tests/test_scc.py +++ b/tests/test_scc.py @@ -419,8 +419,12 @@ def test_freeze_rollup_captions_contents(self, sample_scc_roll_up_ru2): "AND IMPROVING THE LIVES OF ALL", "WE SERVE.", "®°½", - "®°½½", + "®°½", "ABû", + '♪', + '♪', + '♪♪', + '♪♪', "ÁÉÓ¡", "WHERE YOU'RE STANDING NOW,", "LOOKING OUT THERE, THAT'S AL", @@ -430,6 +434,8 @@ def test_freeze_rollup_captions_contents(self, sample_scc_roll_up_ru2): "And wildlife.", ">> Bike Iowa, your source for", ] + for x in actual_texts: + print(x) assert expected_texts == actual_texts def test_multiple_formats(self, sample_scc_multiple_formats):