pycaption 2.3.0__tar.gz → 2.3.1__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.
- {pycaption-2.3.0/pycaption.egg-info → pycaption-2.3.1}/PKG-INFO +1 -1
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/sami/writer.py +8 -7
- {pycaption-2.3.0 → pycaption-2.3.1/pycaption.egg-info}/PKG-INFO +1 -1
- {pycaption-2.3.0 → pycaption-2.3.1}/setup.py +1 -1
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_sami_conversion.py +16 -1
- {pycaption-2.3.0 → pycaption-2.3.1}/LICENSE +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/MANIFEST.in +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/README.rst +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/__init__.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/base.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/dfxp/__init__.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/dfxp/constants.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/dfxp/extras.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/dfxp/reader.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/dfxp/writer.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/exceptions.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/geometry.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/microdvd.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/sami/__init__.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/sami/constants.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/sami/parser.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/sami/reader.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/scc/__init__.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/scc/constants.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/scc/reader.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/scc/specialized_collections.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/scc/state_machines.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/scc/translator.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/scc/writer.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/srt.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/transcript.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/utils.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/webvtt/__init__.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/webvtt/constants.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/webvtt/reader.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption/webvtt/writer.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption.egg-info/SOURCES.txt +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption.egg-info/dependency_links.txt +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption.egg-info/requires.txt +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/pycaption.egg-info/top_level.txt +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/setup.cfg +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/__init__.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/conftest.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/fixtures/__init__.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/fixtures/dfxp.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/fixtures/microdvd.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/fixtures/sami.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/fixtures/scc.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/fixtures/srt.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/fixtures/translated_scc.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/fixtures/webvtt.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/mixins.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_base.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_dfxp.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_dfxp_conversion.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_dfxp_extras.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_functions.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_geometry.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_microdvd.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_microdvd_conversion.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_sami.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_scc.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_scc_conversion.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_scc_translator.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_scc_writer.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_srt.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_srt_conversion.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_webvtt.py +0 -0
- {pycaption-2.3.0 → pycaption-2.3.1}/tests/test_webvtt_conversion.py +0 -0
|
@@ -76,12 +76,12 @@ class SAMIWriter(BaseWriter):
|
|
|
76
76
|
|
|
77
77
|
def _recreate_p_tag(self, caption, sami, lang, primary, captions):
|
|
78
78
|
"""Build a <sync><p> block for a single caption with styling and alignment."""
|
|
79
|
-
time = caption.start // 1000
|
|
79
|
+
time = int(caption.start // 1000)
|
|
80
80
|
|
|
81
81
|
if self.last_time and time != self.last_time:
|
|
82
82
|
sami = self._recreate_blank_tag(sami, caption, lang, primary, captions)
|
|
83
83
|
|
|
84
|
-
self.last_time = caption.end // 1000
|
|
84
|
+
self.last_time = int(caption.end // 1000)
|
|
85
85
|
|
|
86
86
|
sami, sync = self._recreate_sync(sami, lang, primary, time)
|
|
87
87
|
|
|
@@ -92,11 +92,12 @@ class SAMIWriter(BaseWriter):
|
|
|
92
92
|
p_style += f"{attr}:{value};"
|
|
93
93
|
|
|
94
94
|
if caption.layout_info and caption.layout_info.alignment:
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
95
|
+
if not caption.layout_info.origin:
|
|
96
|
+
h = caption.layout_info.alignment.horizontal
|
|
97
|
+
if h:
|
|
98
|
+
css_align = HORIZONTAL_ALIGNMENT_MAP.get(h)
|
|
99
|
+
if css_align:
|
|
100
|
+
p_style += f"text-align:{css_align};"
|
|
100
101
|
|
|
101
102
|
if p_style:
|
|
102
103
|
p["style"] = p_style
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
from pycaption import
|
|
1
|
+
from pycaption import (
|
|
2
|
+
DFXPReader,
|
|
3
|
+
SAMIReader,
|
|
4
|
+
SAMIWriter,
|
|
5
|
+
SCCReader,
|
|
6
|
+
SRTReader,
|
|
7
|
+
WebVTTReader,
|
|
8
|
+
)
|
|
2
9
|
|
|
3
10
|
from .mixins import SAMITestingMixIn
|
|
4
11
|
|
|
@@ -199,3 +206,11 @@ class TestWebVTTtoSAMIStyles(SAMITestingMixIn):
|
|
|
199
206
|
assert ".blue" in result
|
|
200
207
|
assert 'class="red"' in result
|
|
201
208
|
assert 'class="blue"' in result
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
class TestSCCtoSAMI(SAMITestingMixIn):
|
|
212
|
+
def test_scc_to_sami_no_text_align(self, sample_scc_pop_on):
|
|
213
|
+
caption_set = SCCReader().read(sample_scc_pop_on)
|
|
214
|
+
result = SAMIWriter().write(caption_set)
|
|
215
|
+
|
|
216
|
+
assert "text-align" not in result
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|