threefive3 3.0.21__tar.gz → 3.0.25__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 (40) hide show
  1. {threefive3-3.0.21 → threefive3-3.0.25}/PKG-INFO +50 -7
  2. threefive3-3.0.21/threefive3.egg-info/PKG-INFO → threefive3-3.0.25/README.md +46 -24
  3. {threefive3-3.0.21 → threefive3-3.0.25}/bin/threefive3 +48 -7
  4. {threefive3-3.0.21 → threefive3-3.0.25}/setup.py +2 -3
  5. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/__init__.py +1 -2
  6. threefive3-3.0.25/threefive3/crc.py +44 -0
  7. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/cue.py +43 -32
  8. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/descriptors.py +1 -0
  9. threefive3-3.0.25/threefive3/gums.py +198 -0
  10. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/hls.py +21 -17
  11. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/hlstags.py +34 -24
  12. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/iframes.py +6 -4
  13. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/new_reader.py +33 -37
  14. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/packetdata.py +1 -1
  15. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/stream.py +28 -19
  16. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/stuff.py +11 -6
  17. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/superkabuki.py +114 -14
  18. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/sxp.py +11 -9
  19. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/version.py +1 -1
  20. threefive3-3.0.25/threefive3/words.py +43 -0
  21. threefive3-3.0.21/README.md → threefive3-3.0.25/threefive3.egg-info/PKG-INFO +68 -4
  22. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3.egg-info/SOURCES.txt +2 -0
  23. threefive3-3.0.21/threefive3/crc.py +0 -49
  24. {threefive3-3.0.21 → threefive3-3.0.25}/LICENSE +0 -0
  25. {threefive3-3.0.21 → threefive3-3.0.25}/setup.cfg +0 -0
  26. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/base.py +0 -0
  27. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/bitn.py +0 -0
  28. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/commands.py +0 -0
  29. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/encode.py +0 -0
  30. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/section.py +0 -0
  31. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/segment.py +0 -0
  32. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/segmentation.py +0 -0
  33. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/sixfix.py +0 -0
  34. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/streamtypes.py +0 -0
  35. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/upids.py +0 -0
  36. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/x2c.py +0 -0
  37. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3/xml.py +0 -0
  38. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3.egg-info/dependency_links.txt +0 -0
  39. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3.egg-info/requires.txt +0 -0
  40. {threefive3-3.0.21 → threefive3-3.0.25}/threefive3.egg-info/top_level.txt +0 -0
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: threefive3
3
- Version: 3.0.21
4
- Summary: threefive continued.
5
- Home-page: https://github.com/superkabuki/scte35
3
+ Version: 3.0.25
4
+ Summary: SCTE-35 decoder and encoder with MPEGTS and HLS and XML support.
5
+ Home-page: https://github.com/superkabuki/threefive3
6
6
  Author: Adrian of Doom
7
7
  Author-email: spam@iodisco.com
8
8
  Classifier: License :: OSI Approved :: Sleepycat License
@@ -19,8 +19,13 @@ Requires-Python: >=3.6
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
 
22
+ Canada has a virtual monopoly on the World's mustard seed supply and they will use it to manipulate financial markets. We must act.
23
+ ## Nuke Canada Now!
24
+
22
25
  [Install threefive3](#install) |[SCTE-35 Cli](#the-cli-tool) |[SCTE-35 Xml ](https://github.com/superkabuki/threefive3/blob/main/xml.md) | [SCTE-35 HLS](https://github.com/superkabuki/threefive3/blob/main/hls.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
26
 
27
+
28
+
24
29
  # threefive3 SCTE-35 cli super tool and python3 library.
25
30
  > Brought to you by the fine folks at fu-corp _( Adrian and the two blonde Chinese girls. )_
26
31
 
@@ -33,7 +38,7 @@ License-File: LICENSE
33
38
  * Automatic AES decryption for HLS.
34
39
  * All HLS SCTE-35 Tags are Supported.
35
40
 
36
- ### Latest release is v3.0.21
41
+ ### Latest release is v3.0.25
37
42
  > Stay up to date, only the latest release is supported.
38
43
  ___
39
44
  ### MPEGTS streams can be parsed for SCTE-35 with three lines of code.
@@ -51,6 +56,46 @@ Type "help", "copyright", "credits" or "license" for more information.
51
56
  >>>> strm.decode()
52
57
  ```
53
58
 
59
+
60
+ # threefive3 Road Map.
61
+
62
+ > The master plan for threefive3 is to consolidate code from several of my projects.
63
+
64
+ | Project | Description | Status |
65
+ |-----------------|---------------------------------------|----------|
66
+ | threefive | scte-35 parser | Done |
67
+ | bitn | bitslicer for byte strings | Done |
68
+ | new_reader | reader for files and network data | Done |
69
+ | showcues | hls scte35 parser | Done |
70
+ | m3ufu tagparser | hls scte-35 tag parser | Done |
71
+ | iframes | iframe detection for mpegts | Done |
72
+ | dash rip rock | scte-35 xml parser and generator | Done |
73
+ | six2scte35 | ffmpeg bin data stream back to scte-35 | Done |
74
+ | superkabuki | scte-35 packet injection | Next release |
75
+ | sideways | hls scte-35 tag injecton | No |
76
+ | gums | multicast server | Next release |
77
+ | adbreak3 | fast cli scte-35 cue creation | No |
78
+
79
+
80
+ # Little Help?
81
+
82
+ I could use a hand.with these <br>
83
+
84
+ * Writing docs. Explain how to use threefive3.
85
+ * Easy Examples. Light coding.
86
+ * Unit Testing. light coding with some SCTE-35.
87
+ * Pylint and PEP compliance. medium python knowledge.
88
+ * Profiling and Benchmarking. Help make threefive3 faster.
89
+ * Replacing setup tools. Using setup.py for packaging has been deprecated, medium python knowledge.
90
+ * DASH parsing. I need somebody to explain the non-SCTE-35 parts of DASH to me.
91
+
92
+ You don't have to be a master of python or SCTE-35,<BR> but helping will make you better at both.<BR>
93
+ __I value enthusiasm over skill, I can teach you what you don't know.__ <BR>
94
+ Don't worry, I won't let you break anything, that's my job.
95
+
96
+ If you want to get involved, just open an issue and we can talk about it.
97
+
98
+
54
99
  # `Documentation`
55
100
 
56
101
 
@@ -62,7 +107,7 @@ Type "help", "copyright", "credits" or "license" for more information.
62
107
  * The cli tool comes with builtin documentation just type `threefive3 help`
63
108
 
64
109
  ### HLS
65
- * [Advanced Parsing of SCTE-35 in HLS with threefive3](https://github.com/superkabuki/threefive3/blob/main/hls.md) All HLS SCTE-35 tags, Sidecar Files, AAC ID3 Header Timestamps, SCTE-35 filters and more.
110
+ * [Advanced Parsing of SCTE-35 in HLS with threefive3](https://github.com/superkabuki/threefive3/blob/main/hls.md) All HLS SCTE-35 tags, Sidecar Files, AAC ID3 Header Timestamps, SCTE-35 filters... Who loves you baby?
66
111
 
67
112
 
68
113
  #### Xml
@@ -91,12 +136,10 @@ ___
91
136
  #### `| more`
92
137
 
93
138
  * [Online SCTE-35 Parser](https://iodisco.com/scte35) Supporte Base64, Bytes,Hex,Int, Json, Xml, and Xml+binary.
94
- * __Damn__.
95
139
 
96
140
  * [Encode SCTE-35](https://github.com/superkabuki/threefive3/blob/main/encode.md) Some encoding code examples.
97
141
 
98
142
  * [FFmpeg SCTE35](https://github.com/superkabuki/FFmpeg_SCTE35) FFmpeg with the SuperKabui SCTE-35 Patch applied.
99
- * __Hell Yes.__
100
143
 
101
144
  ___
102
145
 
@@ -1,26 +1,10 @@
1
- Metadata-Version: 2.1
2
- Name: threefive3
3
- Version: 3.0.21
4
- Summary: threefive continued.
5
- Home-page: https://github.com/superkabuki/scte35
6
- Author: Adrian of Doom
7
- Author-email: spam@iodisco.com
8
- Classifier: License :: OSI Approved :: Sleepycat License
9
- Classifier: Environment :: Console
10
- Classifier: Operating System :: OS Independent
11
- Classifier: Operating System :: POSIX :: BSD :: OpenBSD
12
- Classifier: Operating System :: POSIX :: BSD :: NetBSD
13
- Classifier: Operating System :: POSIX :: Linux
14
- Classifier: Topic :: Multimedia :: Video
15
- Classifier: Programming Language :: Python :: 3.6
16
- Classifier: Programming Language :: Python :: Implementation :: PyPy
17
- Classifier: Programming Language :: Python :: Implementation :: CPython
18
- Requires-Python: >=3.6
19
- Description-Content-Type: text/markdown
20
- License-File: LICENSE
1
+ Canada has a virtual monopoly on the World's mustard seed supply and they will use it to manipulate financial markets. We must act.
2
+ ## Nuke Canada Now!
21
3
 
22
4
  [Install threefive3](#install) |[SCTE-35 Cli](#the-cli-tool) |[SCTE-35 Xml ](https://github.com/superkabuki/threefive3/blob/main/xml.md) | [SCTE-35 HLS](https://github.com/superkabuki/threefive3/blob/main/hls.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
5
 
6
+
7
+
24
8
  # threefive3 SCTE-35 cli super tool and python3 library.
25
9
  > Brought to you by the fine folks at fu-corp _( Adrian and the two blonde Chinese girls. )_
26
10
 
@@ -33,7 +17,7 @@ License-File: LICENSE
33
17
  * Automatic AES decryption for HLS.
34
18
  * All HLS SCTE-35 Tags are Supported.
35
19
 
36
- ### Latest release is v3.0.21
20
+ ### Latest release is v3.0.25
37
21
  > Stay up to date, only the latest release is supported.
38
22
  ___
39
23
  ### MPEGTS streams can be parsed for SCTE-35 with three lines of code.
@@ -51,6 +35,46 @@ Type "help", "copyright", "credits" or "license" for more information.
51
35
  >>>> strm.decode()
52
36
  ```
53
37
 
38
+
39
+ # threefive3 Road Map.
40
+
41
+ > The master plan for threefive3 is to consolidate code from several of my projects.
42
+
43
+ | Project | Description | Status |
44
+ |-----------------|---------------------------------------|----------|
45
+ | threefive | scte-35 parser | Done |
46
+ | bitn | bitslicer for byte strings | Done |
47
+ | new_reader | reader for files and network data | Done |
48
+ | showcues | hls scte35 parser | Done |
49
+ | m3ufu tagparser | hls scte-35 tag parser | Done |
50
+ | iframes | iframe detection for mpegts | Done |
51
+ | dash rip rock | scte-35 xml parser and generator | Done |
52
+ | six2scte35 | ffmpeg bin data stream back to scte-35 | Done |
53
+ | superkabuki | scte-35 packet injection | Next release |
54
+ | sideways | hls scte-35 tag injecton | No |
55
+ | gums | multicast server | Next release |
56
+ | adbreak3 | fast cli scte-35 cue creation | No |
57
+
58
+
59
+ # Little Help?
60
+
61
+ I could use a hand.with these <br>
62
+
63
+ * Writing docs. Explain how to use threefive3.
64
+ * Easy Examples. Light coding.
65
+ * Unit Testing. light coding with some SCTE-35.
66
+ * Pylint and PEP compliance. medium python knowledge.
67
+ * Profiling and Benchmarking. Help make threefive3 faster.
68
+ * Replacing setup tools. Using setup.py for packaging has been deprecated, medium python knowledge.
69
+ * DASH parsing. I need somebody to explain the non-SCTE-35 parts of DASH to me.
70
+
71
+ You don't have to be a master of python or SCTE-35,<BR> but helping will make you better at both.<BR>
72
+ __I value enthusiasm over skill, I can teach you what you don't know.__ <BR>
73
+ Don't worry, I won't let you break anything, that's my job.
74
+
75
+ If you want to get involved, just open an issue and we can talk about it.
76
+
77
+
54
78
  # `Documentation`
55
79
 
56
80
 
@@ -62,7 +86,7 @@ Type "help", "copyright", "credits" or "license" for more information.
62
86
  * The cli tool comes with builtin documentation just type `threefive3 help`
63
87
 
64
88
  ### HLS
65
- * [Advanced Parsing of SCTE-35 in HLS with threefive3](https://github.com/superkabuki/threefive3/blob/main/hls.md) All HLS SCTE-35 tags, Sidecar Files, AAC ID3 Header Timestamps, SCTE-35 filters and more.
89
+ * [Advanced Parsing of SCTE-35 in HLS with threefive3](https://github.com/superkabuki/threefive3/blob/main/hls.md) All HLS SCTE-35 tags, Sidecar Files, AAC ID3 Header Timestamps, SCTE-35 filters... Who loves you baby?
66
90
 
67
91
 
68
92
  #### Xml
@@ -91,12 +115,10 @@ ___
91
115
  #### `| more`
92
116
 
93
117
  * [Online SCTE-35 Parser](https://iodisco.com/scte35) Supporte Base64, Bytes,Hex,Int, Json, Xml, and Xml+binary.
94
- * __Damn__.
95
118
 
96
119
  * [Encode SCTE-35](https://github.com/superkabuki/threefive3/blob/main/encode.md) Some encoding code examples.
97
120
 
98
121
  * [FFmpeg SCTE35](https://github.com/superkabuki/FFmpeg_SCTE35) FFmpeg with the SuperKabui SCTE-35 Patch applied.
99
- * __Hell Yes.__
100
122
 
101
123
  ___
102
124
 
@@ -8,12 +8,15 @@ scte35 command line SCTE35 decoder.
8
8
 
9
9
  import select
10
10
  import sys
11
+ from threefive3.gums import cli as gumscli
12
+ from threefive3.superkabuki import cli as skcli
11
13
  from threefive3.iframes import IFramer
12
14
  from threefive3.new_reader import reader
13
- from threefive3 import Cue, Stream, print2,blue, version, red
15
+ from threefive3 import Cue, Stream, print2, blue, version, red
14
16
  from threefive3.hls import cli as hlscli
15
17
  from threefive3.sixfix import sixfix
16
18
  import cProfile
19
+
17
20
  # from sideways import cli as sidecli
18
21
 
19
22
  REV = "\033[7;1m"
@@ -30,12 +33,13 @@ class SupaStream(Stream):
30
33
  SupaStream is subclass of Stream used
31
34
  to print raw SCTE-35 packets.
32
35
  """
36
+
33
37
  def _parse_scte35(self, pkt, pid):
34
38
  print2(pkt)
35
39
  print2("")
36
40
  super()._parse_scte35(pkt, pid)
37
41
 
38
-
42
+
39
43
  def mk_sidecar(cue):
40
44
  """
41
45
  mk_sidecar generates a sidecar file with the SCTE-35 Cues
@@ -52,7 +56,7 @@ def mk_sidecar(cue):
52
56
  HELP = f"""
53
57
  {BLUE} threefive3 cli tool {U}
54
58
 
55
- {B} Default {U} {BLUE}The default action is to read a input and write a SCTE-35 output.{U}
59
+ {B} Default {U} {BLUE}The default action is to read an input and write an output.{U}
56
60
 
57
61
  {BLUE}Inputs {U} mpegts, base64, hex, json, xml, and xmlbin{U}.
58
62
 
@@ -75,6 +79,9 @@ HELP = f"""
75
79
 
76
80
  {B} iframes {U}{BLUE} show MPEGTS iframes{NORM} threefive3 iframes video.ts
77
81
 
82
+ {B} mcast {U}{BLUE} Create a Multicast Stream {NORM} threefive3 mcast -I video.ts
83
+ {U}{BLUE}See mcast help {NORM} threefive3 mcast help
84
+
78
85
  {B} packets {U}{NORM}{BLUE} Print raw SCTE-35 packets:{NORM} threefive3 packets udp://@235.35.3.5:3535
79
86
 
80
87
  {B} proxy {U}{NORM}{BLUE} Parse a stream and copy it to stdout:{NORM} threefive3 proxy video.ts
@@ -321,8 +328,8 @@ def to_funk(this):
321
328
  try:
322
329
  cue.bites = cue._mk_bits(this)
323
330
  cue.decode()
324
- except:
325
- print2("Bad Data:\n")
331
+ except Error:
332
+ print2(Error)
326
333
  sys.exit()
327
334
  if cue:
328
335
  funk()(cue) # func works here too.
@@ -344,7 +351,7 @@ def chk_stdin(args):
344
351
  strm = Stream(sys.stdin.buffer)
345
352
  strm._parse(one + two) # dont drop first packet
346
353
  strm.decode(func=funk())
347
- sys.exit() # I keep forgetting why I do
354
+ sys.exit() # I keep forgetting why I do
348
355
  return args
349
356
 
350
357
 
@@ -360,10 +367,44 @@ def chk_funk_map():
360
367
  sys.exit()
361
368
 
362
369
 
370
+ # cli map
371
+
372
+ cli_map = {"mcast": gumscli, "superkabuki": skcli}
373
+
374
+
375
+ def dashdashhelp():
376
+ """
377
+ dashdashhelp swaps out "help" with "--help"
378
+ for keys in cli_map. Pure bureaucracy.
379
+ I still can't believe I can just edit sys.argv at will,
380
+ it kind of makes sense, since I wrote it in the first place,
381
+ but it just feels so wrong.
382
+ """
383
+ if "help" in sys.argv:
384
+ idx = sys.argv.index("help")
385
+ sys.argv[idx]= "--help"
386
+
387
+
388
+ def chk_cli_map():
389
+ """
390
+ chk_cli_map check if a
391
+ cli_map key is present in sys.argv,
392
+ pass control to the cli function.
393
+ """
394
+ for k, v in cli_map.items():
395
+ if k in sys.argv:
396
+ dashdashhelp()
397
+ sys.argv[0] = f"{sys.argv[0]} {k}"
398
+ sys.argv.remove(k)
399
+ v()
400
+ sys.exit()
401
+
402
+
363
403
  def go():
404
+ chk_cli_map()
405
+ chk_print_map()
364
406
  if len(sys.argv) < 2:
365
407
  sys.argv.append("json")
366
- chk_print_map()
367
408
  chk_mpegts_map()
368
409
  chk_funk_map()
369
410
 
@@ -13,10 +13,10 @@ setuptools.setup(
13
13
  version=version,
14
14
  author="Adrian of Doom",
15
15
  author_email="spam@iodisco.com",
16
- description="threefive continued.",
16
+ description="SCTE-35 decoder and encoder with MPEGTS and HLS and XML support.",
17
17
  long_description=readme,
18
18
  long_description_content_type="text/markdown",
19
- url="https://github.com/superkabuki/scte35",
19
+ url="https://github.com/superkabuki/threefive3",
20
20
  install_requires=[
21
21
  "pyaes",
22
22
  ],
@@ -37,4 +37,3 @@ setuptools.setup(
37
37
  ],
38
38
  python_requires=">=3.6",
39
39
  )
40
-
@@ -9,8 +9,7 @@ from .hlstags import TagParser
9
9
  from .section import SpliceInfoSection
10
10
  from .segment import Segment
11
11
  from .stream import Stream
12
- from .stuff import print2, iso8601, atohif ,red, blue
13
- from .superkabuki import SuperKabuki
12
+ from .stuff import print2, iso8601, atohif, red, blue
14
13
  from .version import version
15
14
 
16
15
  from .commands import (
@@ -0,0 +1,44 @@
1
+ """
2
+ crc.py crc32 function for encoding.
3
+ """
4
+
5
+ from .words import zero, one, eight, twentyfour, thirtytwo, twofiftyfive, twofiftysix
6
+
7
+ POLY = 0x104C11DB7
8
+ INIT_VALUE = 0xFFFFFFFF
9
+
10
+
11
+ def _bytecrc(crc, poly):
12
+ mask = one << (thirtytwo - one)
13
+ i = eight
14
+ while i:
15
+ crc = (crc << one, crc << one ^ poly)[crc & mask != zero]
16
+ i -= one
17
+ return crc & INIT_VALUE
18
+
19
+
20
+ def _mk_table():
21
+ mask = (one << thirtytwo) - one
22
+ poly = POLY & mask
23
+ return [_bytecrc((i << twentyfour), poly) for i in range(twofiftysix)]
24
+
25
+
26
+ def crc32(data):
27
+ """
28
+ generate a 32 bit crc
29
+ """
30
+
31
+ table = _mk_table()
32
+ crc = INIT_VALUE
33
+ for bite in data:
34
+ crc = table[bite ^ ((crc >> twentyfour) & twofiftyfive)] ^ (
35
+ (crc << eight) & (INIT_VALUE - twofiftyfive)
36
+ )
37
+ return crc
38
+
39
+
40
+ def crc32hex(data):
41
+ """
42
+ crc32hex crc32 returned as hex
43
+ """
44
+ return hex(crc32(data))
@@ -13,6 +13,19 @@ 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 .words import (
17
+ minusone,
18
+ zero,
19
+ one,
20
+ two,
21
+ three,
22
+ four,
23
+ eight,
24
+ eleven,
25
+ fourteen,
26
+ sixteen,
27
+ equalsign,
28
+ )
16
29
  from .x2c import xml2cue
17
30
 
18
31
 
@@ -52,12 +65,11 @@ class Cue(SCTE35Base):
52
65
  self.info_section = SpliceInfoSection()
53
66
  self.bites = None
54
67
  if data:
55
- self.bites=self._mk_bits(data)
68
+ self.bites = self._mk_bits(data)
56
69
  self.packet_data = packet_data
57
70
  self.dash_data = None
58
71
  self.decode()
59
72
 
60
-
61
73
  def __repr__(self):
62
74
  return str(self.__dict__)
63
75
 
@@ -75,7 +87,7 @@ class Cue(SCTE35Base):
75
87
  bites = self._set_splice_command(bites)
76
88
  bites = self._mk_descriptors(bites)
77
89
  if bites:
78
- crc = hex(int.from_bytes(bites[0:4], byteorder="big"))
90
+ crc = hex(int.from_bytes(bites[zero:four], byteorder="big"))
79
91
  self.info_section.crc = crc
80
92
  return True
81
93
  return False
@@ -84,7 +96,7 @@ class Cue(SCTE35Base):
84
96
  """
85
97
  Cue._descriptor_loop parses all splice descriptors
86
98
  """
87
- tag_n_len = 2
99
+ tag_n_len = two
88
100
  while len(loop_bites) > tag_n_len:
89
101
  spliced = splice_descriptor(loop_bites)
90
102
  if not spliced:
@@ -119,7 +131,6 @@ class Cue(SCTE35Base):
119
131
  scte35_data = self._get_packet_data(scte35_data)
120
132
 
121
133
  return scte35_data
122
- red("command or info section not found")
123
134
  return False
124
135
 
125
136
  def get_descriptors(self):
@@ -139,16 +150,15 @@ class Cue(SCTE35Base):
139
150
  """
140
151
  fix_bad_b64 fixes bad padding on Base64
141
152
  """
142
- while len(data) % 4 != 0:
143
- data = data + "="
144
- blue("bad base64 length fixed.\n ")
153
+ while len(data) % four != zero:
154
+ data = data + equalsign
145
155
  return data
146
156
 
147
157
  def _int_bits(self, data):
148
158
  """
149
159
  _int_bits convert a SCTE-35 Cue from integer to bytes.
150
160
  """
151
- length = data.bit_length() >> 3
161
+ length = data.bit_length() >> three
152
162
  bites = int.to_bytes(data, length, byteorder="big")
153
163
  return bites
154
164
 
@@ -157,14 +167,14 @@ class Cue(SCTE35Base):
157
167
  _hex_bits convert a SCTE-35 Cue from hex to bytes.
158
168
  """
159
169
  try:
160
- i = int(data, 16)
161
- i_len = i.bit_length() >> 3
170
+ i = int(data, sixteen)
171
+ i_len = i.bit_length() >> three
162
172
  bites = int.to_bytes(i, i_len, byteorder="big")
163
173
  return bites
164
174
  except (LookupError, TypeError, ValueError):
165
- if data[:2].lower() == "0x":
166
- data = data[2:]
167
- if data[:2].lower() == "fc":
175
+ if data[:two].lower() == "0x":
176
+ data = data[two:]
177
+ if data[:two].lower() == "fc":
168
178
  return bytes.fromhex(data)
169
179
  return b""
170
180
 
@@ -187,14 +197,14 @@ class Cue(SCTE35Base):
187
197
  return hex_bits
188
198
  return self._b64_bits(data)
189
199
 
190
- def _pkt_bits(self,data):
200
+ def _pkt_bits(self, data):
191
201
  """
192
202
  _pkt_bits parse raw mpegts SCTE-35 packet
193
203
  """
194
- if data.startswith(b'G'):
195
- return data.split(b'\x00\x00\x01\xfc',1)[-1]
204
+ if data.startswith(b"G"):
205
+ return data.split(b"\x00\x00\x01\xfc", one)[minusone]
196
206
  return data
197
-
207
+
198
208
  def _mk_bits(self, data):
199
209
  """
200
210
  cue._mk_bits Converts
@@ -208,14 +218,15 @@ class Cue(SCTE35Base):
208
218
  self.load(data.mk())
209
219
  return self.bites
210
220
  if isinstance(data, bytes):
211
- data=self._pkt_bits(data)
212
- bites = self.idxsplit(data,b"\xfc")
221
+ data = self._pkt_bits(data)
222
+ bites = self.idxsplit(data, b"\xfc")
213
223
  return bites
214
224
  if isinstance(data, int):
215
225
  return self._int_bits(data)
216
226
  if isinstance(data, str):
217
- return self._str_bits(data)
218
- # self.bites = bites
227
+ return self._str_bits(data)
228
+
229
+ # self.bites = bites
219
230
  # return bites
220
231
 
221
232
  def _mk_descriptors(self, bites):
@@ -227,9 +238,9 @@ class Cue(SCTE35Base):
227
238
  ## if len(bites) < 2:
228
239
  ## return False
229
240
  while bites:
230
- dll = (bites[0] << 8) | bites[1]
241
+ dll = (bites[zero] << eight) | bites[one]
231
242
  self.info_section.descriptor_loop_length = dll
232
- bites = bites[2:]
243
+ bites = bites[two:]
233
244
  self._descriptor_loop(bites[:dll])
234
245
  return bites[dll:]
235
246
 
@@ -239,7 +250,7 @@ class Cue(SCTE35Base):
239
250
  Splice Info Section
240
251
  of a SCTE35 cue.
241
252
  """
242
- info_size = 14
253
+ info_size = fourteen
243
254
  info_bites = bites[:info_size]
244
255
  self.info_section.decode(info_bites)
245
256
  return bites[info_size:]
@@ -273,11 +284,11 @@ class Cue(SCTE35Base):
273
284
  self.info_section.splice_command_type = self.command.command_type
274
285
  # 11 bytes for info section + command + 2 descriptor loop length
275
286
  # + descriptor loop + 4 for crc
276
- self.info_section.section_length = 11 + cmdl + 2 + dll + 4
287
+ self.info_section.section_length = eleven + cmdl + two + dll + four
277
288
  self.bites = self.info_section.encode()
278
289
  self.bites += cmd_bites
279
290
  self.bites += int.to_bytes(
280
- self.info_section.descriptor_loop_length, 2, byteorder="big"
291
+ self.info_section.descriptor_loop_length, two, byteorder="big"
281
292
  )
282
293
  self.bites += dscptr_bites
283
294
 
@@ -330,7 +341,7 @@ class Cue(SCTE35Base):
330
341
  """
331
342
  crc_int = crc32(self.bites)
332
343
  self.info_section.crc = hex(crc_int)
333
- self.bites += int.to_bytes(crc_int, 4, byteorder="big")
344
+ self.bites += int.to_bytes(crc_int, four, byteorder="big")
334
345
 
335
346
  def _unloop_descriptors(self):
336
347
  """
@@ -343,8 +354,8 @@ class Cue(SCTE35Base):
343
354
  dbite_chunks = [dsptr.encode() for dsptr in self.descriptors]
344
355
  for chunk, dsptr in zip(dbite_chunks, self.descriptors):
345
356
  dsptr.descriptor_length = len(chunk)
346
- all_bites.add_int(dsptr.tag, 8)
347
- all_bites.add_int(dsptr.descriptor_length, 8)
357
+ all_bites.add_int(dsptr.tag, eight)
358
+ all_bites.add_int(dsptr.descriptor_length, eight)
348
359
  all_bites.add_bites(chunk)
349
360
  return all_bites.bites
350
361
 
@@ -381,7 +392,7 @@ class Cue(SCTE35Base):
381
392
  a descriptor instance will be created.
382
393
  """
383
394
  if not isinstance(dlist, list):
384
- red('descriptors should be a list')
395
+ red("descriptors should be a list")
385
396
  for dstuff in dlist:
386
397
  dscptr = descriptor_map[dstuff["tag"]]()
387
398
  dscptr.load(dstuff)
@@ -416,7 +427,7 @@ class Cue(SCTE35Base):
416
427
  self.bites = self._int_bits(int(gonzo))
417
428
  self.decode()
418
429
  return self.bites
419
- if gonzo.strip()[0] == "<":
430
+ if gonzo.strip()[zero] == "<":
420
431
  self._from_xml(gonzo)
421
432
  return self.bites
422
433
  gonzo = json.loads(gonzo)
@@ -9,6 +9,7 @@ from .upids import upid_map
9
9
  from .xml import Node
10
10
  from .stuff import red
11
11
 
12
+
12
13
  def k_by_v(adict, avalue):
13
14
  """
14
15
  dict key lookup by value