Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kartatz committed Oct 1, 2024
1 parent 3a65217 commit 4fd0156
Show file tree
Hide file tree
Showing 8 changed files with 425 additions and 55 deletions.
6 changes: 4 additions & 2 deletions src/cpython/kai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .exceptions import *
from ._types import *
from .types import *

__all__ = [
"KaiError",
Expand Down Expand Up @@ -44,7 +44,9 @@
"M3U8Media",
"M3U8VariantStream",
"M3U8Resolution",
"M3U8ByteRange"
"M3U8ByteRange",
"Dict",
"List"
]

__locals = locals()
Expand Down
17 changes: 14 additions & 3 deletions src/cpython/kai/__kai.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import sys
sys.path.append('/storage/emulated/0/Kai/src/cpython')

from _kai import (
m3u8stream_init,
m3u8stream_load,
Expand All @@ -8,13 +9,19 @@
m3u8stream_getstream
)

from kai.types import *


from exceptions import code2exception, KaiErrorCode

class M3U8Stream:
class M3U8Stream(List):

def __init__(self):
self.instance = m3u8stream_init()

def _fetch_objects(self):
self.base_list = m3u8stream_getstream(self.instance)

def ensure_non_error(self):
code = KaiErrorCode(self.code)

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

self.ensure_non_error()

return m3u8stream_getstream(self.instance)
self._fetch_objects()

return self

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

self.ensure_non_error()
self._fetch_objects()

return self

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

self.ensure_non_error()
self._fetch_objects()

return self

stream = M3U8Stream()
a=stream.load("/storage/emulated/0/cq3l8ci23aks73akgsug/master.m3u8")
import sys
"""
for item in a.stream.iter():
pass
#print(repr(item))
print(sys.getrefcount(a.stream))
"""
print(a)
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
M3U8ByteRange
)

from .base import (
Dict,
List
)

__all__ = [
"M3U8MediaType",
Expand All @@ -55,5 +59,7 @@
"M3U8Media",
"M3U8VariantStream",
"M3U8Resolution",
"M3U8ByteRange"
"M3U8ByteRange",
"Dict",
"List"
]
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
class M3U8Resolution:
from .base import Dict

class M3U8Resolution(Dict):

def __init__(self, width, height):
self.width = width
self.height = height

class M3U8ByteRange:
class M3U8ByteRange(Dict):

def __init__(self, length, offset):
self.length = length
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,8 @@ def __init__(self, type, tag):
self.type = type
self.tag = tag

class M3U8KeyFormatVersions:

def __init__(self, items):
self.items = items
class M3U8KeyFormatVersions(List):
pass

class M3U8Key(Dict):

Expand Down
2 changes: 1 addition & 1 deletion src/cpython/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def get_long_description():
]

setuptools.setup(
name="Kai",
name="kai",
version=version,
author="Kartatz",
author_email="[email protected]",
Expand Down
Loading

0 comments on commit 4fd0156

Please sign in to comment.