Skip to content

Commit

Permalink
better memory management for series experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
kiddac committed Jan 25, 2025
1 parent 7a774a4 commit e28dbf4
Show file tree
Hide file tree
Showing 9 changed files with 331 additions and 297 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ def createSetup(self):
self.list.append(getConfigListEntry(_("Short name or provider name:"), self.iptvname_cfg))
self.list.append(getConfigListEntry(_("Use name as bouquet prefix"), self.prefix_name_cfg))

if self.hide_live is False:
if not self.hide_live:
self.list.append(getConfigListEntry(_("Show LIVE category if available:"), self.show_live_cfg))
if self.show_live_cfg.value:
self.list.append(getConfigListEntry(_("Stream Type LIVE:"), self.live_type_cfg))
Expand All @@ -339,17 +339,15 @@ def createSetup(self):
self.list.append(getConfigListEntry(_("LIVE category bouquet order"), self.live_category_order_cfg))
self.list.append(getConfigListEntry(_("LIVE stream bouquet order"), self.live_stream_order_cfg))

if self.hide_vod is False:
if not self.hide_vod:
self.list.append(getConfigListEntry(_("Show VOD category if available:"), self.show_vod_cfg))

if self.hide_series is False:
if not self.hide_series:
self.list.append(getConfigListEntry(_("Show SERIES category if available:"), self.show_series_cfg))

if self.hide_vod is False or self.hide_series is False:
if not self.hide_vod or not self.hide_series:
if self.show_vod_cfg.value or self.show_series_cfg.value:
self.list.append(getConfigListEntry(_("Stream Type VOD/SERIES:"), self.vod_type_cfg))

if self.show_vod_cfg.value:
self.list.append(getConfigListEntry(_("VOD/SERIES category bouquet order"), self.vod_category_order_cfg))
self.list.append(getConfigListEntry(_("VOD/SERIES streams bouquet order"), self.vod_stream_order_cfg))

Expand Down Expand Up @@ -433,7 +431,7 @@ def save(self):

self["config"].instance.moveSelectionTo(1) # hack to hide texthelper

if self.show_live_cfg.value is False and self.show_vod_cfg.value is False and self.show_series_cfg.value is False:
if not self.show_live_cfg.value and not self.show_vod_cfg.value and not self.show_series_cfg.value:
self.session.open(MessageBox, _("No bouquets selected."), MessageBox.TYPE_ERROR, timeout=5)
self.createSetup()
return
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

debugs = True
debugs = False


def check_internet():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,41 @@ def downloadUrlMulti(url, output_file=None):
if ext == "json":
json_content = r.json()
return category, json_content
else:

chunk_size = 8192 * 8 # 128 KB

if output_file:
# Save to the specified output file
output_dir = os.path.dirname(output_file)
if not os.path.exists(output_dir):
os.makedirs(output_dir)

chunk_size = 8192 * 8 # 128 KB
with open(output_file, 'wb') as f:
for chunk in r.iter_content(chunk_size=chunk_size):
f.write(chunk)
if chunk: # Only write non-empty chunks
f.write(chunk)

return category, output_file

else:
# Collect chunks into memory and return as content
if pythonVer == 2:
content = ''
else:
content = b""

for chunk in r.iter_content(chunk_size=chunk_size):
if chunk: # Only append non-empty chunks
if ext == "text":
if pythonVer == 2:
content += chunk.decode('utf-8', errors='ignore')
else:
content += chunk.decode('utf-8', errors='ignore').encode('utf-8')
else:
content += chunk

return category, content

except requests.Timeout as e:
print("Error message: {}".format(str(e)))
return category, ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
except ImportError:
hasConcurrent = False

debugs = True
debugs = False

pythonFull = float(str(sys.version_info.major) + "." + str(sys.version_info.minor))
pythonVer = sys.version_info.major
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def processFiles():

with open(playlist_file, "w") as f:
for line in lines:
line = line.strip()
line = re.sub(" +", " ", line)
line = line.strip(" ")
if not line.startswith(("http://", "https://", "#")):
Expand Down
Loading

0 comments on commit e28dbf4

Please sign in to comment.