pycaption 2.2.5__tar.gz → 2.2.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. {pycaption-2.2.5/pycaption.egg-info → pycaption-2.2.7}/PKG-INFO +1 -1
  2. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/scc/__init__.py +37 -43
  3. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/scc/constants.py +6 -3
  4. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/scc/specialized_collections.py +12 -5
  5. {pycaption-2.2.5 → pycaption-2.2.7/pycaption.egg-info}/PKG-INFO +1 -1
  6. {pycaption-2.2.5 → pycaption-2.2.7}/setup.py +1 -1
  7. {pycaption-2.2.5 → pycaption-2.2.7}/tests/conftest.py +0 -2
  8. {pycaption-2.2.5 → pycaption-2.2.7}/tests/fixtures/dfxp.py +2 -2
  9. {pycaption-2.2.5 → pycaption-2.2.7}/tests/fixtures/scc.py +1 -28
  10. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_scc.py +10 -40
  11. {pycaption-2.2.5 → pycaption-2.2.7}/LICENSE +0 -0
  12. {pycaption-2.2.5 → pycaption-2.2.7}/MANIFEST.in +0 -0
  13. {pycaption-2.2.5 → pycaption-2.2.7}/README.rst +0 -0
  14. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/__init__.py +0 -0
  15. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/base.py +0 -0
  16. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/dfxp/__init__.py +0 -0
  17. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/dfxp/base.py +0 -0
  18. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/dfxp/extras.py +0 -0
  19. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/english.pickle +0 -0
  20. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/exceptions.py +0 -0
  21. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/geometry.py +0 -0
  22. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/microdvd.py +0 -0
  23. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/sami.py +0 -0
  24. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/scc/state_machines.py +0 -0
  25. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/scc/translator.py +0 -0
  26. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/srt.py +0 -0
  27. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/transcript.py +0 -0
  28. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/utils.py +0 -0
  29. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption/webvtt.py +0 -0
  30. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption.egg-info/SOURCES.txt +0 -0
  31. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption.egg-info/dependency_links.txt +0 -0
  32. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption.egg-info/requires.txt +0 -0
  33. {pycaption-2.2.5 → pycaption-2.2.7}/pycaption.egg-info/top_level.txt +0 -0
  34. {pycaption-2.2.5 → pycaption-2.2.7}/setup.cfg +0 -0
  35. {pycaption-2.2.5 → pycaption-2.2.7}/tests/__init__.py +0 -0
  36. {pycaption-2.2.5 → pycaption-2.2.7}/tests/fixtures/__init__.py +0 -0
  37. {pycaption-2.2.5 → pycaption-2.2.7}/tests/fixtures/microdvd.py +0 -0
  38. {pycaption-2.2.5 → pycaption-2.2.7}/tests/fixtures/sami.py +0 -0
  39. {pycaption-2.2.5 → pycaption-2.2.7}/tests/fixtures/srt.py +0 -0
  40. {pycaption-2.2.5 → pycaption-2.2.7}/tests/fixtures/translated_scc.py +0 -0
  41. {pycaption-2.2.5 → pycaption-2.2.7}/tests/fixtures/webvtt.py +0 -0
  42. {pycaption-2.2.5 → pycaption-2.2.7}/tests/mixins.py +0 -0
  43. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_base.py +0 -0
  44. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_dfxp.py +0 -0
  45. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_dfxp_conversion.py +0 -0
  46. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_dfxp_extras.py +0 -0
  47. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_functions.py +0 -0
  48. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_geometry.py +0 -0
  49. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_microdvd.py +0 -0
  50. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_microdvd_conversion.py +0 -0
  51. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_sami.py +0 -0
  52. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_sami_conversion.py +0 -0
  53. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_scc_conversion.py +0 -0
  54. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_scc_translator.py +0 -0
  55. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_srt.py +0 -0
  56. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_srt_conversion.py +0 -0
  57. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_webvtt.py +0 -0
  58. {pycaption-2.2.5 → pycaption-2.2.7}/tests/test_webvtt_conversion.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycaption
3
- Version: 2.2.5
3
+ Version: 2.2.7
4
4
  Summary: Closed caption converter
5
5
  Author: Joe Norton
6
6
  Author-email: joey@nortoncrew.com
@@ -81,11 +81,11 @@ http://www.theneitherworld.com/mcpoodle/SCC_TOOLS/DOCS/SCC_FORMAT.HTML
81
81
  import math
82
82
  import re
83
83
  import textwrap
84
- from collections import deque
84
+ from collections import deque, defaultdict
85
85
  from copy import deepcopy
86
86
 
87
87
  from pycaption.base import (
88
- BaseReader, BaseWriter, CaptionSet, CaptionNode,
88
+ BaseReader, BaseWriter, CaptionSet
89
89
  )
90
90
  from pycaption.exceptions import CaptionReadNoCaptions, InvalidInputError, \
91
91
  CaptionReadTimingError, CaptionLineLengthError
@@ -232,16 +232,24 @@ class SCCReader(BaseReader):
232
232
  captions = CaptionSet({lang: self.caption_stash.get_all()})
233
233
 
234
234
  # check captions for incorrect lengths
235
- lines = []
235
+ lines_too_long = defaultdict(list)
236
236
  for caption in self.caption_stash._collection:
237
+ caption_start = caption.to_real_caption().format_start()
237
238
  caption_text = "".join(caption.to_real_caption().get_text_nodes())
238
- lines.extend(caption_text.split("\n"))
239
- lines_too_long = [line for line in lines if len(line) > 32]
240
-
241
- if bool(lines_too_long):
242
- msg = ""
243
- for line in lines_too_long:
244
- msg += line + f" - Length { len(line)}" + "\n"
239
+ text_too_long = [line for line in caption_text.split("\n") if len(line) > 32]
240
+ if caption_start in lines_too_long:
241
+ lines_too_long[caption_start] = text_too_long
242
+ else:
243
+ lines_too_long[caption_start].extend(text_too_long)
244
+
245
+ msg = ""
246
+ if bool(lines_too_long.keys()):
247
+ for key in lines_too_long:
248
+ if lines_too_long[key]:
249
+ msg += f"around {key} - "
250
+ for line in lines_too_long[key]:
251
+ msg += line + f" - Length { len(line)}" + "\n"
252
+ if len(msg):
245
253
  raise CaptionLineLengthError(
246
254
  f"32 character limit for caption cue in scc file.\n"
247
255
  f"Lines longer than 32:\n"
@@ -301,27 +309,21 @@ class SCCReader(BaseReader):
301
309
  self.time_translator.start_at(parts[0][0])
302
310
 
303
311
  # loop through each word
304
- words = [word.strip() for word in parts[0][2].split(' ') if len(word) == 4]
305
-
306
- for idx, word in enumerate(words):
307
- self._translate_word(word, words, idx)
308
-
309
- @staticmethod
310
- def get_command(commands, idx):
311
- try:
312
- return commands[idx]
313
- except IndexError:
314
- return None
315
-
316
- def _translate_word(self, word, words, idx):
317
- if self._skip_double_command(word, words, idx):
312
+ for word in parts[0][2].split(' '):
313
+ # ignore empty results or invalid commands
314
+ word = word.strip()
315
+ if len(word) == 4:
316
+ self._translate_word(word)
317
+
318
+ def _translate_word(self, word):
319
+ if self._handle_double_command(word):
318
320
  # count frames for timing
319
321
  self.time_translator.increment_frames()
320
322
  return
321
323
  # first check if word is a command
322
324
  # TODO - check that all the positioning commands are here, or use
323
325
  # some other strategy to determine if the word is a command.
324
- if word in COMMANDS or _is_pac_command(word) or word in PAC_TAB_OFFSET_COMMANDS:
326
+ if word in COMMANDS or _is_pac_command(word):
325
327
  self._translate_command(word)
326
328
 
327
329
  # second, check if word is a special character
@@ -338,39 +340,31 @@ class SCCReader(BaseReader):
338
340
  # count frames for timing only after processing a command
339
341
  self.time_translator.increment_frames()
340
342
 
341
- def _skip_double_command(self, word, words, idx):
343
+ def _handle_double_command(self, word):
342
344
  # If the caption is to be broadcast, each of the commands are doubled
343
345
  # up for redundancy in case the signal is garbled in transmission.
344
346
  # The decoder is programmed to ignore a second command when it is the
345
347
  # same as the first.
346
348
  # Also like codes, Special Characters are always doubled up,
347
349
  # with only one member of each pair being displayed.
348
- next_command = self.get_command(words, idx + 1)
349
- second_next = self.get_command(words, idx + 2)
350
-
351
350
  if word in COMMANDS or _is_pac_command(word) or word in SPECIAL_CHARS or word in EXTENDED_CHARS:
352
- # skip duplicates, execute the last occurrence if not a positioning command
353
- if word == self.last_command and not _is_pac_command(word):
354
- self.last_command = ''
355
- return True
356
- # skip consecutive positioning commands, execute the last one
357
- elif _is_pac_command(word) and _is_pac_command(next_command):
351
+ if word == self.last_command:
358
352
  self.last_command = ''
359
353
  return True
360
- # Fix for the <position> <tab offset> <position> <tab offset> repetition
361
- # execute the last positioning command
362
- elif _is_pac_command(word) and next_command in PAC_TAB_OFFSET_COMMANDS and _is_pac_command(second_next):
354
+ # Fix for the <position> <tab offset> <position> <tab offset>
355
+ # repetition
356
+ elif _is_pac_command(word) and word in self.last_command:
363
357
  self.last_command = ''
364
358
  return True
365
- # execute offset commands only if previous command is PAC and next is not PAC
366
359
  elif word in PAC_TAB_OFFSET_COMMANDS:
367
- if _is_pac_command(self.last_command) and not _is_pac_command(next_command):
368
- self.last_command = word
360
+ if _is_pac_command(self.last_command):
361
+ self.last_command += f" {word}"
369
362
  return False
370
363
  else:
371
364
  return True
372
- self.last_command = word
373
- return False
365
+
366
+ self.last_command = word
367
+ return False
374
368
 
375
369
  def _translate_special_char(self, word):
376
370
  self.buffer.add_chars(SPECIAL_CHARS[word])
@@ -1,5 +1,4 @@
1
1
  from itertools import product
2
- from collections import defaultdict
3
2
 
4
3
  COMMANDS = {
5
4
  '9420': '',
@@ -987,8 +986,6 @@ MICROSECONDS_PER_CODEWORD = 1000.0 * 1000.0 / (30.0 * 1000.0 / 1001.0)
987
986
 
988
987
  HEADER = 'Scenarist_SCC V1.0'
989
988
 
990
- UNHANDLED_COMMANDS = ["9120", "91ae", "912f", "91a1"]
991
-
992
989
  # taken from
993
990
  # http://www.theneitherworld.com/mcpoodle/SCC_TOOLS/DOCS/CC_CHARS.HTML
994
991
  INCONVERTIBLE_TO_ASCII_EXTENDED_CHARS_ASSOCIATION = {
@@ -1049,3 +1046,9 @@ INCONVERTIBLE_TO_ASCII_EXTENDED_CHARS_ASSOCIATION = {
1049
1046
  '└': ["+"],
1050
1047
  '┘': ["+"]
1051
1048
  }
1049
+
1050
+ MID_ROW_CODES = [
1051
+ "9120", "91a1", "91a2", "9123", "91a4", "9125", "9126",
1052
+ "91a7", "91a8", "9129", "912a", "91ab", "912c", "91ad",
1053
+ "97ae", "972f", "91ae", "912f", "94a8"
1054
+ ]
@@ -8,8 +8,8 @@ from ..geometry import (
8
8
  )
9
9
  from .constants import (
10
10
  PAC_BYTES_TO_POSITIONING_MAP, COMMANDS, PAC_TAB_OFFSET_COMMANDS,
11
- MICROSECONDS_PER_CODEWORD, UNHANDLED_COMMANDS,
12
- INCONVERTIBLE_TO_ASCII_EXTENDED_CHARS_ASSOCIATION
11
+ MICROSECONDS_PER_CODEWORD, INCONVERTIBLE_TO_ASCII_EXTENDED_CHARS_ASSOCIATION,
12
+ MID_ROW_CODES
13
13
  )
14
14
 
15
15
  PopOnCue = collections.namedtuple("PopOnCue", "buffer, start, end")
@@ -255,7 +255,7 @@ class CaptionCreator:
255
255
  layout_info = _get_layout_from_tuple(instruction.position)
256
256
  caption.nodes.append(
257
257
  CaptionNode.create_text(
258
- instruction.get_text(), layout_info=layout_info),
258
+ instruction.text, layout_info=layout_info),
259
259
  )
260
260
  caption.layout_info = layout_info
261
261
 
@@ -343,9 +343,16 @@ class InstructionNodeCreator:
343
343
 
344
344
  :type command: str
345
345
  """
346
- if command not in UNHANDLED_COMMANDS:
347
- self._update_positioning(command)
346
+ self._update_positioning(command)
347
+
348
348
  text = COMMANDS.get(command, '')
349
+
350
+ if command in MID_ROW_CODES:
351
+ for node in self._collection[::-1]:
352
+ if node.is_text_node():
353
+ node.text += ' '
354
+ break
355
+
349
356
  if 'italic' in text:
350
357
  if 'end' not in text:
351
358
  self._collection.append(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pycaption
3
- Version: 2.2.5
3
+ Version: 2.2.7
4
4
  Summary: Closed caption converter
5
5
  Author: Joe Norton
6
6
  Author-email: joey@nortoncrew.com
@@ -24,7 +24,7 @@ transcript_dependencies = [
24
24
 
25
25
  setup(
26
26
  name='pycaption',
27
- version='2.2.5',
27
+ version='2.2.7',
28
28
  description='Closed caption converter',
29
29
  long_description=open(README_PATH).read(),
30
30
  author='Joe Norton',
@@ -61,8 +61,6 @@ from tests.fixtures.scc import ( # noqa: F401
61
61
  sample_scc_duplicate_tab_offset, sample_scc_duplicate_special_characters,
62
62
  sample_scc_tab_offset, sample_scc_with_unknown_commands,
63
63
  sample_scc_special_and_extended_characters,
64
- sample_scc_with_consecutive_pac_commands,
65
- sample_scc_special_and_extended_characters,
66
64
  sample_scc_with_line_too_long
67
65
  )
68
66
  from tests.fixtures.srt import ( # noqa: F401
@@ -920,10 +920,10 @@ def sample_dfxp_from_scc_output():
920
920
  <region tts:displayAlign="before" tts:origin="40% 53%" tts:textAlign="left" xml:id="r5"/>
921
921
  <region tts:displayAlign="before" tts:origin="70% 17%" tts:textAlign="left" xml:id="r6"/>
922
922
  <region tts:displayAlign="before" tts:origin="20% 35%" tts:textAlign="left" xml:id="r7"/>
923
- <region tts:displayAlign="before" tts:origin="25% 83%" tts:textAlign="left" xml:id="r8"/>
923
+ <region tts:displayAlign="before" tts:origin="20% 83%" tts:textAlign="left" xml:id="r8"/>
924
924
  <region tts:displayAlign="before" tts:origin="70% 11%" tts:textAlign="left" xml:id="r9"/>
925
925
  <region tts:displayAlign="before" tts:origin="40% 41%" tts:textAlign="left" xml:id="r10"/>
926
- <region tts:displayAlign="before" tts:origin="25% 71%" tts:textAlign="left" xml:id="r11"/>
926
+ <region tts:displayAlign="before" tts:origin="20% 71%" tts:textAlign="left" xml:id="r11"/>
927
927
  </layout>
928
928
  </head>
929
929
  <body>
@@ -24,33 +24,6 @@ Scenarist_SCC V1.0
24
24
  """
25
25
 
26
26
 
27
- @pytest.fixture(scope="session")
28
- def sample_scc_with_consecutive_pac_commands():
29
- return """\
30
- Scenarist_SCC V1.0
31
-
32
- 00:00:00;15 942c
33
-
34
- 00:11:45;10 9420 94d0 94ce 5b20 cec1 5252 c154 4f52 205d 9470 946e cd4f cecb 45d9 d320 4c4f d645 2054 c849 cec7 d320 54c8 c154 2046 4cd9 ae80 942c 8080 8080 942f
35
-
36
- 00:11:47;28 9420 9454 9723 d9c1 d9a1 94f4 9723 5b20 c84f 4f54 49ce c720 5d80 942c 8080 8080 942f
37
-
38
- 00:11:50;08 9420 94d0 94ce 45d3 d045 4349 c14c 4cd9 2049 4620 54c8 45d9 a752 4520 54c8 4520 4fce 45d3 9470 946e 57c8 4f20 c745 5420 544f 2046 4cd9 2054 c845 cdae 942c 8080 8080 942f
39
-
40
- 00:11:54;06 942c
41
-
42
- 00:23:00;13 9420 1370 136e 5b20 43c8 494c c420 5d80 94d0 94ce c745 4f52 c745 20cd c1c4 4520 c120 cdc1 43c8 49ce 4580 9470 946e 464f 5220 c84f 5749 4520 544f 942c 8080 8080 942f
43
-
44
- 00:23:02;04 9420 91d0 91ce 544f 2046 49ce c420 43d5 5249 4fd5 d320 c745 4f52 c745 9170 916e c1ce c420 c849 d320 4652 4945 cec4 d380 92d0 92ce 45d6 4552 d920 c4c1 d920 4fce 4c49 ce45 2c80 942c 8080 8080 942f
45
-
46
- 00:23:05;00 9420 9152 91ae d357 49ce c720 c2d9 20d0 c2d3 cb49 c4d3 ae4f 52c7 9170 916e 544f 20d0 4cc1 d920 46d5 ce20 c7c1 cd45 d320 c1ce c420 57c1 5443 c880 92d0 9723 91ae d94f d552 2046 c1d6 4f52 4954 4520 d649 c445 4fd3 ae80 942c 8080 8080 942f
47
-
48
-
49
- 00:23:05;00 9420 9152 91ae d357 49ce c720 c2d9 20d0 c2d3 cb49 c4d3 ae4f 52c7 9170 916e 544f 20d0 4cc1 d920 46d5 ce20 c7c1 cd45 d320 c1ce c420 57c1 5443 c880 92d0 9723 91ae d94f d552 2046 c1d6 4f52 4954 4520 d649 c445 4fd3 ae80 942c 8080 8080 942f
50
-
51
- """
52
-
53
-
54
27
  @pytest.fixture(scope="session")
55
28
  def scc_that_generates_webvtt_with_proper_newlines():
56
29
  return """\
@@ -462,7 +435,7 @@ Scenarist_SCC V1.0
462
435
 
463
436
  00:00:00;03 942c
464
437
 
465
- 00:00:01;45 9420 91f4 cb45 4c4c d920 4ac1 cd45 d3ba 20c8 eff7 9254 f468 e520 7368 eff7d3ba 20c8 eff7 9254 f468 e520 7368 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 eff7 2073 f461 f2f4 e564 942c 8080 8080 942f
438
+ 00:00:01;45 9420 91f4 cb45 4c4c d920 4ac1 cd45 d3ba 20c8 eff7 9254 f468 e520 7368 eff7 2073 f461 f2f4 e564 942c 8080 8080 942f
466
439
 
467
440
  00:00:02;55 9420 91e0 9723 f761 7320 4361 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 ec20 c4e5 6ee9 73ef 6e2c 2061 20e6 f2e9 e56e 6480 9240 9723 efe6 20ef 75f2 732c 20f7 6173 2064 efe9 6e67 206d 7920 43c4 73ae 942c 8080 8080 942f
468
441
 
@@ -77,10 +77,10 @@ class TestSCCReader(ReaderTestingMixIn):
77
77
  ((40.0, UnitEnum.PERCENT), (53.0, UnitEnum.PERCENT)),
78
78
  ((70.0, UnitEnum.PERCENT), (17.0, UnitEnum.PERCENT)),
79
79
  ((20.0, UnitEnum.PERCENT), (35.0, UnitEnum.PERCENT)),
80
- ((25.0, UnitEnum.PERCENT), (83.0, UnitEnum.PERCENT)),
80
+ ((20.0, UnitEnum.PERCENT), (83.0, UnitEnum.PERCENT)),
81
81
  ((70.0, UnitEnum.PERCENT), (11.0, UnitEnum.PERCENT)),
82
82
  ((40.0, UnitEnum.PERCENT), (41.0, UnitEnum.PERCENT)),
83
- ((25.0, UnitEnum.PERCENT), (71.0, UnitEnum.PERCENT))
83
+ ((20.0, UnitEnum.PERCENT), (71.0, UnitEnum.PERCENT))
84
84
  ]
85
85
 
86
86
  actual_positioning = [
@@ -206,10 +206,10 @@ class TestSCCReader(ReaderTestingMixIn):
206
206
 
207
207
  def test_skip_duplicate_tab_offset(self, sample_scc_duplicate_tab_offset):
208
208
  expected_lines = [
209
- '[Radio reporter]',
210
- 'The I-10 Santa Monica Freeway',
209
+ '[Radio reporter] ',
210
+ 'The I-10 Santa Monica Freeway ',
211
211
  'westbound is jammed,',
212
- 'due to a three-car accident',
212
+ 'due to a three-car accident ',
213
213
  'blocking lanes 1 and 2',
214
214
  ]
215
215
 
@@ -244,46 +244,15 @@ class TestSCCReader(ReaderTestingMixIn):
244
244
  assert exc_info.value.args[0].startswith(
245
245
  "Unsupported cue duration around 00:00:20.433")
246
246
 
247
- def test_skip_first_pac_command(self, sample_scc_with_consecutive_pac_commands):
248
- caption_set = SCCReader().read(sample_scc_with_consecutive_pac_commands)
249
- caption = caption_set.get_captions('en-US')
250
- actual_lines = [
251
- node.content
252
- for cap_ in caption
253
- for node in cap_.nodes
254
- if node.type_ == CaptionNode.TEXT
255
- ]
256
- expected_lines = [
257
- '[ NARRATOR ]',
258
- 'MONKEYS LOVE THINGS THAT FLY.',
259
- 'YAY!',
260
- '[ HOOTING ]',
261
- "ESPECIALLY IF THEY'RE THE ONES",
262
- 'WHO GET TO FLY THEM.',
263
- '[ CHILD ]',
264
- 'GEORGE MADE A MACHINE',
265
- 'FOR HOWIE TO',
266
- 'TO FIND CURIOUS GEORGE',
267
- 'AND HIS FRIENDS',
268
- 'EVERY DAY ONLINE,',
269
- 'SWING BY PBSKIDS.ORG',
270
- 'TO PLAY FUN GAMES AND WATCH',
271
- 'YOUR FAVORITE VIDEOS.',
272
- 'SWING BY PBSKIDS.ORG',
273
- 'TO PLAY FUN GAMES AND WATCH',
274
- 'YOUR FAVORITE VIDEOS.'
275
- ]
276
- # is not breaking the lines
277
- assert expected_lines == actual_lines
278
-
279
247
  def test_line_too_long(self, sample_scc_with_line_too_long):
280
248
  with pytest.raises(CaptionLineLengthError) as exc_info:
281
249
  SCCReader().read(sample_scc_with_line_too_long)
282
250
 
283
251
  assert exc_info.value.args[0].startswith(
284
252
  "32 character limit for caption cue in scc file.")
285
- assert ("was Cal l l l l l l l l l l l l l l l l l l l l l l l l l l l l Denison, a friend - Length 81"
286
- in exc_info.value.args[0].split("\n"))
253
+ str_to_check = ("around 00:00:05.900 - was Cal l l l l l l l l l l l l l l l l l l l l l l l l l l l l "
254
+ "Denison, a friend - Length 81")
255
+ assert str_to_check in exc_info.value.args[0].split("\n")
287
256
 
288
257
 
289
258
  class TestCoverageOnly:
@@ -377,6 +346,7 @@ class TestCoverageOnly:
377
346
  ]
378
347
 
379
348
  actual_timings = [(c_.start, c_.end) for c_ in captions]
349
+
380
350
  assert expected_timings == actual_timings
381
351
 
382
352
  def test_freeze_colon_spec_time(self, sample_scc_pop_on):
@@ -615,4 +585,4 @@ class TestTimingCorrectingCaptionList:
615
585
  # just one caption, first EOC disappears
616
586
  num_captions = len(caption_set.get_captions('en-US'))
617
587
 
618
- assert num_captions == 1
588
+ assert num_captions == 2
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes