Skip to content

Commit

Permalink
more custom-sids amends. Doesn't effect most people.
Browse files Browse the repository at this point in the history
  • Loading branch information
kiddac committed Dec 18, 2024
1 parent 21d654c commit cfa9342
Show file tree
Hide file tree
Showing 14 changed files with 406 additions and 254 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from . import globalfunctions as bmx
from . import parsem3u as parsem3u
from .bmxStaticText import StaticText
from .plugin import cfg, epgimporter, hasConcurrent, hasMultiprocessing, playlist_file, playlists_json, skin_directory
from .plugin import cfg, epgimporter, hasConcurrent, hasMultiprocessing, playlist_file, playlists_json, skin_directory, debugs

import json
import os
Expand All @@ -19,7 +19,6 @@
from Screens.MessageBox import MessageBox
from Screens.Screen import Screen


try:
from urlparse import parse_qs, urlparse
except:
Expand All @@ -28,6 +27,9 @@

class BmxBouquetSettings(ConfigListScreen, Screen):
def __init__(self, session):
if debugs:
print("*** init ***")

Screen.__init__(self, session)

self.session = session
Expand Down Expand Up @@ -81,6 +83,8 @@ def __init__(self, session):
self.onLayoutFinish.append(self.__layoutFinished)

def clearCaches(self):
if debugs:
print("*** clearcaches ***")
try:
os.system("echo 1 > /proc/sys/vm/drop_caches")
os.system("echo 2 > /proc/sys/vm/drop_caches")
Expand All @@ -95,6 +99,8 @@ def cancel(self):
self.close()

def start(self):
if debugs:
print("*** start ***")
try:
self.timer_conn = self.timer.timeout.connect(self.makeUrlList)
except:
Expand All @@ -105,6 +111,8 @@ def start(self):
self.timer.start(10, True)

def makeUrlList(self):
if debugs:
print("*** makeurllist ***")
self.url_list = []

if glob.current_playlist["playlist_info"]["playlist_type"] != "local":
Expand All @@ -123,6 +131,8 @@ def makeUrlList(self):
self.checkCategories()

def processDownloads(self, outputtype=None):
if debugs:
print("*** processdownloads ***")
results = ""
threads = min(len(self.url_list), 10)
if outputtype == "json":
Expand Down Expand Up @@ -216,17 +226,25 @@ def processDownloads(self, outputtype=None):
os.remove(output_file)

def parseM3u8Playlist(self, response=None):
if debugs:
print("*** parseM3u8Playlist ***")
self.live_streams, self.vod_streams, self.series_streams = parsem3u.parseM3u8Playlist(response)
self.makeM3u8CategoriesJson()

def makeM3u8CategoriesJson(self):
if debugs:
print("*** parseM3u8Playlist ***")
parsem3u.makeM3u8CategoriesJson(self.live_streams, self.vod_streams, self.series_streams)
self.makeM3u8StreamsJson()

def makeM3u8StreamsJson(self):
if debugs:
print("*** makeM3u8StreamsJson ***")
parsem3u.makeM3u8StreamsJson(self.live_streams, self.vod_streams, self.series_streams)

def checkCategories(self):
if debugs:
print("*** checkCategories ***")
if not glob.current_playlist["data"]["live_categories"]:
self.hide_live = True
glob.current_playlist["settings"]["show_live"] = False
Expand All @@ -242,6 +260,8 @@ def checkCategories(self):
self.initConfig()

def initConfig(self):
if debugs:
print("*** initConfig ***")
live_stream_type_choices = [("1", "DVB(1)"), ("4097", "IPTV(4097)")]
vod_stream_type_choices = [("4097", "IPTV(4097)")]

Expand Down Expand Up @@ -304,6 +324,8 @@ def initConfig(self):
self.createSetup()

def createSetup(self):
if debugs:
print("*** createSetup ***")
self.list = []
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))
Expand Down Expand Up @@ -346,6 +368,8 @@ def createSetup(self):
self.handleInputHelpers()

def handleInputHelpers(self):
if debugs:
print("*** handleInputHelpers ***")
currConfig = self["config"].getCurrent()

if currConfig is not None:
Expand Down Expand Up @@ -380,6 +404,8 @@ def handleInputHelpers(self):
self["VKeyIcon"].hide()

def changedEntry(self):
if debugs:
print("*** changedEntry ***")
self.item = self["config"].getCurrent()
for x in self.onChangedEntry:
x()
Expand All @@ -391,12 +417,18 @@ def changedEntry(self):
pass

def getCurrentEntry(self):
if debugs:
print("*** getCurrentEntry ***")
return self["config"].getCurrent() and self["config"].getCurrent()[0] or ""

def getCurrentValue(self):
if debugs:
print("*** getCurrentValue ****")
return self["config"].getCurrent() and str(self["config"].getCurrent()[1].getText()) or ""

def save(self):
if debugs:
print("*** save ***")
if self.list:

self["config"].instance.moveSelectionTo(1) # hack to hide texthelper
Expand Down Expand Up @@ -531,6 +563,8 @@ def save(self):
self.getPlaylistUserFile()

def getPlaylistUserFile(self):
if debugs:
print("*** getPlaylistUserFile ***")
if self.playlists_all:
for idx, playlists in enumerate(self.playlists_all):
if playlists["playlist_info"]["full_url"] == self.full_url:
Expand Down Expand Up @@ -560,6 +594,8 @@ def getPlaylistUserFile(self):
self.writeJsonFile()

def writeJsonFile(self):
if debugs:
print("*** writeJsonFile ***")
with open(playlists_json, "w") as f:
json.dump(self.playlists_all, f)
self.clearCaches()
Expand All @@ -569,12 +605,16 @@ def writeJsonFile(self):
self.session.openWithCallback(self.exit, choosecategories.BmxChooseCategories)

def exit(self, answer=None):
if debugs:
print("*** exit ***")
if glob.finished:
self.clearCaches()
self.clearSeries()
self.close(True)

def clearSeries(self):
if debugs:
print("*** clearSeries ***")
playlists_all = bmx.getPlaylistJson()

if playlists_all:
Expand Down
Loading

0 comments on commit cfa9342

Please sign in to comment.