threefive3 3.0.13__tar.gz → 3.0.15__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 (34) hide show
  1. {threefive3-3.0.13/threefive3.egg-info → threefive3-3.0.15}/PKG-INFO +58 -42
  2. {threefive3-3.0.13 → threefive3-3.0.15}/README.md +57 -38
  3. {threefive3-3.0.13 → threefive3-3.0.15}/bin/threefive3 +3 -2
  4. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/base.py +10 -10
  5. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/stream.py +24 -29
  6. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/sxp.py +15 -4
  7. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/version.py +1 -1
  8. {threefive3-3.0.13 → threefive3-3.0.15/threefive3.egg-info}/PKG-INFO +58 -42
  9. {threefive3-3.0.13 → threefive3-3.0.15}/LICENSE +0 -0
  10. {threefive3-3.0.13 → threefive3-3.0.15}/setup.cfg +0 -0
  11. {threefive3-3.0.13 → threefive3-3.0.15}/setup.py +0 -0
  12. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/__init__.py +0 -0
  13. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/bitn.py +0 -0
  14. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/commands.py +0 -0
  15. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/crc.py +0 -0
  16. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/cue.py +0 -0
  17. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/descriptors.py +0 -0
  18. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/hls.py +0 -0
  19. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/iframes.py +0 -0
  20. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/new_reader.py +0 -0
  21. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/packetdata.py +0 -0
  22. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/section.py +0 -0
  23. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/segment.py +0 -0
  24. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/segmentation.py +0 -0
  25. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/sixfix.py +0 -0
  26. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/spare.py +0 -0
  27. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/streamtypes.py +0 -0
  28. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/upids.py +0 -0
  29. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/x2c.py +0 -0
  30. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3/xml.py +0 -0
  31. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3.egg-info/SOURCES.txt +0 -0
  32. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3.egg-info/dependency_links.txt +0 -0
  33. {threefive3-3.0.13 → threefive3-3.0.15}/threefive3.egg-info/requires.txt +0 -0
  34. {threefive3-3.0.13 → threefive3-3.0.15}/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.15
4
4
  Summary: threefive continued.
5
5
  Home-page: https://github.com/superkabuki/scte35
6
6
  Author: Adrian of Doom
@@ -18,57 +18,38 @@ 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
+ [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)
26
23
 
27
24
 
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:
25
+ # threefive3 SCTE-35 cli tool and python3 library.
38
26
 
39
- <br>
27
+ ✅ SCTE-35 Parser ✅ SCTE-35 Encoder ✅ SCTE-35 HLS ✅ SCTE-35 Xml ✅ SCTE-35 Cli ✅ SCTE-35 library
40
28
 
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>
29
+
30
+ * Parses SCTE-35 from MPEGTS, HLS, XML, XML+Binary, Base64, Bytes, Hex, and Integers.
31
+ * Built-in network support for http(s), UDP, and Multicast.
32
+ * Automatic AES decryption for HLS.
33
+ * All HLS SCTE-35 Tags are Supported
54
34
  ___
55
35
 
56
- # FAQ
57
- * Q. What is the latest version?
36
+ ## MPEGTS streams can be parsed for SCTE-35 with three lines of code.
58
37
 
59
- * A. `v3.0.13`
60
- ---
61
- * Q. How do I upgrade my code from threefive to the __more powerful super advanced threefive3?__
38
+ ```py3
39
+ a@fu:~/build5/scte35/scte35$ pypy3
40
+ Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
41
+ [PyPy 7.3.11 with GCC 12.2.0] on linux
42
+ Type "help", "copyright", "credits" or "license" for more information.
62
43
 
63
- * A. `sed.`
64
- ```js
65
- sed -i 's/threefive/threefive3/g'
44
+ >>>> from threefive import Stream
45
+
46
+ >>>> strm=Stream('https://futzu.com/xaa.ts')
47
+
48
+ >>>> strm.decode()
66
49
  ```
67
- ---
68
- * Q. Does threefive3 have super cool new features?
69
50
 
70
- * A. `Yes.`
71
- ---
51
+ ___
52
+
72
53
 
73
54
  # `Install`
74
55
  * python3 via pip
@@ -88,7 +69,7 @@ make install
88
69
  ___
89
70
 
90
71
  # `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.
72
+
92
73
 
93
74
  ### The cli tool installs automatically with pip or the Makefile.
94
75
 
@@ -106,6 +87,28 @@ ___
106
87
  * __stdin__ is __auto selected__ and __auto detected.__
107
88
  * __SCTE-35 data is printed to stderr__
108
89
  * __stdout is used when piping video__
90
+ * mpegts can be specified by file name or URI.
91
+ ```rebol
92
+ threefive3 udp://@235.2.5.35:3535
93
+ ```
94
+ * If a file comtains a SCTE-35 Cue as a string( base64,hex,int,json,xml or xml+bin), redirect the file contents.
95
+ ```rebol
96
+
97
+ threefive3 < json.json
98
+
99
+ threefive3 < xml.xml
100
+
101
+ cat xml.xml | threefive3
102
+ ```
103
+
104
+ * quoted strings(( base64,hex,int,json,xml or xml+bin), can be passed directly on the command line as well.
105
+
106
+ ```awk
107
+
108
+ threefive3 '/DAWAAAAAAAAAP/wBQb+ztd7owAAdIbbmw=='
109
+
110
+ ```
111
+
109
112
 
110
113
  | Input Type | Cli Example |
111
114
  |------------|-------------------------------------------------------------------------------------------------------------|
@@ -214,7 +217,20 @@ ___
214
217
  ```rebol
215
218
  threefive3 help
216
219
  ```
220
+ ___
221
+
222
+ ![image](https://github.com/user-attachments/assets/91fd37c2-746c-498d-8c6c-80c6e7760c0e)
223
+
224
+ ___
225
+
217
226
  ## [iodisco.com/scte35](https://iodisco.com/scte35)
218
227
  ![image](https://github.com/user-attachments/assets/4df85c44-a078-4da0-97e2-5daefcf2509d)
219
228
 
220
229
 
230
+
231
+ ___
232
+
233
+ [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)
234
+
235
+
236
+
@@ -1,50 +1,34 @@
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
+ [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)
2
2
 
3
3
 
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:
4
+ # threefive3 SCTE-35 cli tool and python3 library.
14
5
 
15
- <br>
6
+ ✅ SCTE-35 Parser ✅ SCTE-35 Encoder ✅ SCTE-35 HLS ✅ SCTE-35 Xml ✅ SCTE-35 Cli ✅ SCTE-35 library
16
7
 
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>
8
+
9
+ * Parses SCTE-35 from MPEGTS, HLS, XML, XML+Binary, Base64, Bytes, Hex, and Integers.
10
+ * Built-in network support for http(s), UDP, and Multicast.
11
+ * Automatic AES decryption for HLS.
12
+ * All HLS SCTE-35 Tags are Supported
30
13
  ___
31
14
 
32
- # FAQ
33
- * Q. What is the latest version?
15
+ ## MPEGTS streams can be parsed for SCTE-35 with three lines of code.
34
16
 
35
- * A. `v3.0.13`
36
- ---
37
- * Q. How do I upgrade my code from threefive to the __more powerful super advanced threefive3?__
17
+ ```py3
18
+ a@fu:~/build5/scte35/scte35$ pypy3
19
+ Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
20
+ [PyPy 7.3.11 with GCC 12.2.0] on linux
21
+ Type "help", "copyright", "credits" or "license" for more information.
38
22
 
39
- * A. `sed.`
40
- ```js
41
- sed -i 's/threefive/threefive3/g'
23
+ >>>> from threefive import Stream
24
+
25
+ >>>> strm=Stream('https://futzu.com/xaa.ts')
26
+
27
+ >>>> strm.decode()
42
28
  ```
43
- ---
44
- * Q. Does threefive3 have super cool new features?
45
29
 
46
- * A. `Yes.`
47
- ---
30
+ ___
31
+
48
32
 
49
33
  # `Install`
50
34
  * python3 via pip
@@ -64,7 +48,7 @@ make install
64
48
  ___
65
49
 
66
50
  # `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.
51
+
68
52
 
69
53
  ### The cli tool installs automatically with pip or the Makefile.
70
54
 
@@ -82,6 +66,28 @@ ___
82
66
  * __stdin__ is __auto selected__ and __auto detected.__
83
67
  * __SCTE-35 data is printed to stderr__
84
68
  * __stdout is used when piping video__
69
+ * mpegts can be specified by file name or URI.
70
+ ```rebol
71
+ threefive3 udp://@235.2.5.35:3535
72
+ ```
73
+ * If a file comtains a SCTE-35 Cue as a string( base64,hex,int,json,xml or xml+bin), redirect the file contents.
74
+ ```rebol
75
+
76
+ threefive3 < json.json
77
+
78
+ threefive3 < xml.xml
79
+
80
+ cat xml.xml | threefive3
81
+ ```
82
+
83
+ * quoted strings(( base64,hex,int,json,xml or xml+bin), can be passed directly on the command line as well.
84
+
85
+ ```awk
86
+
87
+ threefive3 '/DAWAAAAAAAAAP/wBQb+ztd7owAAdIbbmw=='
88
+
89
+ ```
90
+
85
91
 
86
92
  | Input Type | Cli Example |
87
93
  |------------|-------------------------------------------------------------------------------------------------------------|
@@ -190,7 +196,20 @@ ___
190
196
  ```rebol
191
197
  threefive3 help
192
198
  ```
199
+ ___
200
+
201
+ ![image](https://github.com/user-attachments/assets/91fd37c2-746c-498d-8c6c-80c6e7760c0e)
202
+
203
+ ___
204
+
193
205
  ## [iodisco.com/scte35](https://iodisco.com/scte35)
194
206
  ![image](https://github.com/user-attachments/assets/4df85c44-a078-4da0-97e2-5daefcf2509d)
195
207
 
196
208
 
209
+
210
+ ___
211
+
212
+ [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)
213
+
214
+
215
+
@@ -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
 
@@ -27,7 +27,7 @@ class SCTE35Base:
27
27
  return nbin
28
28
 
29
29
  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 "
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}, {bit_count} bit(s) long.\n "
31
31
  print2(err_mesg)
32
32
 
33
33
  def _bool_int(self, var_name, var_value, bit_count, var_type):
@@ -100,9 +100,10 @@ class SCTE35Base:
100
100
  def has(self, what):
101
101
  """
102
102
  has runs hasattr with self and what
103
+ returns value if set.
103
104
  """
104
105
  if hasattr(self, what):
105
- return True
106
+ return vars(self)[what]
106
107
  return False
107
108
 
108
109
  def hasis(self, what):
@@ -151,23 +152,22 @@ class SCTE35Base:
151
152
 
152
153
  return {k: b2l(v) for k, v in vars(self).items() if v is not None}
153
154
 
154
- def _load_str(self, gonzo):
155
+ def _json2dict(self, gonzo):
155
156
  if isinstance(gonzo, str):
156
157
  gonzo = json.loads(gonzo)
157
158
  return gonzo
158
159
 
159
- def _chk_prevars(self, k, v, prevars):
160
- if k in prevars:
160
+ def _chk_vars(self, k, v):
161
+ if k in vars(self):
161
162
  self.__dict__[k] = v
162
163
 
163
- def _vrfy_load(self, gonzo, prevars):
164
+ def _vrfy_load(self, gonzo):
164
165
  for k, v in gonzo.items():
165
- self._chk_prevars(k, v, prevars)
166
+ self._chk_vars(k, v)
166
167
 
167
168
  def _load_dict(self, gonzo):
168
169
  if isinstance(gonzo, dict):
169
- prevars = vars(self)
170
- self._vrfy_load(gonzo, prevars)
170
+ self._vrfy_load(gonzo)
171
171
 
172
172
  def load(self, gonzo):
173
173
  """
@@ -175,7 +175,7 @@ class SCTE35Base:
175
175
  data from a dict or json string.
176
176
  only updates vars that exist in the obj.
177
177
  """
178
- gonzo = self._load_str(gonzo)
178
+ gonzo = self._json2dict(gonzo)
179
179
  self._load_dict(gonzo)
180
180
 
181
181
  def show(self):
@@ -231,7 +231,7 @@ class Stream:
231
231
  while self._tsdata:
232
232
  one = self._tsdata.read(1)
233
233
  if one:
234
- if one[0]== self.SYNC_BYTE:
234
+ if one[0] == self.SYNC_BYTE:
235
235
  tail = self._tsdata.read(self.PACKET_SIZE - 1)
236
236
  self._parse(one + tail)
237
237
  return True
@@ -315,7 +315,7 @@ class Stream:
315
315
  """
316
316
  self.info = True
317
317
  for pkt in self.iter_pkts():
318
- self._parse_info(pkt)
318
+ self._parse(pkt)
319
319
  if self.maps.prgm.keys():
320
320
  sopro = sorted(self.maps.prgm.items())
321
321
  for k, vee in sopro:
@@ -386,8 +386,14 @@ class Stream:
386
386
  one = 1
387
387
  if not bites:
388
388
  return b""
389
- if bites[0] in [pad]:
390
- self._unpad(bites[one:])
389
+ while bites[0] == pad:
390
+ bites = bites[1:]
391
+ return self._unpad2(bites)
392
+
393
+ def _unpad2(self, bites):
394
+ pad = 255
395
+ while bites[-1] == pad:
396
+ bites = bites[:-1]
391
397
  return bites
392
398
 
393
399
  def _mk_packet_data(self, pid):
@@ -412,15 +418,6 @@ class Stream:
412
418
  parse pts and store by program key
413
419
  in the dict Stream._pid_pts
414
420
  """
415
- ## payload = self._parse_payload(pkt)
416
- ## if len(payload) > 13:
417
- ## if self._pts_flag(payload):
418
- ## pts = (payload[9] & 14) << 29
419
- ## pts |= payload[10] << 22
420
- ## pts |= (payload[11] >> 1) << 15
421
- ## pts |= payload[12] << 7
422
- ## pts |= payload[13] >> 1
423
-
424
421
  pts = self.iframer.ticks(pkt)
425
422
  if pts:
426
423
  prgm = self.pid2prgm(pid)
@@ -449,18 +446,17 @@ class Stream:
449
446
  head_size += afl + 1 # +1 for afl byte
450
447
  return pkt[head_size:]
451
448
 
452
- def _pmt_pid(self, pkt, pid):
449
+ def _pmt_pid(self, pay, pid):
453
450
  if pid in self.pids.pmt:
454
- pay = self._parse_payload(pkt)
455
451
  self._parse_pmt(pay, pid)
456
452
 
457
453
  def _pat_pid(self, pay, pid):
458
454
  if pid == self.pids.PAT_PID:
459
455
  self._parse_pat(pay)
460
456
 
461
- def _sdt_pid(self, pay, pid,):
457
+ def _sdt_pid(self,pay,pid):
462
458
  if pid == self.pids.SDT_PID:
463
- self._parse_sdt(pay)
459
+ self._parse_sdt(pay)
464
460
 
465
461
  def _parse_tables(self, pkt, pid):
466
462
  """
@@ -468,9 +464,9 @@ class Stream:
468
464
  PAT, PMT, and SDT tables
469
465
  based on pid of the pkt
470
466
  """
471
- self._pmt_pid(pkt, pid,)
472
467
  pay = self._parse_payload(pkt)
473
468
  if not self._same_as_last(pay, pid):
469
+ self._pmt_pid(pay,pid)
474
470
  self._pat_pid(pay, pid)
475
471
  self._sdt_pid(pay, pid)
476
472
 
@@ -502,15 +498,14 @@ class Stream:
502
498
  pid = self._parse_info(pkt)
503
499
  if pid in self.pids.pcr:
504
500
  self._chk_pcr(pkt, pid)
505
- if self._pusi_flag(pkt):
506
- self._chk_pts(pkt, pid)
501
+ self._chk_pts(pkt, pid)
507
502
  return self._chk_scte35(pkt, pid)
508
503
 
509
504
  def _pid_has_scte35(self, pid):
510
- # return pid in self.pids.scte35.union(self.pids.maybe_scte35) # union sucks. 4.47 secs
511
- # return (pid in self.pids.scte35 or pid in self.pids.maybe_scte35) # 3.37 secs
512
- return pid in (self.pids.scte35 or self.pids.maybe_scte35) # 3.326 secs
513
- # return pid in (self.pids.scte35|self.pids.maybe_scte35) # wtf? 4.128 secs
505
+ # return pid in self.pids.scte35.union(self.pids.maybe_scte35) # 4 Slowest. (union sucks)
506
+ # return (pid in self.pids.scte35 or pid in self.pids.maybe_scte35) #2 Fast
507
+ return pid in (self.pids.scte35 or self.pids.maybe_scte35) # 1 Fastest
508
+ # return pid in (self.pids.scte35|self.pids.maybe_scte35) #3 Slow. (I thought this would be fastest)
514
509
 
515
510
  def _chk_partial(self, pay, pid, sep):
516
511
  if pid in self.maps.partial:
@@ -526,10 +521,11 @@ class Stream:
526
521
 
527
522
  def _section_incomplete(self, pay, pid, seclen):
528
523
  # + 3 for the bytes before section starts
524
+ if len(pay) > (seclen + 3):
525
+ return False
529
526
  if (seclen + 3) > len(pay):
530
527
  self.maps.partial[pid] = pay
531
528
  return True
532
- return False
533
529
 
534
530
  def _parse_cue(self, pay, pid):
535
531
  packet_data = None
@@ -644,7 +640,6 @@ class Stream:
644
640
  idx += chunk_size
645
641
  return True
646
642
 
647
-
648
643
  def _parse_pmt(self, pay, pid):
649
644
  """
650
645
  parse program maps for streams
@@ -657,7 +652,7 @@ class Stream:
657
652
  return False
658
653
  program_number = self._parse_program(pay[3], pay[4])
659
654
  if not program_number:
660
- return False
655
+ return False
661
656
  pcr_pid = self._parse_pid(pay[8], pay[9])
662
657
  if program_number not in self.maps.prgm:
663
658
  self.maps.prgm[program_number] = ProgramInfo()
@@ -679,8 +674,8 @@ class Stream:
679
674
  """
680
675
  # 5 bytes for stream_type info
681
676
  chunk_size = 5
682
- end_idx = (idx + si_len) -4
683
- while idx < end_idx:
677
+ end_idx = (idx + si_len) - 4
678
+ while end_idx - chunk_size >= idx:
684
679
  stream_type, pid, ei_len = self._parse_stream_type(pay, idx)
685
680
  pinfo = self.maps.prgm[program_number]
686
681
  pinfo.streams[pid] = stream_type
@@ -8,9 +8,7 @@ from xml.sax.saxutils import unescape
8
8
  from .xml import strip_ns, iter_attrs
9
9
 
10
10
 
11
- class SuperXmlParser:
12
-
13
- CHILD_NODES = [
11
+ CHILD_NODES = [
14
12
  "Program",
15
13
  "SpliceTime",
16
14
  "DeliveryRestrictions",
@@ -18,6 +16,19 @@ class SuperXmlParser:
18
16
  "BreakDuration",
19
17
  ]
20
18
 
19
+ class SuperXmlParser:
20
+ """
21
+ The Super Xml Parser
22
+ """
23
+ def __init__(self,child_nodes=CHILD_NODES):
24
+ """
25
+ __init__ allows you to specify child nodes
26
+
27
+ My thinking was, since I know which ones are
28
+ child nodes, why not specify them?
29
+ """
30
+ self.child_nodes=child_nodes
31
+
21
32
  def _split_attrs(self, node):
22
33
  node = node.replace("='", '="').replace("' ", '" ')
23
34
  attrs = [x for x in node.split(" ") if "=" in x]
@@ -74,7 +85,7 @@ class SuperXmlParser:
74
85
  for sp in splitted:
75
86
  if self._vrfy_sp(sp):
76
87
  x = self._assemble(sp)
77
- if x["name"] in self.CHILD_NODES:
88
+ if x["name"] in self.child_nodes:
78
89
  results[-1]["children"].append(x)
79
90
  else:
80
91
  results.append(x)
@@ -5,6 +5,6 @@ from the cli tool run: threefive3 version
5
5
 
6
6
  major = 3
7
7
  minor = 0
8
- maintenance = 13
8
+ maintenance = 15
9
9
 
10
10
  version = f"{major}.{minor}.{maintenance}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: threefive3
3
- Version: 3.0.13
3
+ Version: 3.0.15
4
4
  Summary: threefive continued.
5
5
  Home-page: https://github.com/superkabuki/scte35
6
6
  Author: Adrian of Doom
@@ -18,57 +18,38 @@ 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
+ [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)
26
23
 
27
24
 
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:
25
+ # threefive3 SCTE-35 cli tool and python3 library.
38
26
 
39
- <br>
27
+ ✅ SCTE-35 Parser ✅ SCTE-35 Encoder ✅ SCTE-35 HLS ✅ SCTE-35 Xml ✅ SCTE-35 Cli ✅ SCTE-35 library
40
28
 
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>
29
+
30
+ * Parses SCTE-35 from MPEGTS, HLS, XML, XML+Binary, Base64, Bytes, Hex, and Integers.
31
+ * Built-in network support for http(s), UDP, and Multicast.
32
+ * Automatic AES decryption for HLS.
33
+ * All HLS SCTE-35 Tags are Supported
54
34
  ___
55
35
 
56
- # FAQ
57
- * Q. What is the latest version?
36
+ ## MPEGTS streams can be parsed for SCTE-35 with three lines of code.
58
37
 
59
- * A. `v3.0.13`
60
- ---
61
- * Q. How do I upgrade my code from threefive to the __more powerful super advanced threefive3?__
38
+ ```py3
39
+ a@fu:~/build5/scte35/scte35$ pypy3
40
+ Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
41
+ [PyPy 7.3.11 with GCC 12.2.0] on linux
42
+ Type "help", "copyright", "credits" or "license" for more information.
62
43
 
63
- * A. `sed.`
64
- ```js
65
- sed -i 's/threefive/threefive3/g'
44
+ >>>> from threefive import Stream
45
+
46
+ >>>> strm=Stream('https://futzu.com/xaa.ts')
47
+
48
+ >>>> strm.decode()
66
49
  ```
67
- ---
68
- * Q. Does threefive3 have super cool new features?
69
50
 
70
- * A. `Yes.`
71
- ---
51
+ ___
52
+
72
53
 
73
54
  # `Install`
74
55
  * python3 via pip
@@ -88,7 +69,7 @@ make install
88
69
  ___
89
70
 
90
71
  # `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.
72
+
92
73
 
93
74
  ### The cli tool installs automatically with pip or the Makefile.
94
75
 
@@ -106,6 +87,28 @@ ___
106
87
  * __stdin__ is __auto selected__ and __auto detected.__
107
88
  * __SCTE-35 data is printed to stderr__
108
89
  * __stdout is used when piping video__
90
+ * mpegts can be specified by file name or URI.
91
+ ```rebol
92
+ threefive3 udp://@235.2.5.35:3535
93
+ ```
94
+ * If a file comtains a SCTE-35 Cue as a string( base64,hex,int,json,xml or xml+bin), redirect the file contents.
95
+ ```rebol
96
+
97
+ threefive3 < json.json
98
+
99
+ threefive3 < xml.xml
100
+
101
+ cat xml.xml | threefive3
102
+ ```
103
+
104
+ * quoted strings(( base64,hex,int,json,xml or xml+bin), can be passed directly on the command line as well.
105
+
106
+ ```awk
107
+
108
+ threefive3 '/DAWAAAAAAAAAP/wBQb+ztd7owAAdIbbmw=='
109
+
110
+ ```
111
+
109
112
 
110
113
  | Input Type | Cli Example |
111
114
  |------------|-------------------------------------------------------------------------------------------------------------|
@@ -214,7 +217,20 @@ ___
214
217
  ```rebol
215
218
  threefive3 help
216
219
  ```
220
+ ___
221
+
222
+ ![image](https://github.com/user-attachments/assets/91fd37c2-746c-498d-8c6c-80c6e7760c0e)
223
+
224
+ ___
225
+
217
226
  ## [iodisco.com/scte35](https://iodisco.com/scte35)
218
227
  ![image](https://github.com/user-attachments/assets/4df85c44-a078-4da0-97e2-5daefcf2509d)
219
228
 
220
229
 
230
+
231
+ ___
232
+
233
+ [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)
234
+
235
+
236
+
File without changes
File without changes
File without changes