threefive3 3.0.13__tar.gz → 3.0.16__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 (36) hide show
  1. {threefive3-3.0.13/threefive3.egg-info → threefive3-3.0.16}/PKG-INFO +65 -43
  2. {threefive3-3.0.13 → threefive3-3.0.16}/README.md +64 -39
  3. {threefive3-3.0.13 → threefive3-3.0.16}/bin/threefive3 +3 -2
  4. {threefive3-3.0.13 → threefive3-3.0.16}/setup.py +0 -2
  5. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/__init__.py +19 -0
  6. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/base.py +15 -19
  7. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/bitn.py +4 -4
  8. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/commands.py +4 -3
  9. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/cue.py +34 -8
  10. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/descriptors.py +11 -7
  11. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/hls.py +7 -7
  12. threefive3-3.0.16/threefive3/m3ufu.py +663 -0
  13. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/section.py +15 -14
  14. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/stream.py +24 -29
  15. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/sxp.py +15 -4
  16. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/upids.py +4 -4
  17. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/version.py +1 -1
  18. {threefive3-3.0.13 → threefive3-3.0.16/threefive3.egg-info}/PKG-INFO +65 -43
  19. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3.egg-info/SOURCES.txt +1 -0
  20. threefive3-3.0.16/threefive3.egg-info/requires.txt +1 -0
  21. threefive3-3.0.13/threefive3.egg-info/requires.txt +0 -3
  22. {threefive3-3.0.13 → threefive3-3.0.16}/LICENSE +0 -0
  23. {threefive3-3.0.13 → threefive3-3.0.16}/setup.cfg +0 -0
  24. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/crc.py +0 -0
  25. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/iframes.py +0 -0
  26. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/new_reader.py +0 -0
  27. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/packetdata.py +0 -0
  28. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/segment.py +0 -0
  29. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/segmentation.py +0 -0
  30. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/sixfix.py +0 -0
  31. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/spare.py +0 -0
  32. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/streamtypes.py +0 -0
  33. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/x2c.py +0 -0
  34. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3/xml.py +0 -0
  35. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3.egg-info/dependency_links.txt +0 -0
  36. {threefive3-3.0.13 → threefive3-3.0.16}/threefive3.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: threefive3
3
- Version: 3.0.13
3
+ Version: 3.0.16
4
4
  Summary: threefive continued.
5
5
  Home-page: https://github.com/superkabuki/scte35
6
6
  Author: Adrian of Doom
@@ -18,57 +18,43 @@ Classifier: Programming Language :: Python :: Implementation :: CPython
18
18
  Requires-Python: >=3.6
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
- Requires-Dist: m3ufu>=0.0.89
22
- Requires-Dist: sideways>=0.0.23
23
- Requires-Dist: pyaes
24
21
 
25
- [Install](#install) |[SCTE-35 Cli](#the-cli-tool) |[SCTE-35 Xml ](https://github.com/superkabuki/threefive3/blob/main/xml.md) | [Cue Class](https://github.com/superkabuki/threefive3/blob/main/cue.md) | [Stream Class](https://github.com/superkabuki/threefive3/blob/main/stream.md) | [Online SCTE-35 Parser](https://iodisco.com/scte35) | [Encode SCTE-35](https://github.com/superkabuki/threefive3/blob/main/encode.md)
22
+ # threefive3 SCTE-35 cli tool and python3 library.
26
23
 
24
+ ✅ SCTE-35 Parser ✅ SCTE-35 Encoder ✅ SCTE-35 HLS ✅ SCTE-35 Xml ✅ SCTE-35 Cli ✅ SCTE-35 library
27
25
 
28
- # threefive3
29
- SCTE-35 Parser ✅
30
- SCTE-35 Encoder ✅
31
- SCTE-35 HLS ✅
32
- SCTE-35 Xml ✅
33
- SCTE-35 Cli ✅
34
- SCTE-35 library ✅
35
- <br>
36
- <br>
37
- # What people are saying about threefive3:
38
26
 
39
- <br>
40
-
41
- _I was satisfied with everything, only a linear entrance of.... there was a bomb with him._ ~ __Suzy in Swanee__
42
- <br>
43
- ___
44
- _A little bigger than i thought, but lighter._ ~ __Bob in Buford__
45
- <br>
46
- ___
47
- _Class! I choked very much, took it for the dacha, as an easily transported option, the sound was just hurt! And generally listen to music. Perfectly pumps speakers from ancient muses. Center Sony! Without distortion, background noise, detailed sound. In short, who does not need highend much, so I recommend it!_
48
- ~ __Larry in Lawrenceville__
49
- <br>
50
- ___
51
- _It's good, it's good. It's good. It's good. It's good. It's good. It's good. It's good. It's good. It's good_
52
- ~ __Connie in Columbia__
53
- <br>
27
+ * Parses SCTE-35 from MPEGTS, HLS, XML, XML+Binary, Base64, Bytes, Hex, and Integers.
28
+ * Built-in network support for http(s), UDP, and Multicast.
29
+ * Automatic AES decryption for HLS.
30
+ * All HLS SCTE-35 Tags are Supported
54
31
  ___
32
+ * [Install](#install)
33
+ * [SCTE-35 Cli](#the-cli-tool)
34
+ * [SCTE-35 Xml ](https://github.com/superkabuki/threefive3/blob/main/xml.md)
35
+ * [Cue Class](https://github.com/superkabuki/threefive3/blob/main/cue.md)
36
+ * [Stream Class](https://github.com/superkabuki/threefive3/blob/main/stream.md)
37
+ * [Online SCTE-35 Parser](https://iodisco.com/scte35)
38
+ * [Encode SCTE-35](https://github.com/superkabuki/threefive3/blob/main/encode.md)
39
+ * [FFmpeg SCTE35](https://github.com/superkabuki/FFmpeg_SCTE35)
40
+
41
+ ## MPEGTS streams can be parsed for SCTE-35 with three lines of code.
55
42
 
56
- # FAQ
57
- * Q. What is the latest version?
43
+ ```py3
44
+ a@fu:~/build5/scte35/scte35$ pypy3
45
+ Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
46
+ [PyPy 7.3.11 with GCC 12.2.0] on linux
47
+ Type "help", "copyright", "credits" or "license" for more information.
58
48
 
59
- * A. `v3.0.13`
60
- ---
61
- * Q. How do I upgrade my code from threefive to the __more powerful super advanced threefive3?__
49
+ >>>> from threefive import Stream
62
50
 
63
- * A. `sed.`
64
- ```js
65
- sed -i 's/threefive/threefive3/g'
51
+ >>>> strm=Stream('https://futzu.com/xaa.ts')
52
+
53
+ >>>> strm.decode()
66
54
  ```
67
- ---
68
- * Q. Does threefive3 have super cool new features?
69
55
 
70
- * A. `Yes.`
71
- ---
56
+ ___
57
+
72
58
 
73
59
  # `Install`
74
60
  * python3 via pip
@@ -87,8 +73,9 @@ make install
87
73
  ```
88
74
  ___
89
75
 
76
+
90
77
  # `The Cli tool`
91
- > The cli polls stdin and that allows it to autodetect the SCTE-35 format as well as MPEGTS steams. Now every SCTE-35 data format, except hls, is autodetected on the commandline, as well as stdin.<br>HLS requires the `hls` ketyword.
78
+
92
79
 
93
80
  ### The cli tool installs automatically with pip or the Makefile.
94
81
 
@@ -106,6 +93,28 @@ ___
106
93
  * __stdin__ is __auto selected__ and __auto detected.__
107
94
  * __SCTE-35 data is printed to stderr__
108
95
  * __stdout is used when piping video__
96
+ * mpegts can be specified by file name or URI.
97
+ ```rebol
98
+ threefive3 udp://@235.2.5.35:3535
99
+ ```
100
+ * If a file comtains a SCTE-35 Cue as a string( base64,hex,int,json,xml or xml+bin), redirect the file contents.
101
+ ```rebol
102
+
103
+ threefive3 < json.json
104
+
105
+ threefive3 < xml.xml
106
+
107
+ cat xml.xml | threefive3
108
+ ```
109
+
110
+ * quoted strings(( base64,hex,int,json,xml or xml+bin), can be passed directly on the command line as well.
111
+
112
+ ```awk
113
+
114
+ threefive3 '/DAWAAAAAAAAAP/wBQb+ztd7owAAdIbbmw=='
115
+
116
+ ```
117
+
109
118
 
110
119
  | Input Type | Cli Example |
111
120
  |------------|-------------------------------------------------------------------------------------------------------------|
@@ -214,7 +223,20 @@ ___
214
223
  ```rebol
215
224
  threefive3 help
216
225
  ```
226
+ ___
227
+
228
+ ![image](https://github.com/user-attachments/assets/91fd37c2-746c-498d-8c6c-80c6e7760c0e)
229
+
230
+ ___
231
+
217
232
  ## [iodisco.com/scte35](https://iodisco.com/scte35)
218
233
  ![image](https://github.com/user-attachments/assets/4df85c44-a078-4da0-97e2-5daefcf2509d)
219
234
 
220
235
 
236
+
237
+ ___
238
+
239
+ [Install](#install) |[SCTE-35 Cli](#the-cli-tool) |[SCTE-35 Xml ](https://github.com/superkabuki/threefive3/blob/main/xml.md) | [Cue Class](https://github.com/superkabuki/threefive3/blob/main/cue.md) | [Stream Class](https://github.com/superkabuki/threefive3/blob/main/stream.md) | [Online SCTE-35 Parser](https://iodisco.com/scte35) | [Encode SCTE-35](https://github.com/superkabuki/threefive3/blob/main/encode.md) [FFmpeg SCTE35](https://github.com/superkabuki/FFmpeg_SCTE35)
240
+
241
+
242
+
@@ -1,50 +1,39 @@
1
- [Install](#install) |[SCTE-35 Cli](#the-cli-tool) |[SCTE-35 Xml ](https://github.com/superkabuki/threefive3/blob/main/xml.md) | [Cue Class](https://github.com/superkabuki/threefive3/blob/main/cue.md) | [Stream Class](https://github.com/superkabuki/threefive3/blob/main/stream.md) | [Online SCTE-35 Parser](https://iodisco.com/scte35) | [Encode SCTE-35](https://github.com/superkabuki/threefive3/blob/main/encode.md)
1
+ # threefive3 SCTE-35 cli tool and python3 library.
2
2
 
3
+ ✅ SCTE-35 Parser ✅ SCTE-35 Encoder ✅ SCTE-35 HLS ✅ SCTE-35 Xml ✅ SCTE-35 Cli ✅ SCTE-35 library
3
4
 
4
- # threefive3
5
- SCTE-35 Parser ✅
6
- SCTE-35 Encoder ✅
7
- SCTE-35 HLS ✅
8
- SCTE-35 Xml ✅
9
- SCTE-35 Cli ✅
10
- SCTE-35 library ✅
11
- <br>
12
- <br>
13
- # What people are saying about threefive3:
14
5
 
15
- <br>
16
-
17
- _I was satisfied with everything, only a linear entrance of.... there was a bomb with him._ ~ __Suzy in Swanee__
18
- <br>
19
- ___
20
- _A little bigger than i thought, but lighter._ ~ __Bob in Buford__
21
- <br>
22
- ___
23
- _Class! I choked very much, took it for the dacha, as an easily transported option, the sound was just hurt! And generally listen to music. Perfectly pumps speakers from ancient muses. Center Sony! Without distortion, background noise, detailed sound. In short, who does not need highend much, so I recommend it!_
24
- ~ __Larry in Lawrenceville__
25
- <br>
26
- ___
27
- _It's good, it's good. It's good. It's good. It's good. It's good. It's good. It's good. It's good. It's good_
28
- ~ __Connie in Columbia__
29
- <br>
6
+ * Parses SCTE-35 from MPEGTS, HLS, XML, XML+Binary, Base64, Bytes, Hex, and Integers.
7
+ * Built-in network support for http(s), UDP, and Multicast.
8
+ * Automatic AES decryption for HLS.
9
+ * All HLS SCTE-35 Tags are Supported
30
10
  ___
11
+ * [Install](#install)
12
+ * [SCTE-35 Cli](#the-cli-tool)
13
+ * [SCTE-35 Xml ](https://github.com/superkabuki/threefive3/blob/main/xml.md)
14
+ * [Cue Class](https://github.com/superkabuki/threefive3/blob/main/cue.md)
15
+ * [Stream Class](https://github.com/superkabuki/threefive3/blob/main/stream.md)
16
+ * [Online SCTE-35 Parser](https://iodisco.com/scte35)
17
+ * [Encode SCTE-35](https://github.com/superkabuki/threefive3/blob/main/encode.md)
18
+ * [FFmpeg SCTE35](https://github.com/superkabuki/FFmpeg_SCTE35)
19
+
20
+ ## MPEGTS streams can be parsed for SCTE-35 with three lines of code.
31
21
 
32
- # FAQ
33
- * Q. What is the latest version?
22
+ ```py3
23
+ a@fu:~/build5/scte35/scte35$ pypy3
24
+ Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
25
+ [PyPy 7.3.11 with GCC 12.2.0] on linux
26
+ Type "help", "copyright", "credits" or "license" for more information.
34
27
 
35
- * A. `v3.0.13`
36
- ---
37
- * Q. How do I upgrade my code from threefive to the __more powerful super advanced threefive3?__
28
+ >>>> from threefive import Stream
38
29
 
39
- * A. `sed.`
40
- ```js
41
- sed -i 's/threefive/threefive3/g'
30
+ >>>> strm=Stream('https://futzu.com/xaa.ts')
31
+
32
+ >>>> strm.decode()
42
33
  ```
43
- ---
44
- * Q. Does threefive3 have super cool new features?
45
34
 
46
- * A. `Yes.`
47
- ---
35
+ ___
36
+
48
37
 
49
38
  # `Install`
50
39
  * python3 via pip
@@ -63,8 +52,9 @@ make install
63
52
  ```
64
53
  ___
65
54
 
55
+
66
56
  # `The Cli tool`
67
- > The cli polls stdin and that allows it to autodetect the SCTE-35 format as well as MPEGTS steams. Now every SCTE-35 data format, except hls, is autodetected on the commandline, as well as stdin.<br>HLS requires the `hls` ketyword.
57
+
68
58
 
69
59
  ### The cli tool installs automatically with pip or the Makefile.
70
60
 
@@ -82,6 +72,28 @@ ___
82
72
  * __stdin__ is __auto selected__ and __auto detected.__
83
73
  * __SCTE-35 data is printed to stderr__
84
74
  * __stdout is used when piping video__
75
+ * mpegts can be specified by file name or URI.
76
+ ```rebol
77
+ threefive3 udp://@235.2.5.35:3535
78
+ ```
79
+ * If a file comtains a SCTE-35 Cue as a string( base64,hex,int,json,xml or xml+bin), redirect the file contents.
80
+ ```rebol
81
+
82
+ threefive3 < json.json
83
+
84
+ threefive3 < xml.xml
85
+
86
+ cat xml.xml | threefive3
87
+ ```
88
+
89
+ * quoted strings(( base64,hex,int,json,xml or xml+bin), can be passed directly on the command line as well.
90
+
91
+ ```awk
92
+
93
+ threefive3 '/DAWAAAAAAAAAP/wBQb+ztd7owAAdIbbmw=='
94
+
95
+ ```
96
+
85
97
 
86
98
  | Input Type | Cli Example |
87
99
  |------------|-------------------------------------------------------------------------------------------------------------|
@@ -190,7 +202,20 @@ ___
190
202
  ```rebol
191
203
  threefive3 help
192
204
  ```
205
+ ___
206
+
207
+ ![image](https://github.com/user-attachments/assets/91fd37c2-746c-498d-8c6c-80c6e7760c0e)
208
+
209
+ ___
210
+
193
211
  ## [iodisco.com/scte35](https://iodisco.com/scte35)
194
212
  ![image](https://github.com/user-attachments/assets/4df85c44-a078-4da0-97e2-5daefcf2509d)
195
213
 
196
214
 
215
+
216
+ ___
217
+
218
+ [Install](#install) |[SCTE-35 Cli](#the-cli-tool) |[SCTE-35 Xml ](https://github.com/superkabuki/threefive3/blob/main/xml.md) | [Cue Class](https://github.com/superkabuki/threefive3/blob/main/cue.md) | [Stream Class](https://github.com/superkabuki/threefive3/blob/main/stream.md) | [Online SCTE-35 Parser](https://iodisco.com/scte35) | [Encode SCTE-35](https://github.com/superkabuki/threefive3/blob/main/encode.md) [FFmpeg SCTE35](https://github.com/superkabuki/FFmpeg_SCTE35)
219
+
220
+
221
+
@@ -225,6 +225,7 @@ def chk_mpegts_map():
225
225
  for key in m_keys:
226
226
  if key in sys.argv:
227
227
  for arg in args:
228
+ print2(arg)
228
229
  mpegts_map[key](arg)
229
230
  sys.exit()
230
231
 
@@ -320,7 +321,7 @@ def to_funk(this):
320
321
  try:
321
322
  cue = Cue(this)
322
323
  except:
323
- print2("Bad Data")
324
+ print2(f"Bad Data:\n{this}")
324
325
  sys.exit()
325
326
  if cue:
326
327
  funk()(cue) # func works here too.
@@ -342,7 +343,7 @@ def chk_stdin(args):
342
343
  strm = Stream(sys.stdin.buffer)
343
344
  strm._parse(one + two) # dont drop first packet
344
345
  strm.decode(func=funk())
345
- sys.exit() # I keep forgetting why I do
346
+ sys.exit() # I keep forgetting why I do
346
347
  return args
347
348
 
348
349
 
@@ -18,8 +18,6 @@ setuptools.setup(
18
18
  long_description_content_type="text/markdown",
19
19
  url="https://github.com/superkabuki/scte35",
20
20
  install_requires=[
21
- 'm3ufu >= 0.0.89',
22
- 'sideways >= 0.0.23',
23
21
  "pyaes",
24
22
  ],
25
23
 
@@ -3,6 +3,7 @@ scte35.__init__.py
3
3
  """
4
4
 
5
5
  from .spare import print2
6
+
6
7
  from .cue import Cue
7
8
  from .section import SpliceInfoSection
8
9
  from .segment import Segment
@@ -10,18 +11,36 @@ from .stream import Stream
10
11
  from .version import version
11
12
 
12
13
  from .commands import (
14
+ SpliceCommand,
13
15
  TimeSignal,
14
16
  SpliceInsert,
15
17
  SpliceNull,
16
18
  PrivateCommand,
17
19
  BandwidthReservation,
20
+ command_map,
18
21
  )
19
22
 
20
23
  from .descriptors import (
24
+ k_by_v,
21
25
  AvailDescriptor,
22
26
  DVBDASDescriptor,
23
27
  DtmfDescriptor,
24
28
  SegmentationDescriptor,
25
29
  SpliceDescriptor,
26
30
  TimeDescriptor,
31
+ descriptor_map,
32
+
27
33
  )
34
+
35
+ from .upids import(
36
+ Upid,
37
+ NoUpid,
38
+ AirId,
39
+ Atsc,
40
+ Eidr,
41
+ Isan,
42
+ Mid,
43
+ Mpu,
44
+ Umid,
45
+ upid_map,
46
+ )
@@ -17,6 +17,9 @@ class SCTE35Base:
17
17
 
18
18
  ROLLOVER = 8589934591
19
19
 
20
+ def __init__(self):
21
+ self.errors=[]
22
+
20
23
  def __repr__(self):
21
24
  return str(self.__dict__)
22
25
 
@@ -27,8 +30,9 @@ class SCTE35Base:
27
30
  return nbin
28
31
 
29
32
  def _err2(self, var_name, var_value, bit_count, var_type):
30
- err_mesg = f"\033[1;41m !! \033[0m \033[1;41m {var_name}\033[0m is \033[1;41m {var_value} \033[0m, it should be type {var_type} of {bit_count} bit(s)\n "
31
- print2(err_mesg)
33
+ var_type = str(var_type).split("'")[1]
34
+ err_mesg = f'{var_name} is {var_value} , it should be type {var_type}, {bit_count} bit(s) long.'
35
+ self.errors.append(err_mesg)
32
36
 
33
37
  def _bool_int(self, var_name, var_value, bit_count, var_type):
34
38
  if var_type == int:
@@ -100,16 +104,9 @@ class SCTE35Base:
100
104
  def has(self, what):
101
105
  """
102
106
  has runs hasattr with self and what
107
+ returns value if set.
103
108
  """
104
109
  if hasattr(self, what):
105
- return True
106
- return False
107
-
108
- def hasis(self, what):
109
- """
110
- hasis obj "has" a what and what "is" returned.
111
- """
112
- if self.has(what):
113
110
  return vars(self)[what]
114
111
  return None
115
112
 
@@ -149,25 +146,24 @@ class SCTE35Base:
149
146
  val = list(val)
150
147
  return val
151
148
 
152
- return {k: b2l(v) for k, v in vars(self).items() if v is not None}
149
+ return {k: b2l(v) for k, v in vars(self).items() if v not in [None,[],] } # added empty list []
153
150
 
154
- def _load_str(self, gonzo):
151
+ def _json2dict(self, gonzo):
155
152
  if isinstance(gonzo, str):
156
153
  gonzo = json.loads(gonzo)
157
154
  return gonzo
158
155
 
159
- def _chk_prevars(self, k, v, prevars):
160
- if k in prevars:
156
+ def _chk_vars(self, k, v):
157
+ if k in vars(self):
161
158
  self.__dict__[k] = v
162
159
 
163
- def _vrfy_load(self, gonzo, prevars):
160
+ def _vrfy_load(self, gonzo):
164
161
  for k, v in gonzo.items():
165
- self._chk_prevars(k, v, prevars)
162
+ self._chk_vars(k, v)
166
163
 
167
164
  def _load_dict(self, gonzo):
168
165
  if isinstance(gonzo, dict):
169
- prevars = vars(self)
170
- self._vrfy_load(gonzo, prevars)
166
+ self._vrfy_load(gonzo)
171
167
 
172
168
  def load(self, gonzo):
173
169
  """
@@ -175,7 +171,7 @@ class SCTE35Base:
175
171
  data from a dict or json string.
176
172
  only updates vars that exist in the obj.
177
173
  """
178
- gonzo = self._load_str(gonzo)
174
+ gonzo = self._json2dict(gonzo)
179
175
  self._load_dict(gonzo)
180
176
 
181
177
  def show(self):
@@ -1,11 +1,11 @@
1
1
  """
2
- The bitn.BitBin and bitn.NBin classes
2
+ The bitn.Bitn and bitn.NBin classes
3
3
  """
4
4
 
5
5
  from .spare import print2
6
6
 
7
7
 
8
- class BitBin:
8
+ class Bitn:
9
9
  """
10
10
  bitn.Bitbin takes a byte string and
11
11
  converts it to a integer, a very large integer
@@ -19,7 +19,7 @@ class BitBin:
19
19
  self.bits = int.from_bytes(bites, byteorder="big")
20
20
 
21
21
  def __repr__(self):
22
- return str(vars(self))
22
+ return str(vars(self))
23
23
 
24
24
  def as_90k(self, num_bits):
25
25
  """
@@ -96,7 +96,7 @@ class BitBin:
96
96
  class NBin:
97
97
  """
98
98
  bitn.NBin is
99
- the reverse BitBin.
99
+ the reverse Bitn.
100
100
  Encodes data to integers
101
101
  and then bytes
102
102
  """
@@ -2,7 +2,7 @@
2
2
  SCTE35 Splice Commands
3
3
  """
4
4
 
5
- from .bitn import BitBin
5
+ from .bitn import Bitn
6
6
  from .base import SCTE35Base
7
7
  from .xml import Node
8
8
 
@@ -13,6 +13,7 @@ class SpliceCommand(SCTE35Base):
13
13
  """
14
14
 
15
15
  def __init__(self, bites=None):
16
+ super().__init__()
16
17
  self.command_length = 0
17
18
  self.command_type = None
18
19
  self.name = None
@@ -130,7 +131,7 @@ class TimeSignal(SpliceCommand):
130
131
  """
131
132
  TimeSignal.decode method
132
133
  """
133
- bitbin = BitBin(self.bites)
134
+ bitbin = Bitn(self.bites)
134
135
  start = bitbin.idx
135
136
  self._splice_time(bitbin)
136
137
  self._set_len(start, bitbin.idx)
@@ -224,7 +225,7 @@ class SpliceInsert(TimeSignal):
224
225
  """
225
226
  decode SpliceInsert
226
227
  """
227
- bitbin = BitBin(self.bites)
228
+ bitbin = Bitn(self.bites)
228
229
  start = bitbin.idx
229
230
  self.splice_event_id = bitbin.as_int(32)
230
231
  self.splice_event_cancel_indicator = bitbin.as_flag(1)
@@ -8,7 +8,7 @@ from .spare import print2
8
8
  from .bitn import NBin
9
9
  from .base import SCTE35Base
10
10
  from .section import SpliceInfoSection
11
- from .commands import command_map
11
+ from .commands import command_map, SpliceCommand
12
12
  from .descriptors import splice_descriptor, descriptor_map
13
13
  from .crc import crc32
14
14
  from .xml import Node
@@ -47,18 +47,33 @@ class Cue(SCTE35Base):
47
47
  data may be packet bites or encoded string
48
48
  packet_data is a instance passed from a Stream instance
49
49
  """
50
+ self.errors=[]
50
51
  self.command = None
51
52
  self.descriptors = []
52
53
  self.info_section = SpliceInfoSection()
53
54
  self.bites = None
54
55
  if data:
55
56
  self.bites = self._mk_bits(data)
57
+ self.decode()
56
58
  self.packet_data = packet_data
57
59
  self.dash_data = None
60
+ self.decode()
58
61
 
59
62
  def __repr__(self):
60
63
  return str(self.__dict__)
61
64
 
65
+ def errs(self):
66
+ """
67
+ errs show encoding errors.
68
+ """
69
+ e= {"cue.errors": self.errors}
70
+ if self.info_section:
71
+ e["info_section_errors"] = self.info_section.has("errors")
72
+ if isinstance(self.command, SpliceCommand):
73
+ e["command_errors"]= self.command.errors
74
+ e["descriptor_errors"] = [d.errors for d in self.descriptors]
75
+ return e
76
+
62
77
  def decode(self):
63
78
  """
64
79
  Cue.decode() parses for SCTE35 data
@@ -116,6 +131,7 @@ class Cue(SCTE35Base):
116
131
  scte35_data = self._get_dash_data(scte35_data)
117
132
  scte35_data = self._get_packet_data(scte35_data)
118
133
  return scte35_data
134
+ self.errors.append("command or info section not found")
119
135
  return False
120
136
 
121
137
  def get_descriptors(self):
@@ -131,11 +147,12 @@ class Cue(SCTE35Base):
131
147
  """
132
148
  return self.bites
133
149
 
134
- @staticmethod
135
- def fix_bad_b64(data):
150
+ def fix_bad_b64(self,data):
136
151
  """
137
152
  fix_bad_b64 fixes bad padding on Base64
138
153
  """
154
+ if len(data) %4!=0:
155
+ self.errors.append('fixed bad base64 length ')
139
156
  while len(data) % 4 != 0:
140
157
  data = data + "="
141
158
  return data
@@ -238,12 +255,12 @@ class Cue(SCTE35Base):
238
255
  """
239
256
  sct = self.info_section.splice_command_type
240
257
  if sct not in command_map:
258
+ self.errors.append(f"Splice Command type {sct} not recognized")
241
259
  return False
242
260
  iscl = self.info_section.splice_command_length
243
261
  cmd_bites = bites[:iscl]
244
262
  self.command = command_map[sct](cmd_bites)
245
263
  self.command.command_length = iscl
246
-
247
264
  self.command.decode()
248
265
  del self.command.bites
249
266
  return bites[iscl:]
@@ -251,9 +268,13 @@ class Cue(SCTE35Base):
251
268
  # encode related
252
269
 
253
270
  def _assemble(self):
271
+ for d in self.descriptors:
272
+ d.errors=[]
254
273
  dscptr_bites = self._unloop_descriptors()
255
274
  dll = len(dscptr_bites)
256
275
  self.info_section.descriptor_loop_length = dll
276
+ self.info_section.errors=[]
277
+ self.command.errors=[]
257
278
  cmd_bites = self.command.encode()
258
279
  cmdl = self.command.command_length = len(cmd_bites)
259
280
  self.info_section.splice_command_length = cmdl
@@ -277,6 +298,7 @@ class Cue(SCTE35Base):
277
298
  self._assemble()
278
299
  self._encode_crc()
279
300
  return b64encode(self.bites).decode()
301
+ self._no_cmd()
280
302
  return False
281
303
 
282
304
  def encode(self):
@@ -366,7 +388,8 @@ class Cue(SCTE35Base):
366
388
  """
367
389
  _no_cmd raises an exception if no splice command.
368
390
  """
369
- raise Exception("\033[7mA splice command is required\033[27m")
391
+ self.errors.append("A splice command is required")
392
+ # raise Exception("\033[7mA splice command is required\033[27m")
370
393
 
371
394
  def load(self, gonzo):
372
395
  """
@@ -424,9 +447,12 @@ class Cue(SCTE35Base):
424
447
  _mk_descriptor_xml make xml nodes for descriptors.
425
448
  """
426
449
  for d in self.descriptors:
427
- if d.has("segmentation_type_id") and d.segmentation_type_id in table22:
428
- comment = f"{table22[d.segmentation_type_id]}"
429
- sis.add_comment(comment)
450
+ if d.has("segmentation_type_id"):
451
+ if d.segmentation_type_id in table22:
452
+ comment = f"{table22[d.segmentation_type_id]}"
453
+ sis.add_comment(comment)
454
+ else:
455
+ d.errors.append("Segmentation type id not in table 22")
430
456
  sis.add_child(d.xml(ns=ns))
431
457
  return sis
432
458