Skip to content

Commit 4fd0156

Browse files
committed
Initial commit
1 parent 3a65217 commit 4fd0156

File tree

8 files changed

+425
-55
lines changed

8 files changed

+425
-55
lines changed

src/cpython/kai/__init__.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from .exceptions import *
2-
from ._types import *
2+
from .types import *
33

44
__all__ = [
55
"KaiError",
@@ -44,7 +44,9 @@
4444
"M3U8Media",
4545
"M3U8VariantStream",
4646
"M3U8Resolution",
47-
"M3U8ByteRange"
47+
"M3U8ByteRange",
48+
"Dict",
49+
"List"
4850
]
4951

5052
__locals = locals()

src/cpython/kai/__kai.py

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
sys.path.append('/storage/emulated/0/Kai/src/cpython')
3+
34
from _kai import (
45
m3u8stream_init,
56
m3u8stream_load,
@@ -8,13 +9,19 @@
89
m3u8stream_getstream
910
)
1011

12+
from kai.types import *
13+
14+
1115
from exceptions import code2exception, KaiErrorCode
1216

13-
class M3U8Stream:
17+
class M3U8Stream(List):
1418

1519
def __init__(self):
1620
self.instance = m3u8stream_init()
1721

22+
def _fetch_objects(self):
23+
self.base_list = m3u8stream_getstream(self.instance)
24+
1825
def ensure_non_error(self):
1926
code = KaiErrorCode(self.code)
2027

@@ -32,8 +39,7 @@ def load(self, something, base_url = None):
3239
)
3340

3441
self.ensure_non_error()
35-
36-
return m3u8stream_getstream(self.instance)
42+
self._fetch_objects()
3743

3844
return self
3945

@@ -45,6 +51,7 @@ def load_url(self, url, base_url = None):
4551
)
4652

4753
self.ensure_non_error()
54+
self._fetch_objects()
4855

4956
return self
5057

@@ -56,14 +63,18 @@ def load_file(self, filename, base_url = None):
5663
)
5764

5865
self.ensure_non_error()
66+
self._fetch_objects()
5967

6068
return self
6169

6270
stream = M3U8Stream()
6371
a=stream.load("/storage/emulated/0/cq3l8ci23aks73akgsug/master.m3u8")
6472
import sys
73+
"""
6574
for item in a.stream.iter():
6675
pass
6776
#print(repr(item))
77+
6878
print(sys.getrefcount(a.stream))
79+
"""
6980
print(a)

src/cpython/kai/_types/__init__.py src/cpython/kai/types/__init__.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
M3U8ByteRange
3030
)
3131

32+
from .base import (
33+
Dict,
34+
List
35+
)
3236

3337
__all__ = [
3438
"M3U8MediaType",
@@ -55,5 +59,7 @@
5559
"M3U8Media",
5660
"M3U8VariantStream",
5761
"M3U8Resolution",
58-
"M3U8ByteRange"
62+
"M3U8ByteRange",
63+
"Dict",
64+
"List"
5965
]
File renamed without changes.

src/cpython/kai/_types/m3u8.py src/cpython/kai/types/m3u8.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
class M3U8Resolution:
1+
from .base import Dict
2+
3+
class M3U8Resolution(Dict):
24

35
def __init__(self, width, height):
46
self.width = width
57
self.height = height
68

7-
class M3U8ByteRange:
9+
class M3U8ByteRange(Dict):
810

911
def __init__(self, length, offset):
1012
self.length = length

src/cpython/kai/_types/m3u8stream.py src/cpython/kai/types/m3u8stream.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,8 @@ def __init__(self, type, tag):
135135
self.type = type
136136
self.tag = tag
137137

138-
class M3U8KeyFormatVersions:
139-
140-
def __init__(self, items):
141-
self.items = items
138+
class M3U8KeyFormatVersions(List):
139+
pass
142140

143141
class M3U8Key(Dict):
144142

src/cpython/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def get_long_description():
5454
]
5555

5656
setuptools.setup(
57-
name="Kai",
57+
name="kai",
5858
version=version,
5959
author="Kartatz",
6060
author_email="[email protected]",

0 commit comments

Comments
 (0)