threefive3 3.0.15__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.
- {threefive3-3.0.15/threefive3.egg-info → threefive3-3.0.16}/PKG-INFO +10 -4
- {threefive3-3.0.15 → threefive3-3.0.16}/README.md +9 -3
- {threefive3-3.0.15 → threefive3-3.0.16}/setup.py +0 -2
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/__init__.py +19 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/base.py +7 -11
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/bitn.py +4 -4
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/commands.py +4 -3
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/cue.py +34 -8
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/descriptors.py +11 -7
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/hls.py +7 -7
- threefive3-3.0.16/threefive3/m3ufu.py +663 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/section.py +15 -14
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/upids.py +4 -4
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/version.py +1 -1
- {threefive3-3.0.15 → threefive3-3.0.16/threefive3.egg-info}/PKG-INFO +10 -4
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3.egg-info/SOURCES.txt +1 -0
- threefive3-3.0.16/threefive3.egg-info/requires.txt +1 -0
- threefive3-3.0.15/threefive3.egg-info/requires.txt +0 -3
- {threefive3-3.0.15 → threefive3-3.0.16}/LICENSE +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/bin/threefive3 +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/setup.cfg +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/crc.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/iframes.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/new_reader.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/packetdata.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/segment.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/segmentation.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/sixfix.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/spare.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/stream.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/streamtypes.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/sxp.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/x2c.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3/xml.py +0 -0
- {threefive3-3.0.15 → threefive3-3.0.16}/threefive3.egg-info/dependency_links.txt +0 -0
- {threefive3-3.0.15 → 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.
|
|
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
|
|
@@ -19,9 +19,6 @@ Requires-Python: >=3.6
|
|
|
19
19
|
Description-Content-Type: text/markdown
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
|
|
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)
|
|
23
|
-
|
|
24
|
-
|
|
25
22
|
# threefive3 SCTE-35 cli tool and python3 library.
|
|
26
23
|
|
|
27
24
|
✅ SCTE-35 Parser ✅ SCTE-35 Encoder ✅ SCTE-35 HLS ✅ SCTE-35 Xml ✅ SCTE-35 Cli ✅ SCTE-35 library
|
|
@@ -32,6 +29,14 @@ License-File: LICENSE
|
|
|
32
29
|
* Automatic AES decryption for HLS.
|
|
33
30
|
* All HLS SCTE-35 Tags are Supported
|
|
34
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)
|
|
35
40
|
|
|
36
41
|
## MPEGTS streams can be parsed for SCTE-35 with three lines of code.
|
|
37
42
|
|
|
@@ -68,6 +73,7 @@ make install
|
|
|
68
73
|
```
|
|
69
74
|
___
|
|
70
75
|
|
|
76
|
+
|
|
71
77
|
# `The Cli tool`
|
|
72
78
|
|
|
73
79
|
|
|
@@ -1,6 +1,3 @@
|
|
|
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
|
-
|
|
3
|
-
|
|
4
1
|
# threefive3 SCTE-35 cli tool and python3 library.
|
|
5
2
|
|
|
6
3
|
✅ SCTE-35 Parser ✅ SCTE-35 Encoder ✅ SCTE-35 HLS ✅ SCTE-35 Xml ✅ SCTE-35 Cli ✅ SCTE-35 library
|
|
@@ -11,6 +8,14 @@
|
|
|
11
8
|
* Automatic AES decryption for HLS.
|
|
12
9
|
* All HLS SCTE-35 Tags are Supported
|
|
13
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)
|
|
14
19
|
|
|
15
20
|
## MPEGTS streams can be parsed for SCTE-35 with three lines of code.
|
|
16
21
|
|
|
@@ -47,6 +52,7 @@ make install
|
|
|
47
52
|
```
|
|
48
53
|
___
|
|
49
54
|
|
|
55
|
+
|
|
50
56
|
# `The Cli tool`
|
|
51
57
|
|
|
52
58
|
|
|
@@ -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
|
-
|
|
31
|
-
|
|
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:
|
|
@@ -104,14 +108,6 @@ class SCTE35Base:
|
|
|
104
108
|
"""
|
|
105
109
|
if hasattr(self, what):
|
|
106
110
|
return vars(self)[what]
|
|
107
|
-
return False
|
|
108
|
-
|
|
109
|
-
def hasis(self, what):
|
|
110
|
-
"""
|
|
111
|
-
hasis obj "has" a what and what "is" returned.
|
|
112
|
-
"""
|
|
113
|
-
if self.has(what):
|
|
114
|
-
return vars(self)[what]
|
|
115
111
|
return None
|
|
116
112
|
|
|
117
113
|
@staticmethod
|
|
@@ -150,7 +146,7 @@ class SCTE35Base:
|
|
|
150
146
|
val = list(val)
|
|
151
147
|
return val
|
|
152
148
|
|
|
153
|
-
return {k: b2l(v) for k, v in vars(self).items() if v
|
|
149
|
+
return {k: b2l(v) for k, v in vars(self).items() if v not in [None,[],] } # added empty list []
|
|
154
150
|
|
|
155
151
|
def _json2dict(self, gonzo):
|
|
156
152
|
if isinstance(gonzo, str):
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"""
|
|
2
|
-
The bitn.
|
|
2
|
+
The bitn.Bitn and bitn.NBin classes
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
from .spare import print2
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
class
|
|
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
|
-
|
|
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
|
|
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
|
|
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 =
|
|
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 =
|
|
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
|
-
|
|
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
|
-
|
|
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")
|
|
428
|
-
|
|
429
|
-
|
|
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
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
SCTE35 Splice Descriptors
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from .bitn import
|
|
5
|
+
from .bitn import Bitn
|
|
6
6
|
from .base import SCTE35Base
|
|
7
7
|
from .segmentation import table20, table22, dvb_table2
|
|
8
8
|
from .upids import upid_map
|
|
@@ -25,7 +25,7 @@ class SpliceDescriptor(SCTE35Base):
|
|
|
25
25
|
"""
|
|
26
26
|
|
|
27
27
|
def __init__(self, bites=None):
|
|
28
|
-
|
|
28
|
+
super().__init__()
|
|
29
29
|
self.tag = None
|
|
30
30
|
self.identifier = "CUEI"
|
|
31
31
|
self.name = None
|
|
@@ -110,7 +110,7 @@ class DVBDASDescriptor(SpliceDescriptor):
|
|
|
110
110
|
"""
|
|
111
111
|
Decode DVB DAS Descriptor
|
|
112
112
|
"""
|
|
113
|
-
bitbin =
|
|
113
|
+
bitbin = Bitn(self.bites)
|
|
114
114
|
self.break_num = bitbin.as_int(8)
|
|
115
115
|
self.breaks_expected = bitbin.as_int(8)
|
|
116
116
|
bitbin.forward(4)
|
|
@@ -152,7 +152,7 @@ class AvailDescriptor(SpliceDescriptor):
|
|
|
152
152
|
"""
|
|
153
153
|
decode SCTE35 Avail Descriptor
|
|
154
154
|
"""
|
|
155
|
-
bitbin =
|
|
155
|
+
bitbin = Bitn(self.bites)
|
|
156
156
|
self.provider_avail_id = bitbin.as_int(32)
|
|
157
157
|
|
|
158
158
|
def encode(self, nbin=None):
|
|
@@ -251,7 +251,7 @@ class TimeDescriptor(SpliceDescriptor):
|
|
|
251
251
|
"""
|
|
252
252
|
decode SCTE35 Time Descriptor
|
|
253
253
|
"""
|
|
254
|
-
bitbin =
|
|
254
|
+
bitbin = Bitn(self.bites)
|
|
255
255
|
self.tai_seconds = bitbin.as_int(48)
|
|
256
256
|
self.tai_ns = bitbin.as_int(32)
|
|
257
257
|
self.utc_offset = bitbin.as_int(16)
|
|
@@ -328,7 +328,7 @@ class SegmentationDescriptor(SpliceDescriptor):
|
|
|
328
328
|
"""
|
|
329
329
|
decode a segmentation descriptor
|
|
330
330
|
"""
|
|
331
|
-
bitbin =
|
|
331
|
+
bitbin = Bitn(self.bites)
|
|
332
332
|
self.segmentation_event_id = bitbin.as_hex(32)
|
|
333
333
|
self.segmentation_event_cancel_indicator = bitbin.as_flag(1)
|
|
334
334
|
self.segmentation_event_id_compliance_indicator = bitbin.as_flag(1)
|
|
@@ -421,6 +421,7 @@ class SegmentationDescriptor(SpliceDescriptor):
|
|
|
421
421
|
"""
|
|
422
422
|
upid_type = self.segmentation_upid_type
|
|
423
423
|
if upid_type not in upid_map:
|
|
424
|
+
self.errors.append("Unknown upid type , setting to 0xFD")
|
|
424
425
|
upid_type = 0xFD
|
|
425
426
|
the_upid = upid_map[upid_type][1](
|
|
426
427
|
bitbin, upid_type, self.segmentation_upid_length
|
|
@@ -435,6 +436,7 @@ class SegmentationDescriptor(SpliceDescriptor):
|
|
|
435
436
|
upid_type = self.segmentation_upid_type
|
|
436
437
|
if upid_type not in upid_map:
|
|
437
438
|
upid_type = 0xFD
|
|
439
|
+
self.errors.append("Unknown upid type , setting to 0xFD")
|
|
438
440
|
the_upid = upid_map[upid_type][1](
|
|
439
441
|
None, upid_type, self.segmentation_upid_length
|
|
440
442
|
)
|
|
@@ -459,6 +461,7 @@ class SegmentationDescriptor(SpliceDescriptor):
|
|
|
459
461
|
self._chk_var(int, nbin.add_int, "sub_segment_num", 8)
|
|
460
462
|
self._chk_var(int, nbin.add_int, "sub_segments_expected", 8)
|
|
461
463
|
except:
|
|
464
|
+
self.errors.append("Adding sub_segment_num and sub_segments_expected. setting to 0, 0")
|
|
462
465
|
nbin.add_int(0, 8)
|
|
463
466
|
nbin.add_int(0, 8)
|
|
464
467
|
|
|
@@ -524,7 +527,7 @@ class SegmentationDescriptor(SpliceDescriptor):
|
|
|
524
527
|
bites = bytes.fromhex(seg_upid)
|
|
525
528
|
except ValueError:
|
|
526
529
|
bites = seg_upid.encode()
|
|
527
|
-
bitbin =
|
|
530
|
+
bitbin = Bitn(bites)
|
|
528
531
|
self.segmentation_upid_length = len(bites)
|
|
529
532
|
the_upid = self.mk_the_upid(bitbin=bitbin)
|
|
530
533
|
self.segmentation_upid_type_name, self.segmentation_upid = the_upid.decode()
|
|
@@ -550,5 +553,6 @@ def splice_descriptor(bites):
|
|
|
550
553
|
spliced = descriptor_map[tag](bites)
|
|
551
554
|
else:
|
|
552
555
|
spliced = SpliceDescriptor(bites)
|
|
556
|
+
spliced.errors.append(f"tag not in descriptor map. 0,1,2,3, 240 are valid tags")
|
|
553
557
|
spliced.decode()
|
|
554
558
|
return spliced
|
|
@@ -10,7 +10,7 @@ import os
|
|
|
10
10
|
import sys
|
|
11
11
|
import time
|
|
12
12
|
from collections import deque
|
|
13
|
-
from m3ufu import M3uFu, TagParser, HEADER_TAGS
|
|
13
|
+
from .m3ufu import M3uFu, TagParser, HEADER_TAGS
|
|
14
14
|
from .segment import Segment
|
|
15
15
|
from .cue import Cue
|
|
16
16
|
from .new_reader import reader
|
|
@@ -153,9 +153,9 @@ class Scte35Profile:
|
|
|
153
153
|
|
|
154
154
|
@staticmethod
|
|
155
155
|
def _clean(line):
|
|
156
|
-
|
|
156
|
+
"""
|
|
157
157
|
remove whitespace and quotes
|
|
158
|
-
|
|
158
|
+
"""
|
|
159
159
|
translate_map = {34: 94, 10: 94, 9: 94, 32: 94, 39: 94}
|
|
160
160
|
return line.translate(translate_map).replace("^", "")
|
|
161
161
|
|
|
@@ -230,7 +230,7 @@ class Scte35Profile:
|
|
|
230
230
|
|
|
231
231
|
def _chk_pts(self, cue):
|
|
232
232
|
pts = None
|
|
233
|
-
if cue.command.
|
|
233
|
+
if cue.command.has("pts_time"):
|
|
234
234
|
pts = self.set_pts(cue)
|
|
235
235
|
return pts
|
|
236
236
|
|
|
@@ -265,7 +265,7 @@ class Scte35Profile:
|
|
|
265
265
|
def _is_splice_insert_cueout(self, cue):
|
|
266
266
|
line = None
|
|
267
267
|
if cue.command.out_of_network_indicator:
|
|
268
|
-
if cue.command.
|
|
268
|
+
if cue.command.has("break_duration"):
|
|
269
269
|
duration = cue.command.break_duration
|
|
270
270
|
line = f"#EXT-X-CUE-OUT:{duration}\n"
|
|
271
271
|
return line
|
|
@@ -282,7 +282,7 @@ class Scte35Profile:
|
|
|
282
282
|
def _is_dscptr_cueout(self, dscptr, line):
|
|
283
283
|
if dscptr.segmentation_type_id in self.starts:
|
|
284
284
|
self.seg_type = dscptr.segmentation_type_id + 1
|
|
285
|
-
if dscptr.
|
|
285
|
+
if dscptr.has("segmentation_duration"):
|
|
286
286
|
duration = dscptr.segmentation_duration
|
|
287
287
|
line = f"#EXT-X-CUE-OUT:{duration}\n"
|
|
288
288
|
return line
|
|
@@ -808,7 +808,7 @@ class CuePuller:
|
|
|
808
808
|
found in a segment.
|
|
809
809
|
"""
|
|
810
810
|
for cue in seg.cues:
|
|
811
|
-
if cue.
|
|
811
|
+
if cue.has("packet_data"):
|
|
812
812
|
self.pts = cue.packet_data.pts
|
|
813
813
|
if cue.encode() != self.last_cue:
|
|
814
814
|
self.last_cue = cue.encode()
|