threefive3 3.0.17__tar.gz → 3.0.19__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 (35) hide show
  1. {threefive3-3.0.17/threefive3.egg-info → threefive3-3.0.19}/PKG-INFO +43 -14
  2. {threefive3-3.0.17 → threefive3-3.0.19}/README.md +42 -13
  3. {threefive3-3.0.17 → threefive3-3.0.19}/bin/threefive3 +4 -2
  4. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/__init__.py +3 -1
  5. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/base.py +1 -0
  6. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/bitn.py +6 -2
  7. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/cue.py +10 -9
  8. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/hls.py +63 -74
  9. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/hlstags.py +3 -3
  10. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/section.py +3 -3
  11. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/stuff.py +23 -2
  12. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/version.py +1 -1
  13. {threefive3-3.0.17 → threefive3-3.0.19/threefive3.egg-info}/PKG-INFO +43 -14
  14. {threefive3-3.0.17 → threefive3-3.0.19}/LICENSE +0 -0
  15. {threefive3-3.0.17 → threefive3-3.0.19}/setup.cfg +0 -0
  16. {threefive3-3.0.17 → threefive3-3.0.19}/setup.py +0 -0
  17. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/commands.py +0 -0
  18. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/crc.py +0 -0
  19. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/descriptors.py +0 -0
  20. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/iframes.py +0 -0
  21. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/new_reader.py +0 -0
  22. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/packetdata.py +0 -0
  23. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/segment.py +0 -0
  24. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/segmentation.py +0 -0
  25. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/sixfix.py +0 -0
  26. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/stream.py +0 -0
  27. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/streamtypes.py +0 -0
  28. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/sxp.py +0 -0
  29. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/upids.py +0 -0
  30. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/x2c.py +0 -0
  31. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3/xml.py +0 -0
  32. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3.egg-info/SOURCES.txt +0 -0
  33. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3.egg-info/dependency_links.txt +0 -0
  34. {threefive3-3.0.17 → threefive3-3.0.19}/threefive3.egg-info/requires.txt +0 -0
  35. {threefive3-3.0.17 → threefive3-3.0.19}/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.17
3
+ Version: 3.0.19
4
4
  Summary: threefive continued.
5
5
  Home-page: https://github.com/superkabuki/scte35
6
6
  Author: Adrian of Doom
@@ -19,16 +19,47 @@ Requires-Python: >=3.6
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
 
22
- # threefive3 SCTE-35 cli tool and python3 library.
22
+
23
+ # threefive3 SCTE-35 cli super tool and python3 library.
23
24
 
24
25
  ✅ SCTE-35 Parser ✅ SCTE-35 Encoder ✅ SCTE-35 HLS ✅ SCTE-35 Xml ✅ SCTE-35 Cli ✅ SCTE-35 library
25
26
 
26
27
 
27
- * Parses SCTE-35 from MPEGTS, HLS, XML, XML+Binary, Base64, Bytes, Hex, and Integers.
28
- * Built-in network support for http(s), UDP, and Multicast.
28
+ * Parses SCTE-35 from MPEGTS, HLS, XML, XML+Binary, Base64, Bytes, Hex, Integers, or JSON.
29
+ * Encode SCTE-35 to Base64, Bytes, Hex, Int, JSON, Xml, or Xml+binary.
30
+ * Built-in network support for HTTP(S), UDP, and Multicast.
29
31
  * Automatic AES decryption for HLS.
30
- * All HLS SCTE-35 Tags are Supported
32
+ * All HLS SCTE-35 Tags are Supported.
33
+ ___
34
+ # Latest release is v3.0.19
35
+ > Stay up to date, only the latest release is supported.
31
36
  ___
37
+ ### MPEGTS streams can be parsed for SCTE-35 with three lines of code.
38
+
39
+ ```py3
40
+ a@fu:~/build5/scte35/scte35$ pypy3
41
+ Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
42
+ [PyPy 7.3.11 with GCC 12.2.0] on linux
43
+ Type "help", "copyright", "credits" or "license" for more information.
44
+
45
+ >>>> from threefive3 import Stream
46
+
47
+ >>>> strm=Stream('https://futzu.com/xaa.ts')
48
+
49
+ >>>> strm.decode()
50
+ ```
51
+ # Heads Up!
52
+
53
+ > threefive3 is a lot to do by myself, in my spare time. I'm going to impose on y'all a little.
54
+
55
+ > I am currently working on error reporting. I am trying to aggregate the errors into each object, so if you have multiple errors, you can get them all at once, rather than one at a time. I need to try some stuff so I can see how it works and how it fails.
56
+ > If I have to do this alone, it will take much longer than if y'all help me.
57
+ > I will probably push a couple releases this week, I need you to use then.
58
+ > Be a good citizen and get involved. That's what makes open source work.
59
+
60
+
61
+ # Documentation
62
+
32
63
  * [Install](#install)
33
64
  * [SCTE-35 Cli](#the-cli-tool)
34
65
  * [SCTE-35 Xml ](https://github.com/superkabuki/threefive3/blob/main/xml.md)
@@ -38,19 +69,17 @@ ___
38
69
  * [Encode SCTE-35](https://github.com/superkabuki/threefive3/blob/main/encode.md)
39
70
  * [FFmpeg SCTE35](https://github.com/superkabuki/FFmpeg_SCTE35)
40
71
 
41
- ## MPEGTS streams can be parsed for SCTE-35 with three lines of code.
72
+ * _The cli tool comes with builtin documentation just type_ `threefive3 help`
42
73
 
43
- ```py3
44
- a@fu:~/build5/scte35/scte35$ pypy3
74
+ * _The python built in help is always the most up to date._
75
+
76
+ ```rebol
77
+ a@fu:~/build7/threefive3$ pypy3
45
78
  Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
46
79
  [PyPy 7.3.11 with GCC 12.2.0] on linux
47
80
  Type "help", "copyright", "credits" or "license" for more information.
48
-
49
- >>>> from threefive3 import Stream
50
-
51
- >>>> strm=Stream('https://futzu.com/xaa.ts')
52
-
53
- >>>> strm.decode()
81
+ >>>> from threefive import Stream
82
+ >>>> help(Stream)
54
83
  ```
55
84
 
56
85
  ___
@@ -1,13 +1,44 @@
1
- # threefive3 SCTE-35 cli tool and python3 library.
1
+
2
+ # threefive3 SCTE-35 cli super tool and python3 library.
2
3
 
3
4
  ✅ SCTE-35 Parser ✅ SCTE-35 Encoder ✅ SCTE-35 HLS ✅ SCTE-35 Xml ✅ SCTE-35 Cli ✅ SCTE-35 library
4
5
 
5
6
 
6
- * Parses SCTE-35 from MPEGTS, HLS, XML, XML+Binary, Base64, Bytes, Hex, and Integers.
7
- * Built-in network support for http(s), UDP, and Multicast.
7
+ * Parses SCTE-35 from MPEGTS, HLS, XML, XML+Binary, Base64, Bytes, Hex, Integers, or JSON.
8
+ * Encode SCTE-35 to Base64, Bytes, Hex, Int, JSON, Xml, or Xml+binary.
9
+ * Built-in network support for HTTP(S), UDP, and Multicast.
8
10
  * Automatic AES decryption for HLS.
9
- * All HLS SCTE-35 Tags are Supported
11
+ * All HLS SCTE-35 Tags are Supported.
12
+ ___
13
+ # Latest release is v3.0.19
14
+ > Stay up to date, only the latest release is supported.
10
15
  ___
16
+ ### MPEGTS streams can be parsed for SCTE-35 with three lines of code.
17
+
18
+ ```py3
19
+ a@fu:~/build5/scte35/scte35$ pypy3
20
+ Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
21
+ [PyPy 7.3.11 with GCC 12.2.0] on linux
22
+ Type "help", "copyright", "credits" or "license" for more information.
23
+
24
+ >>>> from threefive3 import Stream
25
+
26
+ >>>> strm=Stream('https://futzu.com/xaa.ts')
27
+
28
+ >>>> strm.decode()
29
+ ```
30
+ # Heads Up!
31
+
32
+ > threefive3 is a lot to do by myself, in my spare time. I'm going to impose on y'all a little.
33
+
34
+ > I am currently working on error reporting. I am trying to aggregate the errors into each object, so if you have multiple errors, you can get them all at once, rather than one at a time. I need to try some stuff so I can see how it works and how it fails.
35
+ > If I have to do this alone, it will take much longer than if y'all help me.
36
+ > I will probably push a couple releases this week, I need you to use then.
37
+ > Be a good citizen and get involved. That's what makes open source work.
38
+
39
+
40
+ # Documentation
41
+
11
42
  * [Install](#install)
12
43
  * [SCTE-35 Cli](#the-cli-tool)
13
44
  * [SCTE-35 Xml ](https://github.com/superkabuki/threefive3/blob/main/xml.md)
@@ -17,19 +48,17 @@ ___
17
48
  * [Encode SCTE-35](https://github.com/superkabuki/threefive3/blob/main/encode.md)
18
49
  * [FFmpeg SCTE35](https://github.com/superkabuki/FFmpeg_SCTE35)
19
50
 
20
- ## MPEGTS streams can be parsed for SCTE-35 with three lines of code.
51
+ * _The cli tool comes with builtin documentation just type_ `threefive3 help`
21
52
 
22
- ```py3
23
- a@fu:~/build5/scte35/scte35$ pypy3
53
+ * _The python built in help is always the most up to date._
54
+
55
+ ```rebol
56
+ a@fu:~/build7/threefive3$ pypy3
24
57
  Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
25
58
  [PyPy 7.3.11 with GCC 12.2.0] on linux
26
59
  Type "help", "copyright", "credits" or "license" for more information.
27
-
28
- >>>> from threefive3 import Stream
29
-
30
- >>>> strm=Stream('https://futzu.com/xaa.ts')
31
-
32
- >>>> strm.decode()
60
+ >>>> from threefive import Stream
61
+ >>>> help(Stream)
33
62
  ```
34
63
 
35
64
  ___
@@ -318,10 +318,12 @@ def to_funk(this):
318
318
  strm = Stream(this)
319
319
  strm.decode(func=funk()) # funk() works here
320
320
  except: # try to load json or xml
321
+ cue = Cue()
321
322
  try:
322
- cue = Cue(this)
323
+ cue.bites = cue._mk_bits(this)
324
+ cue.decode()
323
325
  except:
324
- print2(f"Bad Data:\n{this}")
326
+ print2(f"Bad Data:\n{cue.errs()}")
325
327
  sys.exit()
326
328
  if cue:
327
329
  funk()(cue) # func works here too.
@@ -4,10 +4,12 @@ scte35.__init__.py
4
4
 
5
5
 
6
6
  from .cue import Cue
7
+ from .hls import HlsParser
8
+ from .hlstags import TagParser
7
9
  from .section import SpliceInfoSection
8
10
  from .segment import Segment
9
11
  from .stream import Stream
10
- from .stuff import print2
12
+ from .stuff import print2, iso8601, atohif
11
13
  from .version import version
12
14
 
13
15
  from .commands import (
@@ -33,6 +33,7 @@ class SCTE35Base:
33
33
  var_type = str(var_type).split("'")[1]
34
34
  err_mesg = f"{var_name} is {var_value} , it should be type {var_type}, {bit_count} bit(s) long."
35
35
  self.errors.append(err_mesg)
36
+ print2(err_mesg)
36
37
 
37
38
  def _bool_int(self, var_name, var_value, bit_count, var_type):
38
39
  if var_type == int:
@@ -16,8 +16,12 @@ class Bitn:
16
16
  def __init__(self, bites):
17
17
  # self.bites = bites
18
18
  self.bitsize = self.idx = len(bites) << 3
19
- self.bits = int.from_bytes(bites, byteorder="big")
19
+ if isinstance(bites,bytes):
20
+ self.bits = int.from_bytes(bites, byteorder="big")
21
+ if isinstance(bites,int):
22
+ self.bits=bites
20
23
 
24
+
21
25
  def __repr__(self):
22
26
  return str(vars(self))
23
27
 
@@ -157,7 +161,7 @@ class NBin:
157
161
  if isinstance(hex_str, str):
158
162
  dehexed = int(hex_str, 16)
159
163
  # just in case hex_str is an int....
160
- else:
164
+ if isinstance(hex_str,int):
161
165
  dehexed = hex_str
162
166
  self.add_int(dehexed, bit_len)
163
167
 
@@ -122,17 +122,19 @@ class Cue(SCTE35Base):
122
122
  Cue.get returns the SCTE-35 Cue
123
123
  data as a dict of dicts.
124
124
  """
125
- if self.command and self.info_section:
126
- scte35_data = {
125
+ # if self.command and self.info_section:
126
+ scte35_data = {
127
+ "errors": self.errs(),
127
128
  "info_section": self.info_section.get(),
128
129
  "command": self.command.get(),
129
130
  "descriptors": self.get_descriptors(),
130
- }
131
- scte35_data = self._get_dash_data(scte35_data)
132
- scte35_data = self._get_packet_data(scte35_data)
133
- return scte35_data
134
- self.errors.append("command or info section not found")
135
- return False
131
+ }
132
+ scte35_data = self._get_dash_data(scte35_data)
133
+ scte35_data = self._get_packet_data(scte35_data)
134
+
135
+ return scte35_data
136
+ # self.errors.append("command or info section not found")
137
+ # return False
136
138
 
137
139
  def get_descriptors(self):
138
140
  """
@@ -461,7 +463,6 @@ class Cue(SCTE35Base):
461
463
  """
462
464
  xml returns a threefive3.Node instance
463
465
  which can be edited as needed or printed.
464
- xmlbin
465
466
  """
466
467
  sis = self.info_section.xml(ns=ns)
467
468
  cmd = self.command.xml(ns=ns)
@@ -5,15 +5,17 @@ scte35.hls hls.py
5
5
 
6
6
  """
7
7
 
8
- import datetime
9
8
  import os
10
9
  import sys
11
10
  import time
12
11
  from collections import deque
12
+ from pprint import pprint
13
13
  from .hlstags import TagParser, HEADER_TAGS
14
14
  from .segment import Segment
15
15
  from .cue import Cue
16
16
  from .new_reader import reader
17
+ from .stuff import atohif, iso8601,print2
18
+
17
19
 
18
20
  REV = "\033[7m"
19
21
  NORM = "\033[27m"
@@ -26,28 +28,6 @@ HEADER_TAGS = list(HEADER_TAGS)
26
28
  HEADER_TAGS.append("#EXTM3U")
27
29
 
28
30
 
29
- def atoif(value):
30
- """
31
- atoif converts ascii to (int|float)
32
- """
33
- if isinstance(value, str):
34
- try:
35
- value = float(value)
36
- except:
37
- value = int(value)
38
- return value
39
-
40
-
41
- def iso8601():
42
- """
43
- return UTC time in iso8601 format.
44
-
45
- '2023-05-11T15:55:51.'
46
-
47
- """
48
- return f"{datetime.datetime.utcnow().isoformat()[:-4]}Z "
49
-
50
-
51
31
  class Scte35Profile:
52
32
  """
53
33
  Scte35Profile Manages the Scte35 Parsing Profile
@@ -78,6 +58,9 @@ class Scte35Profile:
78
58
 
79
59
  # self.stops = [0x23, 0x31, 0x33, 0x35, 0x37, 0x45, 0x47]
80
60
 
61
+ def __repr__(self):
62
+ return '\n\n '.join([f'\n{REV} Profile: {NORM}']+[f'{REV} {k} {NORM} = {v}' for k,v in vars(self).items()])
63
+
81
64
  def _is_int(self, vee, line):
82
65
  for item in vee:
83
66
  if isinstance(item, int):
@@ -127,16 +110,16 @@ class Scte35Profile:
127
110
  if isinstance(vee, list):
128
111
  vee = self._vee_is_ints(vee)
129
112
  return vee
130
-
131
- def show_profile(self, headline):
132
- """
133
- show_profile displays profile settings.
134
- """
135
- print(f"\n\n\t{REV}{headline}{NORM}\n")
136
- for que, vee in vars(self).items():
137
- vee = self._vee_is_list(vee)
138
- print(f"\t{que} = {vee}\n")
139
- time.sleep(0.3)
113
+ ##
114
+ ## def show_profile(self, headline):
115
+ ## """
116
+ ## show_profile displays profile settings.
117
+ ## """
118
+ ## print(f"\n\n\t{REV}{headline}{NORM}\n")
119
+ ## for que, vee in vars(self).items():
120
+ ## vee = self._vee_is_list(vee)
121
+ ## print(f"\t{que} = {vee}\n")
122
+ ## time.sleep(0.3)
140
123
 
141
124
  def _is_comment(self, line, this):
142
125
  if line[0] == "#" or line[:2] == "//":
@@ -217,7 +200,6 @@ class Scte35Profile:
217
200
  if os.path.isfile(pro_file):
218
201
  with open(pro_file, "r", encoding="utf-8") as pro_handle:
219
202
  self._parse_profile(pro_handle)
220
- self.show_profile("Profile:")
221
203
 
222
204
  def set_pts(self, cue):
223
205
  """
@@ -413,12 +395,12 @@ class AacParser:
413
395
  return round((pts % ROLLOVER), 6)
414
396
 
415
397
 
416
- class CuePuller:
398
+ class HlsParser:
417
399
  """
418
- CuePuller is the main object.
400
+ HlsParser is the Hls Parser
419
401
  """
420
402
 
421
- def __init__(self):
403
+ def __init__(self,pro_file="hls.profile"):
422
404
  self.media = deque()
423
405
  self.sidecar = "hls.sidecar"
424
406
  self.dumpfile = "hls.dump"
@@ -446,6 +428,7 @@ class CuePuller:
446
428
  self.hls_pts = "HLS"
447
429
  self.prof = Scte35Profile()
448
430
  self.prof.read_profile(self.pro_file)
431
+ self.rendition=None
449
432
  self.clear_files()
450
433
 
451
434
  @staticmethod
@@ -556,7 +539,7 @@ class CuePuller:
556
539
  self.cue_state = "OUT"
557
540
  self.break_timer = 0.0
558
541
  if ":" in line:
559
- self.break_duration = atoif(line.split(":")[1])
542
+ self.break_duration = atohif(line.split(":")[1])
560
543
  self.to_sidecar(self.pts, line)
561
544
  self.clear()
562
545
  print(f"{head}{self.dur_stuff()}{NSUB}{self.media_stuff()}\n")
@@ -769,7 +752,7 @@ class CuePuller:
769
752
  if "#EXTINF" in tags:
770
753
  if isinstance(tags["#EXTINF"], str):
771
754
  tags["#EXTINF"] = tags["#EXTINF"].rsplit(",", 1)[0]
772
- seg_time = round(atoif(tags["#EXTINF"]), 6)
755
+ seg_time = round(atohif(tags["#EXTINF"]), 6)
773
756
  line = self.auto_cuein(line)
774
757
  if self.pts is not None:
775
758
  self.pts += seg_time
@@ -885,7 +868,7 @@ class CuePuller:
885
868
  """
886
869
  if "TARGETDURATION" in line:
887
870
  if self.sleep_duration == 0:
888
- target_duration = atoif(line.split(":")[1])
871
+ target_duration = atohif(line.split(":")[1])
889
872
  self.sleep_duration = round(target_duration * 0.5, 3)
890
873
  print(f"{SUB}{REV} Target Duration {NORM} {target_duration}\n")
891
874
 
@@ -999,11 +982,14 @@ class CuePuller:
999
982
  self.update_cue_state()
1000
983
  time.sleep(self.sleep_duration)
1001
984
 
1002
- def _parse_manifest(self, manifest):
985
+ def _parse_manifest(self):
1003
986
  """
1004
987
  _parse_manifest, parses m3u8 files.
1005
988
  """
1006
- with reader(manifest) as m3u8:
989
+ if not self.rendition:
990
+ print("No rendition to parse")
991
+ return
992
+ with reader(self.rendition) as m3u8:
1007
993
  lines = []
1008
994
  m3u8_lines = self.decode_lines(m3u8.readlines())
1009
995
  self.chk_window_size(m3u8_lines)
@@ -1018,19 +1004,42 @@ class CuePuller:
1018
1004
  lines = []
1019
1005
  self._post_parse()
1020
1006
 
1021
- def pull(self, manifest):
1007
+ def pull(self):
1022
1008
  """
1023
1009
  pull m3u8 and parse it.
1024
1010
  """
1025
1011
  print(f"\n{SUB}{REV} Started {NORM} {iso8601()}\n")
1026
- print(f"{SUB}{REV} Manifest {NORM} {manifest}\n")
1027
- self.base_uri = manifest.rsplit("/", 1)[0]
1012
+ print(f"{SUB}{REV} Manifest {NORM} {self.rendition}\n")
1013
+ self.base_uri = self.rendition.rsplit("/", 1)[0]
1028
1014
  self.sliding_window = SlidingWindow()
1029
1015
  while self.reload:
1030
- self._parse_manifest(manifest)
1016
+ self._parse_manifest()
1031
1017
  with open(self.flat, "a") as flat:
1032
1018
  flat.write("#EXT-X-ENDLIST\n")
1033
1019
 
1020
+ def pick_one(self,lines, uri):
1021
+ """
1022
+ pick_one if lines come from a master.m3u8
1023
+ find the first rendition and make a uri or return uri.
1024
+ """
1025
+ for line in lines:
1026
+ if line.startswith(b"#EXT-X-STREAM-INF"):
1027
+ idx = lines.index(line) + 1
1028
+ line = lines[idx].decode("utf-8")
1029
+ base_url = uri.rsplit("/", 1)[0]
1030
+ uri = base_url + "/" + line
1031
+ uri.replace("\n", "")
1032
+ print(f'Rendition Found {uri}')
1033
+ self.rendition=uri
1034
+
1035
+
1036
+ def find_renditions(self,uri):
1037
+ """
1038
+ find_renditions search master.m3u8 for playable renditions.
1039
+ """
1040
+ with reader(uri) as arg:
1041
+ lines = arg.readlines()
1042
+ self.pick_one(lines, uri)
1034
1043
 
1035
1044
  def _chk_help():
1036
1045
  if "help" in sys.argv:
@@ -1054,30 +1063,6 @@ def precheck():
1054
1063
  _chk_profile()
1055
1064
 
1056
1065
 
1057
- def pick_one(lines, uri):
1058
- """
1059
- pick_one if lines come from a master.m3u8
1060
- find the first rendition and make a uri or return uri.
1061
- """
1062
- for line in lines:
1063
- if line.startswith(b"#EXT-X-STREAM-INF"):
1064
- idx = lines.index(line) + 1
1065
- line = lines[idx].decode("utf-8")
1066
- base_url = uri.rsplit("/", 1)[0]
1067
- uri = base_url + "/" + line
1068
- uri.replace("\n", "")
1069
- return uri
1070
-
1071
-
1072
- def find_renditions():
1073
- """
1074
- find_renditions search master.m3u8 for playable renditions.
1075
- """
1076
- uri = sys.argv[1]
1077
- with reader(uri) as arg:
1078
- lines = arg.readlines()
1079
- return pick_one(lines, uri)
1080
-
1081
1066
 
1082
1067
  def cli():
1083
1068
  """
@@ -1094,10 +1079,14 @@ def cli():
1094
1079
  is all that's required.
1095
1080
  """
1096
1081
  precheck()
1097
- playlist = find_renditions()
1098
- if playlist:
1099
- cpulr = CuePuller()
1100
- cpulr.pull(playlist)
1082
+ hlsparser = HlsParser()
1083
+ print(hlsparser.prof)
1084
+ print('\n\n')
1085
+ time.sleep(.3)
1086
+ print(f"{REV} Parsing Manifest {NORM}")
1087
+ manifest = sys.argv[1]
1088
+ hlsparser.find_renditions(manifest)
1089
+ hlsparser.pull()
1101
1090
  sys.exit()
1102
1091
 
1103
1092
 
@@ -2,7 +2,7 @@
2
2
  hlstags.py
3
3
 
4
4
  """
5
- from .stuff import atoif
5
+ from .stuff import atohif
6
6
 
7
7
 
8
8
  BASIC_TAGS = (
@@ -104,7 +104,7 @@ class TagParser:
104
104
  while tail:
105
105
  tail = self._strip_last_comma(tail)
106
106
  if "=" not in tail:
107
- self.tags[tag] = atoif(tail)
107
+ self.tags[tag] = atohif(tail)
108
108
  return
109
109
  tail, value = self._split_value(tag, tail)
110
110
  tail = self._split_key(tail, tag, value)
@@ -164,7 +164,7 @@ class TagParser:
164
164
  try:
165
165
  tail, value = tail.rsplit("=", 1)
166
166
  value += hold
167
- value = atoif(value)
167
+ value = atohif(value)
168
168
  except:
169
169
  tail = None
170
170
  return tail, value
@@ -144,9 +144,9 @@ class SpliceInfoSection(SCTE35Base):
144
144
  """
145
145
  encode SpliceInfoSection.tier
146
146
  """
147
- if not self.tier:
148
- self.tier = "0xfff"
149
- self._chk_var(str, nbin.add_hex, "tier", 12)
147
+ # if not self.tier:
148
+ self.tier = "0xfff"
149
+ nbin.add_hex( self.tier, 12)
150
150
 
151
151
  def _encode_splice_command(self, nbin):
152
152
  """
@@ -1,7 +1,10 @@
1
1
  """
2
2
  stuff.py functions and such common to threefive3.
3
+
4
+ print2, atohif, and iso8601
3
5
  """
4
6
 
7
+ import datetime
5
8
  from sys import stderr
6
9
 
7
10
 
@@ -12,15 +15,33 @@ def print2(gonzo=b""):
12
15
  print(gonzo, file=stderr, flush=True)
13
16
 
14
17
 
15
- def atoif(value):
18
+ def atohif(value):
16
19
  """
17
20
  atoif converts ascii to (int|float)
18
21
  """
19
22
  if isinstance(value, str):
20
23
  value= value.strip()
21
- value = value.replace(',','')
24
+ value = value.strip(',')
22
25
  if '.' in value:
23
26
  value = float(value)
27
+ elif '0x' in value.lower():
28
+ value = int(value,16)
24
29
  elif value.isdigit():
25
30
  value = int(value)
26
31
  return value
32
+
33
+
34
+
35
+ def iso8601():
36
+ """
37
+ return UTC time in iso8601 format.
38
+
39
+ '2023-05-11T15:55:51.'
40
+
41
+ """
42
+ return f"{datetime.datetime.utcnow().isoformat()[:-4]}Z "
43
+
44
+
45
+
46
+
47
+
@@ -5,6 +5,6 @@ from the cli tool run: threefive3 version
5
5
 
6
6
  major = 3
7
7
  minor = 0
8
- maintenance = 17
8
+ maintenance = 19
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.17
3
+ Version: 3.0.19
4
4
  Summary: threefive continued.
5
5
  Home-page: https://github.com/superkabuki/scte35
6
6
  Author: Adrian of Doom
@@ -19,16 +19,47 @@ Requires-Python: >=3.6
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
21
 
22
- # threefive3 SCTE-35 cli tool and python3 library.
22
+
23
+ # threefive3 SCTE-35 cli super tool and python3 library.
23
24
 
24
25
  ✅ SCTE-35 Parser ✅ SCTE-35 Encoder ✅ SCTE-35 HLS ✅ SCTE-35 Xml ✅ SCTE-35 Cli ✅ SCTE-35 library
25
26
 
26
27
 
27
- * Parses SCTE-35 from MPEGTS, HLS, XML, XML+Binary, Base64, Bytes, Hex, and Integers.
28
- * Built-in network support for http(s), UDP, and Multicast.
28
+ * Parses SCTE-35 from MPEGTS, HLS, XML, XML+Binary, Base64, Bytes, Hex, Integers, or JSON.
29
+ * Encode SCTE-35 to Base64, Bytes, Hex, Int, JSON, Xml, or Xml+binary.
30
+ * Built-in network support for HTTP(S), UDP, and Multicast.
29
31
  * Automatic AES decryption for HLS.
30
- * All HLS SCTE-35 Tags are Supported
32
+ * All HLS SCTE-35 Tags are Supported.
33
+ ___
34
+ # Latest release is v3.0.19
35
+ > Stay up to date, only the latest release is supported.
31
36
  ___
37
+ ### MPEGTS streams can be parsed for SCTE-35 with three lines of code.
38
+
39
+ ```py3
40
+ a@fu:~/build5/scte35/scte35$ pypy3
41
+ Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
42
+ [PyPy 7.3.11 with GCC 12.2.0] on linux
43
+ Type "help", "copyright", "credits" or "license" for more information.
44
+
45
+ >>>> from threefive3 import Stream
46
+
47
+ >>>> strm=Stream('https://futzu.com/xaa.ts')
48
+
49
+ >>>> strm.decode()
50
+ ```
51
+ # Heads Up!
52
+
53
+ > threefive3 is a lot to do by myself, in my spare time. I'm going to impose on y'all a little.
54
+
55
+ > I am currently working on error reporting. I am trying to aggregate the errors into each object, so if you have multiple errors, you can get them all at once, rather than one at a time. I need to try some stuff so I can see how it works and how it fails.
56
+ > If I have to do this alone, it will take much longer than if y'all help me.
57
+ > I will probably push a couple releases this week, I need you to use then.
58
+ > Be a good citizen and get involved. That's what makes open source work.
59
+
60
+
61
+ # Documentation
62
+
32
63
  * [Install](#install)
33
64
  * [SCTE-35 Cli](#the-cli-tool)
34
65
  * [SCTE-35 Xml ](https://github.com/superkabuki/threefive3/blob/main/xml.md)
@@ -38,19 +69,17 @@ ___
38
69
  * [Encode SCTE-35](https://github.com/superkabuki/threefive3/blob/main/encode.md)
39
70
  * [FFmpeg SCTE35](https://github.com/superkabuki/FFmpeg_SCTE35)
40
71
 
41
- ## MPEGTS streams can be parsed for SCTE-35 with three lines of code.
72
+ * _The cli tool comes with builtin documentation just type_ `threefive3 help`
42
73
 
43
- ```py3
44
- a@fu:~/build5/scte35/scte35$ pypy3
74
+ * _The python built in help is always the most up to date._
75
+
76
+ ```rebol
77
+ a@fu:~/build7/threefive3$ pypy3
45
78
  Python 3.9.16 (7.3.11+dfsg-2+deb12u3, Dec 30 2024, 22:36:23)
46
79
  [PyPy 7.3.11 with GCC 12.2.0] on linux
47
80
  Type "help", "copyright", "credits" or "license" for more information.
48
-
49
- >>>> from threefive3 import Stream
50
-
51
- >>>> strm=Stream('https://futzu.com/xaa.ts')
52
-
53
- >>>> strm.decode()
81
+ >>>> from threefive import Stream
82
+ >>>> help(Stream)
54
83
  ```
55
84
 
56
85
  ___
File without changes
File without changes
File without changes