threefive3 3.0.3__tar.gz → 3.0.5__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.3 → threefive3-3.0.5}/PKG-INFO +12 -7
- {threefive3-3.0.3 → threefive3-3.0.5}/README.md +11 -6
- {threefive3-3.0.3 → threefive3-3.0.5}/bin/threefive3 +4 -3
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/cue.py +21 -21
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/iframes.py +2 -1
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/sixfix.py +32 -22
- threefive3-3.0.5/threefive3/sxp.py +79 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/version.py +1 -1
- threefive3-3.0.5/threefive3/x2c.py +236 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3.egg-info/PKG-INFO +12 -7
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3.egg-info/SOURCES.txt +1 -0
- threefive3-3.0.3/threefive3/sxp.py +0 -350
- {threefive3-3.0.3 → threefive3-3.0.5}/setup.cfg +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/setup.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/__init__.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/base.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/bitn.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/commands.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/crc.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/descriptors.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/hls.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/new_reader.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/packetdata.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/section.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/segment.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/segmentation.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/spare.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/stream.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/streamtypes.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/upids.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3/xml.py +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3.egg-info/dependency_links.txt +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3.egg-info/requires.txt +0 -0
- {threefive3-3.0.3 → threefive3-3.0.5}/threefive3.egg-info/top_level.txt +0 -0
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: threefive3
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.5
|
|
4
4
|
Summary: threefive continued.
|
|
5
5
|
Home-page: https://github.com/superkabuki/scte35
|
|
6
6
|
Author: Adrian of Doom
|
|
7
7
|
Author-email: spam@iodisco.com
|
|
8
8
|
License: UNKNOWN
|
|
9
|
-
Description: #
|
|
9
|
+
Description: # <s>threefive</s>
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
|
|
10
13
|
threefive continued. SCTE-35 for the People.
|
|
11
|
-
# Now with Super Advanced Error Detection Stuff.
|
|
14
|
+
# Now with Super Advanced Error Detection and Stuff.
|
|
12
15
|
* Does not generate Fatal errors, it won't break your process.
|
|
13
16
|
* Displays what is in error and how to correct it.
|
|
14
17
|
* Works in the cli
|
|
15
18
|
* Works in code.
|
|
16
19
|

|
|
17
20
|
|
|
21
|
+

|
|
18
22
|
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
22
24
|
# `Install`
|
|
23
25
|
* python3 via pip
|
|
24
26
|
```rebol
|
|
@@ -31,12 +33,11 @@ Description: # `threefive3`
|
|
|
31
33
|
* from the git repo
|
|
32
34
|
```rebol
|
|
33
35
|
git clone https://github.com/superkabuki/scte35.git
|
|
34
|
-
cd
|
|
36
|
+
cd scte35
|
|
35
37
|
make install
|
|
36
38
|
```
|
|
37
39
|
___
|
|
38
40
|
|
|
39
|
-
|
|
40
41
|
# `The Cli tool`
|
|
41
42
|
> The cli audetects data being available on 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.HLS requires the `hls` ketyword.
|
|
42
43
|
|
|
@@ -233,8 +234,12 @@ Description: # `threefive3`
|
|
|
233
234
|
```rebol
|
|
234
235
|
threefive3 help
|
|
235
236
|
```
|
|
237
|
+
## [iodisco.com/scte35](https://iodisco.com/scte35)
|
|
238
|
+
[
|
|
239
|
+
](https://iodisco.com/scte35)
|
|
236
240
|
___
|
|
237
241
|
|
|
242
|
+
|
|
238
243
|
Platform: UNKNOWN
|
|
239
244
|
Classifier: License :: OSI Approved :: Sleepycat License
|
|
240
245
|
Classifier: Environment :: Console
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
#
|
|
1
|
+
# <s>threefive</s>
|
|
2
|
+

|
|
3
|
+
|
|
4
|
+
|
|
2
5
|
threefive continued. SCTE-35 for the People.
|
|
3
|
-
# Now with Super Advanced Error Detection Stuff.
|
|
6
|
+
# Now with Super Advanced Error Detection and Stuff.
|
|
4
7
|
* Does not generate Fatal errors, it won't break your process.
|
|
5
8
|
* Displays what is in error and how to correct it.
|
|
6
9
|
* Works in the cli
|
|
7
10
|
* Works in code.
|
|
8
11
|

|
|
9
12
|
|
|
13
|
+

|
|
10
14
|
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
16
|
# `Install`
|
|
15
17
|
* python3 via pip
|
|
16
18
|
```rebol
|
|
@@ -23,12 +25,11 @@ pypy3 -mpip install threefive3
|
|
|
23
25
|
* from the git repo
|
|
24
26
|
```rebol
|
|
25
27
|
git clone https://github.com/superkabuki/scte35.git
|
|
26
|
-
cd
|
|
28
|
+
cd scte35
|
|
27
29
|
make install
|
|
28
30
|
```
|
|
29
31
|
___
|
|
30
32
|
|
|
31
|
-
|
|
32
33
|
# `The Cli tool`
|
|
33
34
|
> The cli audetects data being available on 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.HLS requires the `hls` ketyword.
|
|
34
35
|
|
|
@@ -225,4 +226,8 @@ ___
|
|
|
225
226
|
```rebol
|
|
226
227
|
threefive3 help
|
|
227
228
|
```
|
|
229
|
+
## [iodisco.com/scte35](https://iodisco.com/scte35)
|
|
230
|
+
[
|
|
231
|
+
](https://iodisco.com/scte35)
|
|
228
232
|
___
|
|
233
|
+
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/
|
|
1
|
+
#!/usr/bin/pypy3
|
|
2
2
|
|
|
3
3
|
"""
|
|
4
4
|
scte35 command line SCTE35 decoder.
|
|
@@ -308,6 +308,7 @@ def to_funk(this):
|
|
|
308
308
|
"""
|
|
309
309
|
to_funk prints a cue in a variety of formats.
|
|
310
310
|
"""
|
|
311
|
+
cue=None
|
|
311
312
|
if this in ["", b""]:
|
|
312
313
|
return
|
|
313
314
|
try:
|
|
@@ -319,8 +320,8 @@ def to_funk(this):
|
|
|
319
320
|
cue = Cue(this)
|
|
320
321
|
except:
|
|
321
322
|
print2("Bad Data")
|
|
322
|
-
|
|
323
|
-
|
|
323
|
+
if cue:
|
|
324
|
+
funk()(cue) # func works here too.
|
|
324
325
|
|
|
325
326
|
|
|
326
327
|
def chk_stdin(args):
|
|
@@ -13,25 +13,23 @@ from .descriptors import splice_descriptor, descriptor_map
|
|
|
13
13
|
from .crc import crc32
|
|
14
14
|
from .xml import Node
|
|
15
15
|
from .segmentation import table22
|
|
16
|
-
from .
|
|
17
|
-
|
|
16
|
+
from .x2c import xml2cue
|
|
18
17
|
|
|
19
18
|
class Cue(SCTE35Base):
|
|
20
19
|
"""
|
|
21
|
-
The threefive3.
|
|
20
|
+
The threefive3.Cue class handles parsing
|
|
22
21
|
SCTE 35 message strings.
|
|
23
22
|
Example usage:
|
|
24
23
|
|
|
25
|
-
>>>> import
|
|
24
|
+
>>>> import threefive3
|
|
26
25
|
>>>> Base64 = "/DAvAAAAAAAA///wBQb+dGKQoAAZAhdDVUVJSAAAjn+fCAgAAAAALKChijUCAKnMZ1g="
|
|
27
26
|
>>>> cue = threefive3.Cue(Base64)
|
|
27
|
+
>>>> cue.show()
|
|
28
|
+
|
|
29
|
+
* A cue instance can be initialized with
|
|
30
|
+
Base64, Bytes, Hex, Int, Json, Xml, or Xml+binary data.
|
|
28
31
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
>>>> cue.decode()
|
|
32
|
-
True
|
|
33
|
-
|
|
34
|
-
# After Calling cue.decode() the instance variables can be accessed via dot notation.
|
|
32
|
+
* Instance variables can be accessed via dot notation.
|
|
35
33
|
|
|
36
34
|
>>>> cue.command
|
|
37
35
|
{'command_length': 5, 'name': 'Time Signal', 'time_specified_flag': True,
|
|
@@ -40,10 +38,7 @@ class Cue(SCTE35Base):
|
|
|
40
38
|
>>>> cue.command.pts_time
|
|
41
39
|
21695.740089
|
|
42
40
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
'0xfc'
|
|
46
|
-
|
|
41
|
+
|
|
47
42
|
"""
|
|
48
43
|
|
|
49
44
|
def __init__(self, data=None, packet_data=None):
|
|
@@ -63,11 +58,13 @@ class Cue(SCTE35Base):
|
|
|
63
58
|
def __repr__(self):
|
|
64
59
|
return str(self.__dict__)
|
|
65
60
|
|
|
66
|
-
# decode
|
|
67
61
|
|
|
68
62
|
def decode(self):
|
|
69
63
|
"""
|
|
70
64
|
Cue.decode() parses for SCTE35 data
|
|
65
|
+
|
|
66
|
+
* decode doesn't need to be called directly
|
|
67
|
+
unless you initialize a Cue without data.
|
|
71
68
|
"""
|
|
72
69
|
bites = self.bites
|
|
73
70
|
self.descriptors = []
|
|
@@ -379,6 +376,10 @@ class Cue(SCTE35Base):
|
|
|
379
376
|
'command': {dict},
|
|
380
377
|
'descriptors': [list of {dicts}],
|
|
381
378
|
}
|
|
379
|
+
|
|
380
|
+
* load doesn't need to be called directly
|
|
381
|
+
unless you initialize a Cue without data.
|
|
382
|
+
|
|
382
383
|
"""
|
|
383
384
|
if isinstance(gonzo, bytes):
|
|
384
385
|
gonzo = gonzo.decode()
|
|
@@ -389,7 +390,7 @@ class Cue(SCTE35Base):
|
|
|
389
390
|
self.decode()
|
|
390
391
|
return self.bites
|
|
391
392
|
if gonzo.strip()[0] == "<":
|
|
392
|
-
self.
|
|
393
|
+
self._from_xml(gonzo)
|
|
393
394
|
return self.bites
|
|
394
395
|
gonzo = json.loads(gonzo)
|
|
395
396
|
if "command" not in gonzo:
|
|
@@ -400,13 +401,12 @@ class Cue(SCTE35Base):
|
|
|
400
401
|
self.encode()
|
|
401
402
|
return self.bites
|
|
402
403
|
|
|
403
|
-
def
|
|
404
|
+
def _from_xml(self,gonzo):
|
|
404
405
|
"""
|
|
405
|
-
|
|
406
|
-
|
|
406
|
+
_from_xml converts xml to data that can
|
|
407
|
+
be loaded by a Cue instance.
|
|
407
408
|
"""
|
|
408
|
-
|
|
409
|
-
dat = sxp.xml2cue(gonzo)
|
|
409
|
+
dat = xml2cue(gonzo)
|
|
410
410
|
if isinstance(
|
|
411
411
|
dat, str
|
|
412
412
|
): # a string is returned for Binary xml tag, make sense?
|
|
@@ -30,7 +30,8 @@ class PreFix(Stream):
|
|
|
30
30
|
super().decode(func=passed)
|
|
31
31
|
global fixme
|
|
32
32
|
fixme = list(set(fixme))
|
|
33
|
-
|
|
33
|
+
if fixme:
|
|
34
|
+
print("fixing these pids", fixme)
|
|
34
35
|
return fixme
|
|
35
36
|
|
|
36
37
|
|
|
@@ -57,26 +58,30 @@ class SixFix(Stream):
|
|
|
57
58
|
pkt = pkt[:4] + self.pmt_payload
|
|
58
59
|
return pkt
|
|
59
60
|
|
|
61
|
+
def _parse_pkts(self, out_file):
|
|
62
|
+
active = io.BytesIO()
|
|
63
|
+
pkt_count = 0
|
|
64
|
+
chunk_size = 2048
|
|
65
|
+
for pkt in self.iter_pkts():
|
|
66
|
+
pid = self._parse_pid(pkt[1], pkt[2])
|
|
67
|
+
pkt = self._parse_by_pid(pkt, pid)
|
|
68
|
+
active.write(pkt)
|
|
69
|
+
pkt_count = (pkt_count + 1) % chunk_size
|
|
70
|
+
if not pkt_count:
|
|
71
|
+
out_file.write(active.getbuffer())
|
|
72
|
+
active = io.BytesIO()
|
|
73
|
+
|
|
60
74
|
def convert_pids(self):
|
|
61
75
|
"""
|
|
62
76
|
convert_pids
|
|
63
77
|
changes the stream type to 0x86 and replaces
|
|
64
78
|
the existing PMT as it writes packets to the outfile
|
|
65
79
|
"""
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
self.
|
|
71
|
-
with self.out_file as out_file:
|
|
72
|
-
for pkt in self.iter_pkts():
|
|
73
|
-
pid = self._parse_pid(pkt[1], pkt[2])
|
|
74
|
-
pkt = self._parse_by_pid(pkt, pid)
|
|
75
|
-
active.write(pkt)
|
|
76
|
-
pkt_count = (pkt_count + 1) % chunk_size
|
|
77
|
-
if not pkt_count:
|
|
78
|
-
out_file.write(active.getbuffer())
|
|
79
|
-
active = io.BytesIO()
|
|
80
|
+
|
|
81
|
+
#if isinstance(self.out_file, str):
|
|
82
|
+
# self.out_file = open(self.out_file, "wb")
|
|
83
|
+
with open(self.out_file,"wb") as out_file:
|
|
84
|
+
self._parse_pkts(out_file)
|
|
80
85
|
|
|
81
86
|
def _regen_pmt(self, n_seclen, pcr_pid, n_proginfolen, n_info_bites, n_streams):
|
|
82
87
|
nbin = NBin()
|
|
@@ -106,17 +111,22 @@ class SixFix(Stream):
|
|
|
106
111
|
n_payload = pointer_field + n_payload + (b"\xff" * pad)
|
|
107
112
|
self.pmt_payload = n_payload
|
|
108
113
|
|
|
114
|
+
def _chk_payload(self, pay,pid):
|
|
115
|
+
pay = self._chk_partial(pay, pid, self._PMT_TID)
|
|
116
|
+
if not pay:
|
|
117
|
+
return False
|
|
118
|
+
return pay
|
|
119
|
+
|
|
109
120
|
def _parse_pmt(self, pay, pid):
|
|
110
121
|
"""
|
|
111
122
|
parse program maps for streams
|
|
112
123
|
"""
|
|
113
|
-
pay = self.
|
|
114
|
-
if
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return False
|
|
124
|
+
pay = self._chk_payload(pay,pid)
|
|
125
|
+
if pay:
|
|
126
|
+
seclen = self._parse_length(pay[1], pay[2])
|
|
127
|
+
n_seclen = seclen + 6
|
|
128
|
+
if self._section_incomplete(pay, pid, seclen):
|
|
129
|
+
return False
|
|
120
130
|
program_number = self._parse_program(pay[3], pay[4])
|
|
121
131
|
pcr_pid = self._parse_pid(pay[8], pay[9])
|
|
122
132
|
self.pids.pcr.add(pcr_pid)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"""
|
|
2
|
+
sxp.py
|
|
3
|
+
home of the SuperXmlParser class
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from xml.sax.saxutils import escape, unescape
|
|
8
|
+
from .xml import t2s, un_camel, un_xml, strip_ns, iter_attrs
|
|
9
|
+
|
|
10
|
+
class SuperXmlParser:
|
|
11
|
+
|
|
12
|
+
CHILD_NODES=[
|
|
13
|
+
"Program",
|
|
14
|
+
"SpliceTime",
|
|
15
|
+
"DeliveryRestrictions",
|
|
16
|
+
"SegmentationUpid",
|
|
17
|
+
"BreakDuration",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
def _split_attrs(self, node):
|
|
21
|
+
node = node.replace("='", '="').replace("' ", '" ')
|
|
22
|
+
attrs = [x for x in node.split(" ") if "=" in x]
|
|
23
|
+
return attrs
|
|
24
|
+
|
|
25
|
+
def mk_attrs(self, node):
|
|
26
|
+
"""
|
|
27
|
+
mk_attrs parses the current node for attributes
|
|
28
|
+
and stores them in self.stuff[self.active]
|
|
29
|
+
"""
|
|
30
|
+
attrs = {}
|
|
31
|
+
try:
|
|
32
|
+
attrs = self._split_attrs(node)
|
|
33
|
+
parsed = {
|
|
34
|
+
x.split('="')[0]: unescape(x.split('="')[1].split('"')[0])
|
|
35
|
+
for x in attrs
|
|
36
|
+
}
|
|
37
|
+
attrs = iter_attrs(parsed)
|
|
38
|
+
finally:
|
|
39
|
+
return attrs
|
|
40
|
+
|
|
41
|
+
def mk_tag(self, data):
|
|
42
|
+
"""
|
|
43
|
+
mk_tag parse out the
|
|
44
|
+
next available xml tag from data
|
|
45
|
+
"""
|
|
46
|
+
tag = data[1:].split(" ", 1)[0].split(">", 1)[0]
|
|
47
|
+
return strip_ns(tag.strip())
|
|
48
|
+
|
|
49
|
+
def _vrfy_sp(self, sp):
|
|
50
|
+
if sp and sp[0] not in ["!", "/"]:
|
|
51
|
+
return True
|
|
52
|
+
return False
|
|
53
|
+
|
|
54
|
+
def _mk_value(self, sp):
|
|
55
|
+
return sp.split(">")[1].replace("\n", "").strip()
|
|
56
|
+
|
|
57
|
+
def _assemble(self, sp):
|
|
58
|
+
return {
|
|
59
|
+
"name": self.mk_tag(sp),
|
|
60
|
+
"attrs": self.mk_attrs(sp),
|
|
61
|
+
"this": self._mk_value(sp),
|
|
62
|
+
"children": [],
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
def fu(self, exemel):
|
|
66
|
+
"""
|
|
67
|
+
fu slice up exemel into data chunks.
|
|
68
|
+
"""
|
|
69
|
+
results = []
|
|
70
|
+
splitted = exemel.split("<")
|
|
71
|
+
exemel = exemel.replace("\n", "").strip()
|
|
72
|
+
for sp in splitted:
|
|
73
|
+
if self._vrfy_sp(sp):
|
|
74
|
+
x = self._assemble(sp)
|
|
75
|
+
if x["name"] in self.CHILD_NODES:
|
|
76
|
+
results[-1]["children"].append(x)
|
|
77
|
+
else:
|
|
78
|
+
results.append(x)
|
|
79
|
+
return results
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
"""
|
|
2
|
+
x2c.py xml to cue conversion
|
|
3
|
+
"""
|
|
4
|
+
from .descriptors import descriptor_map, k_by_v
|
|
5
|
+
from .segmentation import table20, table22
|
|
6
|
+
from .sxp import SuperXmlParser
|
|
7
|
+
from .upids import upid_map
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def _spliceinfosection(sis):
|
|
11
|
+
"""
|
|
12
|
+
spliceinfosection parses exemel for info section data
|
|
13
|
+
and returns a loadable dict
|
|
14
|
+
"""
|
|
15
|
+
return sis["attrs"]
|
|
16
|
+
|
|
17
|
+
def _command(results):
|
|
18
|
+
"""
|
|
19
|
+
command parses exemel for a splice command
|
|
20
|
+
and returns a loadable dict
|
|
21
|
+
|
|
22
|
+
"""
|
|
23
|
+
cmap = {
|
|
24
|
+
"TimeSignal": _timesignal,
|
|
25
|
+
"SpliceInsert": _spliceinsert,
|
|
26
|
+
"PrivateCommand": _privatecommand,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
for result in results:
|
|
30
|
+
if result["name"] in cmap:
|
|
31
|
+
return cmap[result["name"]](result)
|
|
32
|
+
return {}
|
|
33
|
+
|
|
34
|
+
def _timesignal_children(ts):
|
|
35
|
+
for child in ts["children"]:
|
|
36
|
+
splice_time = _splicetime(child)
|
|
37
|
+
ts["attrs"].update(splice_time)
|
|
38
|
+
return ts
|
|
39
|
+
|
|
40
|
+
def _timesignal( ts):
|
|
41
|
+
"""
|
|
42
|
+
timesignal parses exemel for TimeSignal data
|
|
43
|
+
and creates a loadable dict for the Cue class.
|
|
44
|
+
"""
|
|
45
|
+
setme = {
|
|
46
|
+
"name": "Time Signal",
|
|
47
|
+
"command_type": 6,
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ts["attrs"].update(setme)
|
|
51
|
+
ts = _timesignal_children(ts)
|
|
52
|
+
return ts["attrs"]
|
|
53
|
+
|
|
54
|
+
def _privatecommand( pc):
|
|
55
|
+
"""
|
|
56
|
+
privatecommand parses exemel for PrivateCommand
|
|
57
|
+
data and creates a loadable dict for the Cue class.
|
|
58
|
+
"""
|
|
59
|
+
setme = {
|
|
60
|
+
"command_type": 255,
|
|
61
|
+
"private_bytes": pc["this"],
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
pc["attrs"].update(setme)
|
|
65
|
+
return pc["attrs"]
|
|
66
|
+
|
|
67
|
+
def _spliceinsert_children(si):
|
|
68
|
+
for child in si["children"]:
|
|
69
|
+
splice_time = _splicetime(child)
|
|
70
|
+
si["attrs"].update(splice_time)
|
|
71
|
+
if "pts_time" in si["attrs"]:
|
|
72
|
+
si["attrs"]["program_splice_flag"] = True
|
|
73
|
+
break_duration = _breakduration(child)
|
|
74
|
+
si["attrs"].update(break_duration)
|
|
75
|
+
return si
|
|
76
|
+
|
|
77
|
+
def _spliceinsert( si):
|
|
78
|
+
"""
|
|
79
|
+
spliceinsert parses exemel for SpliceInsert data
|
|
80
|
+
and creates a loadable dict for the Cue class.
|
|
81
|
+
"""
|
|
82
|
+
setme = {
|
|
83
|
+
"command_type": 5,
|
|
84
|
+
"event_id_compliance_flag": True,
|
|
85
|
+
"program_splice_flag": False,
|
|
86
|
+
"duration_flag": False,
|
|
87
|
+
}
|
|
88
|
+
si["attrs"].update(setme)
|
|
89
|
+
si = _spliceinsert_children(si)
|
|
90
|
+
return si["attrs"]
|
|
91
|
+
|
|
92
|
+
def _splicetime( st):
|
|
93
|
+
"""
|
|
94
|
+
splicetime parses xml from a splice command
|
|
95
|
+
to get pts_time, sets time_specified_flag to True
|
|
96
|
+
"""
|
|
97
|
+
if st["name"] == "SpliceTime":
|
|
98
|
+
return {
|
|
99
|
+
"pts_time": st["attrs"]["pts_time"],
|
|
100
|
+
"time_specified_flag": True,
|
|
101
|
+
}
|
|
102
|
+
return {}
|
|
103
|
+
|
|
104
|
+
def _breakduration( bd):
|
|
105
|
+
"""
|
|
106
|
+
breakduration parses xml for break duration, break_auto_return
|
|
107
|
+
and sets duration_flag to True.
|
|
108
|
+
"""
|
|
109
|
+
if bd["name"] == "BreakDuration":
|
|
110
|
+
return {
|
|
111
|
+
"break_duration": bd["attrs"]["duration"],
|
|
112
|
+
"break_auto_return": bd["attrs"]["auto_return"],
|
|
113
|
+
"duration_flag": True,
|
|
114
|
+
}
|
|
115
|
+
return {}
|
|
116
|
+
|
|
117
|
+
def _segmentationdescriptor_children(dscptr):
|
|
118
|
+
for child in dscptr["children"]:
|
|
119
|
+
dr = _deliveryrestrictions(child)
|
|
120
|
+
dscptr["attrs"].update(dr)
|
|
121
|
+
the_upid = _upid(child)
|
|
122
|
+
dscptr["attrs"].update(the_upid)
|
|
123
|
+
return dscptr
|
|
124
|
+
|
|
125
|
+
def _segmentation_message(dscptr):
|
|
126
|
+
if dscptr["attrs"]["segmentation_type_id"] in table22:
|
|
127
|
+
dscptr["attrs"]["segmentation_message"] = table22[
|
|
128
|
+
dscptr["attrs"]["segmentation_type_id"]
|
|
129
|
+
]
|
|
130
|
+
return dscptr
|
|
131
|
+
|
|
132
|
+
def _segmentationdescriptor( dscptr):
|
|
133
|
+
"""
|
|
134
|
+
segmentationdescriptor creates a dict to be loaded.
|
|
135
|
+
"""
|
|
136
|
+
setme = {
|
|
137
|
+
"tag": 2,
|
|
138
|
+
"identifier": "CUEI",
|
|
139
|
+
"name": "Segmentation Descriptor",
|
|
140
|
+
"segmentation_event_id_compliance_indicator": True,
|
|
141
|
+
"program_segmentation_flag": True,
|
|
142
|
+
"segmentation_duration_flag": False,
|
|
143
|
+
"delivery_not_restricted_flag": True,
|
|
144
|
+
"segmentation_event_id": hex(dscptr["attrs"]["segmentation_event_id"]),
|
|
145
|
+
}
|
|
146
|
+
dscptr["attrs"].update(setme)
|
|
147
|
+
dscptr = _segmentation_message(dscptr)
|
|
148
|
+
dscptr = _segmentationdescriptor_children(dscptr)
|
|
149
|
+
return dscptr["attrs"]
|
|
150
|
+
|
|
151
|
+
def _upid(a_upid):
|
|
152
|
+
"""
|
|
153
|
+
upids parses out upids from a splice descriptors xml
|
|
154
|
+
"""
|
|
155
|
+
if a_upid["name"] == "SegmentationUpid":
|
|
156
|
+
try:
|
|
157
|
+
seg_upid = bytes.fromhex(a_upid["this"].lower().replace("0x", ""))
|
|
158
|
+
except ValueError:
|
|
159
|
+
seg_upid = a_upid["this"]
|
|
160
|
+
seg_upid_type = a_upid["attrs"]["segmentation_upid_type"]
|
|
161
|
+
return {
|
|
162
|
+
"segmentation_upid": a_upid["this"],
|
|
163
|
+
"segmentation_upid_type": seg_upid_type,
|
|
164
|
+
"segmentation_upid_type_name": upid_map[seg_upid_type][0],
|
|
165
|
+
"segmentation_upid_length": len(seg_upid),
|
|
166
|
+
}
|
|
167
|
+
return {}
|
|
168
|
+
|
|
169
|
+
def _availdescriptor( dscptr):
|
|
170
|
+
setme = {
|
|
171
|
+
"tag": 0,
|
|
172
|
+
"identifier": "CUEI",
|
|
173
|
+
}
|
|
174
|
+
dscptr["attrs"].update(setme)
|
|
175
|
+
return dscptr["attrs"]
|
|
176
|
+
|
|
177
|
+
## def dtmfdescriptor(dscptr)
|
|
178
|
+
## """
|
|
179
|
+
## Load an DTMFDescriptor from XML
|
|
180
|
+
## """
|
|
181
|
+
## setme={"tag": 1,
|
|
182
|
+
## "identifier": "CUEI",
|
|
183
|
+
## "name":my_name,}
|
|
184
|
+
## gonzo["DTMFDescriptor"]["dtmf_chars"] = gonzo["DTMFDescriptor"].pop("chars")
|
|
185
|
+
## self.load(gonzo["DTMFDescriptor"])
|
|
186
|
+
## self.dtmf_count = len(self.dtmf_chars)
|
|
187
|
+
|
|
188
|
+
def _timedescriptor( dscptr):
|
|
189
|
+
setme = {
|
|
190
|
+
"tag": 3,
|
|
191
|
+
"identifier": "CUEI",
|
|
192
|
+
}
|
|
193
|
+
dscptr["attrs"].update(setme)
|
|
194
|
+
return dscptr["attrs"]
|
|
195
|
+
|
|
196
|
+
def _descriptors( results):
|
|
197
|
+
dmap = {
|
|
198
|
+
"AvailDescriptor": _availdescriptor,
|
|
199
|
+
# "DTMFDescriptor",
|
|
200
|
+
"SegmentationDescriptor": _segmentationdescriptor,
|
|
201
|
+
"TimeDescriptor": _timedescriptor,
|
|
202
|
+
}
|
|
203
|
+
out = []
|
|
204
|
+
for result in results:
|
|
205
|
+
if result["name"] in dmap:
|
|
206
|
+
out.append(dmap[result["name"]](result))
|
|
207
|
+
return out
|
|
208
|
+
|
|
209
|
+
def _deliveryrestrictions( dr):
|
|
210
|
+
if dr["name"] == "DeliveryRestrictions":
|
|
211
|
+
setme = {
|
|
212
|
+
"delivery_not_restricted_flag": False,
|
|
213
|
+
"device_restrictions": table20[dr["attrs"]["device_restrictions"]],
|
|
214
|
+
}
|
|
215
|
+
dr["attrs"].update(setme)
|
|
216
|
+
return dr["attrs"]
|
|
217
|
+
return {}
|
|
218
|
+
|
|
219
|
+
def xml2cue( exemel):
|
|
220
|
+
"""
|
|
221
|
+
xml2cue returns a base64 string for xmlbin
|
|
222
|
+
and a dict for xml
|
|
223
|
+
"""
|
|
224
|
+
sxp=SuperXmlParser()
|
|
225
|
+
results = sxp.fu(exemel)
|
|
226
|
+
for result in results:
|
|
227
|
+
if result["name"] == "Binary":
|
|
228
|
+
return result["this"]
|
|
229
|
+
if result["name"] == "SpliceInfoSection":
|
|
230
|
+
splice_info = _spliceinfosection(result)
|
|
231
|
+
return {
|
|
232
|
+
"info_section": splice_info,
|
|
233
|
+
"command": _command(results),
|
|
234
|
+
"descriptors": _descriptors(results),
|
|
235
|
+
}
|
|
236
|
+
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: threefive3
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.5
|
|
4
4
|
Summary: threefive continued.
|
|
5
5
|
Home-page: https://github.com/superkabuki/scte35
|
|
6
6
|
Author: Adrian of Doom
|
|
7
7
|
Author-email: spam@iodisco.com
|
|
8
8
|
License: UNKNOWN
|
|
9
|
-
Description: #
|
|
9
|
+
Description: # <s>threefive</s>
|
|
10
|
+

|
|
11
|
+
|
|
12
|
+
|
|
10
13
|
threefive continued. SCTE-35 for the People.
|
|
11
|
-
# Now with Super Advanced Error Detection Stuff.
|
|
14
|
+
# Now with Super Advanced Error Detection and Stuff.
|
|
12
15
|
* Does not generate Fatal errors, it won't break your process.
|
|
13
16
|
* Displays what is in error and how to correct it.
|
|
14
17
|
* Works in the cli
|
|
15
18
|
* Works in code.
|
|
16
19
|

|
|
17
20
|
|
|
21
|
+

|
|
18
22
|
|
|
19
23
|
|
|
20
|
-
|
|
21
|
-
|
|
22
24
|
# `Install`
|
|
23
25
|
* python3 via pip
|
|
24
26
|
```rebol
|
|
@@ -31,12 +33,11 @@ Description: # `threefive3`
|
|
|
31
33
|
* from the git repo
|
|
32
34
|
```rebol
|
|
33
35
|
git clone https://github.com/superkabuki/scte35.git
|
|
34
|
-
cd
|
|
36
|
+
cd scte35
|
|
35
37
|
make install
|
|
36
38
|
```
|
|
37
39
|
___
|
|
38
40
|
|
|
39
|
-
|
|
40
41
|
# `The Cli tool`
|
|
41
42
|
> The cli audetects data being available on 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.HLS requires the `hls` ketyword.
|
|
42
43
|
|
|
@@ -233,8 +234,12 @@ Description: # `threefive3`
|
|
|
233
234
|
```rebol
|
|
234
235
|
threefive3 help
|
|
235
236
|
```
|
|
237
|
+
## [iodisco.com/scte35](https://iodisco.com/scte35)
|
|
238
|
+
[
|
|
239
|
+
](https://iodisco.com/scte35)
|
|
236
240
|
___
|
|
237
241
|
|
|
242
|
+
|
|
238
243
|
Platform: UNKNOWN
|
|
239
244
|
Classifier: License :: OSI Approved :: Sleepycat License
|
|
240
245
|
Classifier: Environment :: Console
|
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
sxp.py
|
|
3
|
-
home of the SuperXmlParser class
|
|
4
|
-
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from xml.sax.saxutils import escape, unescape
|
|
8
|
-
from .xml import t2s, un_camel, un_xml, strip_ns, iter_attrs
|
|
9
|
-
from .descriptors import descriptor_map, k_by_v
|
|
10
|
-
from .segmentation import table20, table22
|
|
11
|
-
from .upids import upid_map
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
class SuperXmlParser:
|
|
15
|
-
|
|
16
|
-
def _split_attrs(self, node):
|
|
17
|
-
node = node.replace("='", '="').replace("' ", '" ')
|
|
18
|
-
attrs = [x for x in node.split(" ") if "=" in x]
|
|
19
|
-
return attrs
|
|
20
|
-
|
|
21
|
-
def mk_attrs(self, node):
|
|
22
|
-
"""
|
|
23
|
-
mk_attrs parses the current node for attributes
|
|
24
|
-
and stores them in self.stuff[self.active]
|
|
25
|
-
"""
|
|
26
|
-
if "!--" in node:
|
|
27
|
-
return False
|
|
28
|
-
attrs = self._split_attrs(node)
|
|
29
|
-
parsed = {
|
|
30
|
-
x.split('="')[0]: unescape(x.split('="')[1].split('"')[0]) for x in attrs
|
|
31
|
-
}
|
|
32
|
-
it = iter_attrs(parsed)
|
|
33
|
-
return it
|
|
34
|
-
|
|
35
|
-
def parsed(self, tag, sub_data):
|
|
36
|
-
"""
|
|
37
|
-
parsed returns tag, attrs and value
|
|
38
|
-
for an xml element
|
|
39
|
-
"""
|
|
40
|
-
value = ""
|
|
41
|
-
attrs = {}
|
|
42
|
-
if tag[0] != "/":
|
|
43
|
-
tag = strip_ns(tag)
|
|
44
|
-
o_data = sub_data
|
|
45
|
-
if ">" in sub_data:
|
|
46
|
-
ridx = sub_data.index(">")
|
|
47
|
-
this_node = sub_data[: ridx + 1]
|
|
48
|
-
attrs = self.mk_attrs(this_node)
|
|
49
|
-
sub_data = sub_data[ridx + 1 :]
|
|
50
|
-
if "<" in sub_data:
|
|
51
|
-
lidx = sub_data.index("<")
|
|
52
|
-
value = sub_data[:lidx].strip()
|
|
53
|
-
sub_data = sub_data[lidx:].replace("\t", "")
|
|
54
|
-
return {
|
|
55
|
-
"tag": tag,
|
|
56
|
-
"attrs": attrs,
|
|
57
|
-
"this": value,
|
|
58
|
-
"xml": o_data,
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
def mk_tag(self, data):
|
|
62
|
-
"""
|
|
63
|
-
mk_tag parse out the
|
|
64
|
-
next available xml tag from data
|
|
65
|
-
"""
|
|
66
|
-
tag = data[1:].split(" ", 1)[0].split(">", 1)[0]
|
|
67
|
-
return tag.strip()
|
|
68
|
-
|
|
69
|
-
def mk_element(self, data, tag):
|
|
70
|
-
"""
|
|
71
|
-
mk_element slices out the tag element
|
|
72
|
-
inclusive: <tag > stuff</tag> and <tag attr="1"/>
|
|
73
|
-
"""
|
|
74
|
-
try:
|
|
75
|
-
return data[: data.index(f"</{tag}>") + len(tag) + 2]
|
|
76
|
-
except:
|
|
77
|
-
return data[: data.index("/>") + 1]
|
|
78
|
-
|
|
79
|
-
def mk(self, exemel, target="SpliceInfoSection"):
|
|
80
|
-
"""
|
|
81
|
-
parse parses an xml string for a SCTE-35 Cue.
|
|
82
|
-
"""
|
|
83
|
-
results = []
|
|
84
|
-
sub_data = None
|
|
85
|
-
data = exemel.replace("\n", "").strip()
|
|
86
|
-
while data:
|
|
87
|
-
sub_data = None
|
|
88
|
-
tag = self.mk_tag(data)
|
|
89
|
-
if target in tag: # don't even consider namespace
|
|
90
|
-
sub_data = self.mk_element(data, tag)
|
|
91
|
-
results.append(sub_data + ">")
|
|
92
|
-
data = data.replace(sub_data, "")
|
|
93
|
-
else:
|
|
94
|
-
data = data.split(">", 1)[1]
|
|
95
|
-
if "<" in data:
|
|
96
|
-
data = data[data.index("<") :]
|
|
97
|
-
else:
|
|
98
|
-
return results
|
|
99
|
-
|
|
100
|
-
def gimme(self, tags, exemel):
|
|
101
|
-
"""
|
|
102
|
-
gimme get all instances of tag from exemel and return a list of them.
|
|
103
|
-
"""
|
|
104
|
-
the_list = []
|
|
105
|
-
for tag in tags:
|
|
106
|
-
element_list = [self.parsed(tag, sd) for sd in self.mk(exemel, tag)]
|
|
107
|
-
if element_list:
|
|
108
|
-
the_list.extend(element_list)
|
|
109
|
-
return the_list
|
|
110
|
-
|
|
111
|
-
def gimme_one(self, tag, exemel):
|
|
112
|
-
"""
|
|
113
|
-
gimme_one get the first instance of tag from exemel and return it.
|
|
114
|
-
"""
|
|
115
|
-
one = self.gimme([tag], exemel)
|
|
116
|
-
if one:
|
|
117
|
-
return one[0]
|
|
118
|
-
|
|
119
|
-
def spliceinfosection(self, exemel):
|
|
120
|
-
"""
|
|
121
|
-
spliceinfosection parses exemel for info section data
|
|
122
|
-
and returns a loadable dict
|
|
123
|
-
"""
|
|
124
|
-
my_name = "SpliceInfoSection"
|
|
125
|
-
|
|
126
|
-
out = self.gimme_one(my_name, exemel)
|
|
127
|
-
if out:
|
|
128
|
-
return out["attrs"]
|
|
129
|
-
return {}
|
|
130
|
-
|
|
131
|
-
def command(self, exemel):
|
|
132
|
-
"""
|
|
133
|
-
command parses exemel for a splice command
|
|
134
|
-
and returns a loadable dict
|
|
135
|
-
|
|
136
|
-
"""
|
|
137
|
-
ts = self.timesignal(exemel)
|
|
138
|
-
if ts:
|
|
139
|
-
return ts
|
|
140
|
-
si = self.spliceinsert(exemel)
|
|
141
|
-
if si:
|
|
142
|
-
return si
|
|
143
|
-
pc = self.privatecommand(exemel)
|
|
144
|
-
if pc:
|
|
145
|
-
return pc
|
|
146
|
-
return {}
|
|
147
|
-
|
|
148
|
-
def timesignal(self, exemel):
|
|
149
|
-
"""
|
|
150
|
-
timesignal parses exemel for TimeSignal data
|
|
151
|
-
and creates a loadable dict for the Cue class.
|
|
152
|
-
"""
|
|
153
|
-
my_name = "TimeSignal"
|
|
154
|
-
ts = self.gimme_one("TimeSignal", exemel)
|
|
155
|
-
if ts:
|
|
156
|
-
splice_time = self.splicetime(ts["xml"])
|
|
157
|
-
ts["attrs"].update(splice_time)
|
|
158
|
-
setme = {
|
|
159
|
-
"name": "Time Signal",
|
|
160
|
-
"command_type": 6,
|
|
161
|
-
}
|
|
162
|
-
ts["attrs"].update(setme)
|
|
163
|
-
return ts["attrs"]
|
|
164
|
-
return {}
|
|
165
|
-
|
|
166
|
-
def privatecommand(self, exemel):
|
|
167
|
-
"""
|
|
168
|
-
privatecommand parses exemel for PrivateCommand
|
|
169
|
-
data and creates a loadable dict for the Cue class.
|
|
170
|
-
"""
|
|
171
|
-
my_name = "PrivateCommand"
|
|
172
|
-
pc = self.gimme_one("PrivateCommand", exemel)
|
|
173
|
-
if pc:
|
|
174
|
-
setme = {
|
|
175
|
-
"name": "Private Command",
|
|
176
|
-
"command_type": 255,
|
|
177
|
-
"private_bytes": pc["this"],
|
|
178
|
-
}
|
|
179
|
-
pc["attrs"].update(setme)
|
|
180
|
-
return pc["attrs"]
|
|
181
|
-
return {}
|
|
182
|
-
|
|
183
|
-
def spliceinsert(self, exemel):
|
|
184
|
-
"""
|
|
185
|
-
spliceinsert parses exemel for SpliceInsert data
|
|
186
|
-
and creates a loadable dict for the Cue class.
|
|
187
|
-
"""
|
|
188
|
-
my_name = "SpliceInsert"
|
|
189
|
-
si = self.gimme_one(my_name, exemel)
|
|
190
|
-
if si:
|
|
191
|
-
setme = {
|
|
192
|
-
"name": my_name,
|
|
193
|
-
"command_type": 5,
|
|
194
|
-
"event_id_compliance_flag": True,
|
|
195
|
-
"program_splice_flag": False,
|
|
196
|
-
"duration_flag": False,
|
|
197
|
-
}
|
|
198
|
-
splice_time = self.splicetime(exemel)
|
|
199
|
-
if splice_time:
|
|
200
|
-
setme["program_splice_flag"] = True
|
|
201
|
-
si["attrs"].update(setme)
|
|
202
|
-
si["attrs"].update(splice_time)
|
|
203
|
-
break_duration = self.breakduration(exemel)
|
|
204
|
-
si["attrs"].update(break_duration)
|
|
205
|
-
return si["attrs"]
|
|
206
|
-
return {}
|
|
207
|
-
|
|
208
|
-
def splicetime(self, exemel):
|
|
209
|
-
"""
|
|
210
|
-
splicetime parses xml from a splice command
|
|
211
|
-
to get pts_time, sets time_specified_flag to True
|
|
212
|
-
"""
|
|
213
|
-
splicetime = self.gimme_one("SpliceTime", exemel)
|
|
214
|
-
if splicetime:
|
|
215
|
-
return {
|
|
216
|
-
"pts_time": splicetime["attrs"]["pts_time"],
|
|
217
|
-
"time_specified_flag": True,
|
|
218
|
-
}
|
|
219
|
-
return {}
|
|
220
|
-
|
|
221
|
-
def breakduration(self, exemel):
|
|
222
|
-
"""
|
|
223
|
-
breakduration parses xml for break duration, break_auto_return
|
|
224
|
-
and sets duration_flag to True.
|
|
225
|
-
"""
|
|
226
|
-
break_duration = self.gimme_one("BreakDuration", exemel)
|
|
227
|
-
if break_duration:
|
|
228
|
-
return {
|
|
229
|
-
"break_duration": break_duration["attrs"]["duration"],
|
|
230
|
-
"break_auto_return": break_duration["attrs"]["auto_return"],
|
|
231
|
-
"duration_flag": True,
|
|
232
|
-
}
|
|
233
|
-
return {}
|
|
234
|
-
|
|
235
|
-
def segmentationdescriptor(self, dscptr):
|
|
236
|
-
"""
|
|
237
|
-
segmentationdescriptor creates a dict to be loaded.
|
|
238
|
-
"""
|
|
239
|
-
my_name = "SegmentationDescriptor"
|
|
240
|
-
setme = {
|
|
241
|
-
"tag": 2,
|
|
242
|
-
"identifier": "CUEI",
|
|
243
|
-
"name": "Segmentation Descriptor",
|
|
244
|
-
"segmentation_event_id_compliance_indicator": True,
|
|
245
|
-
"program_segmentation_flag": True,
|
|
246
|
-
"segmentation_duration_flag": False,
|
|
247
|
-
"delivery_not_restricted_flag": True,
|
|
248
|
-
"segmentation_event_id": hex(dscptr["attrs"]["segmentation_event_id"]),
|
|
249
|
-
}
|
|
250
|
-
if dscptr["attrs"]["segmentation_type_id"] in table22:
|
|
251
|
-
dscptr["attrs"]["segmentation_message"] = table22[
|
|
252
|
-
dscptr["attrs"]["segmentation_type_id"]
|
|
253
|
-
]
|
|
254
|
-
dscptr["attrs"].update(setme)
|
|
255
|
-
dr = self.deliveryrestrictions(dscptr["xml"])
|
|
256
|
-
dscptr["attrs"].update(dr)
|
|
257
|
-
the_upid = self.upids(dscptr["xml"])
|
|
258
|
-
dscptr["attrs"].update(the_upid)
|
|
259
|
-
return dscptr["attrs"]
|
|
260
|
-
|
|
261
|
-
def upids(self, exemel):
|
|
262
|
-
"""
|
|
263
|
-
upids parses out upids from a splice descriptors xml
|
|
264
|
-
"""
|
|
265
|
-
ulist = self.gimme(["SegmentationUpid"], exemel)
|
|
266
|
-
if len(ulist) == 1:
|
|
267
|
-
try:
|
|
268
|
-
seg_upid = bytes.fromhex(ulist[0]["this"].lower().replace("0x", ""))
|
|
269
|
-
except ValueError:
|
|
270
|
-
seg_upid = ulist[0]["this"]
|
|
271
|
-
seg_upid_type = ulist[0]["attrs"]["segmentation_upid_type"]
|
|
272
|
-
the_upid = {
|
|
273
|
-
"segmentation_upid": ulist[0]["this"],
|
|
274
|
-
"segmentation_upid_type": seg_upid_type,
|
|
275
|
-
"segmentation_upid_type_name": upid_map[seg_upid_type][0],
|
|
276
|
-
"segmentation_upid_length": len(seg_upid),
|
|
277
|
-
}
|
|
278
|
-
return the_upid
|
|
279
|
-
|
|
280
|
-
def availdescriptor(self, dscptr):
|
|
281
|
-
my_name = "AvailDescriptor"
|
|
282
|
-
setme = {
|
|
283
|
-
"tag": 0,
|
|
284
|
-
"identifier": "CUEI",
|
|
285
|
-
"name": my_name,
|
|
286
|
-
}
|
|
287
|
-
dscptr["attrs"].update(setme)
|
|
288
|
-
return dscptr["attrs"]
|
|
289
|
-
|
|
290
|
-
## def dtmfdescriptor(self,dscptr)
|
|
291
|
-
## """
|
|
292
|
-
## Load an DTMFDescriptor from XML
|
|
293
|
-
## """
|
|
294
|
-
## setme={"tag": 1,
|
|
295
|
-
## "identifier": "CUEI",
|
|
296
|
-
## "name":my_name,}
|
|
297
|
-
## gonzo["DTMFDescriptor"]["dtmf_chars"] = gonzo["DTMFDescriptor"].pop("chars")
|
|
298
|
-
## self.load(gonzo["DTMFDescriptor"])
|
|
299
|
-
## self.dtmf_count = len(self.dtmf_chars)
|
|
300
|
-
|
|
301
|
-
def timedescriptor(self, dscptr):
|
|
302
|
-
my_name = "TimeDescriptor"
|
|
303
|
-
setme = {
|
|
304
|
-
"tag": 3,
|
|
305
|
-
"identifier": "CUEI",
|
|
306
|
-
"name": my_name,
|
|
307
|
-
}
|
|
308
|
-
dscptr["attrs"].update(setme)
|
|
309
|
-
return dscptr["attrs"]
|
|
310
|
-
|
|
311
|
-
def descriptors(self, exemel):
|
|
312
|
-
dmap = {
|
|
313
|
-
"AvailDescriptor": self.availdescriptor,
|
|
314
|
-
# "DTMFDescriptor",
|
|
315
|
-
"SegmentationDescriptor": self.segmentationdescriptor,
|
|
316
|
-
# "TimeDescriptor",
|
|
317
|
-
}
|
|
318
|
-
out = []
|
|
319
|
-
dlist = self.gimme(list(dmap.keys()), exemel)
|
|
320
|
-
for dscptr in dlist:
|
|
321
|
-
out.append(dmap[dscptr["tag"]](dscptr))
|
|
322
|
-
return out
|
|
323
|
-
|
|
324
|
-
def deliveryrestrictions(self, exemel):
|
|
325
|
-
dr = self.gimme_one("DeliveryRestrictions", exemel)
|
|
326
|
-
if dr:
|
|
327
|
-
setme = {
|
|
328
|
-
"delivery_not_restricted_flag": False,
|
|
329
|
-
"device_restrictions": table20[dr["attrs"]["device_restrictions"]],
|
|
330
|
-
}
|
|
331
|
-
dr["attrs"].update(setme)
|
|
332
|
-
return dr["attrs"]
|
|
333
|
-
return {}
|
|
334
|
-
|
|
335
|
-
def xml2cue(self, exemel):
|
|
336
|
-
"""
|
|
337
|
-
xml2cue returns a base64 string for xmlbin
|
|
338
|
-
and a dict for xml
|
|
339
|
-
"""
|
|
340
|
-
bindata = self.gimme_one("Binary", exemel)
|
|
341
|
-
if bindata:
|
|
342
|
-
return bindata["this"]
|
|
343
|
-
splice_info = self.spliceinfosection(exemel)
|
|
344
|
-
cmd = self.command(exemel)
|
|
345
|
-
dscptrs = self.descriptors(exemel)
|
|
346
|
-
return {
|
|
347
|
-
"info_section": splice_info,
|
|
348
|
-
"command": cmd,
|
|
349
|
-
"descriptors": dscptrs,
|
|
350
|
-
}
|
|
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
|