From 42028f3e33c5bf52242f8fb166b3ccedef1ecbe8 Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Tue, 18 Aug 2020 11:05:04 +0200 Subject: [PATCH] platformtools dialogs kodi 19 --- core/downloadtools.py | 4 ++-- core/trakt_tools.py | 5 ++--- lib/onesecmail.py | 3 +-- platformcode/platformtools.py | 25 +++++++++---------------- servers/debriders/realdebrid.py | 4 ++-- service.py | 3 +-- specials/search.py | 4 ++-- tests/test_generic.py | 16 ++++++++-------- 8 files changed, 27 insertions(+), 37 deletions(-) diff --git a/core/downloadtools.py b/core/downloadtools.py index a18af29e..7ceed430 100644 --- a/core/downloadtools.py +++ b/core/downloadtools.py @@ -271,7 +271,7 @@ def downloadfile(url, nombrefichero, headers=None, silent=False, continuar=False # Create the progress dialog if not silent: - progreso = platformtools.dialog_progress(header, "Downloading...", url, nombrefichero) + progreso = platformtools.dialog_progress(header, "Downloading..." + '\n' + url + '\n' + nombrefichero) # If the platform does not return a valid dialog box, it assumes silent mode if progreso is None: @@ -520,7 +520,7 @@ def downloadfileGzipped(url, pathfichero): # Create the progress dialog from platformcode import platformtools - progreso = platformtools.dialog_progress("addon", config.get_localized_string(60200), url.split("|")[0], nombrefichero) + progreso = platformtools.dialog_progress("addon", config.get_localized_string(60200) + '\n' + url.split("|")[0] + '\n' + nombrefichero) # Socket timeout at 60 seconds socket.setdefaulttimeout(10) diff --git a/core/trakt_tools.py b/core/trakt_tools.py index a7b046af..7dead7b0 100644 --- a/core/trakt_tools.py +++ b/core/trakt_tools.py @@ -71,9 +71,8 @@ def token_trakt(item): else: import time dialog_auth = platformtools.dialog_progress(config.get_localized_string(60251), - config.get_localized_string(60252) % item.verify_url, - config.get_localized_string(60253) - % item.user_code, + config.get_localized_string(60252) % item.verify_url + '\n' + + config.get_localized_string(60253) % item.user_code + '\n' + config.get_localized_string(60254)) # Generalmente cada 5 segundos se intenta comprobar si el usuario ha introducido el código diff --git a/lib/onesecmail.py b/lib/onesecmail.py index 21a5c0a4..7fe81993 100644 --- a/lib/onesecmail.py +++ b/lib/onesecmail.py @@ -37,8 +37,7 @@ def readLastMessage(mail): def waitForMail(mail, timeout=50): - dialog = platformtools.dialog_progress(config.get_localized_string(20000), - 'verifica tramite mail richiesta dal sito, sono in attesa di nuove mail sulla casella ' + mail) + dialog = platformtools.dialog_progress(config.get_localized_string(20000), 'verifica tramite mail richiesta dal sito, sono in attesa di nuove mail sulla casella ' + mail) secs = 0 while secs < timeout: msg = readLastMessage(mail) diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index e005ab88..1c2866a7 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -30,17 +30,10 @@ class XBMCPlayer(xbmc.Player): xbmc_player = XBMCPlayer() -def makeMessage(line1, line2, line3): - message = line1 - if line2: - message += '\n' + line2 - if line3: - message += '\n' + line3 - return message -def dialog_ok(heading, line1, line2="", line3=""): +def dialog_ok(heading, message): dialog = xbmcgui.Dialog() - return dialog.ok(heading, makeMessage(line1, line2, line3)) + return dialog.ok(heading, message) def dialog_notification(heading, message, icon=3, time=5000, sound=True): @@ -52,19 +45,19 @@ def dialog_notification(heading, message, icon=3, time=5000, sound=True): dialog_ok(heading, message) -def dialog_yesno(heading, line1, line2="", line3="", nolabel=config.get_localized_string(70170), yeslabel=config.get_localized_string(30022), autoclose=0, customlabel=None): +def dialog_yesno(heading, message, nolabel=config.get_localized_string(70170), yeslabel=config.get_localized_string(30022), autoclose=0, customlabel=None): # customlabel only on kodi 19 dialog = xbmcgui.Dialog() if config.get_platform() == 'kodi-matrix': if autoclose: - return dialog.yesno(heading, makeMessage(line1, line2, line3), nolabel=nolabel, yeslabel=yeslabel, customlabel=customlabel, autoclose=autoclose) + return dialog.yesno(heading, message, nolabel=nolabel, yeslabel=yeslabel, customlabel=customlabel, autoclose=autoclose) else: - return dialog.yesno(heading, makeMessage(line1, line2, line3), nolabel=nolabel, yeslabel=yeslabel, customlabel=customlabel) + return dialog.yesno(heading, message, nolabel=nolabel, yeslabel=yeslabel, customlabel=customlabel) else: if autoclose: - return dialog.yesno(heading, makeMessage(line1, line2, line3), nolabel=nolabel, yeslabel=yeslabel, autoclose=autoclose) + return dialog.yesno(heading, message, nolabel=nolabel, yeslabel=yeslabel, autoclose=autoclose) else: - return dialog.yesno(heading, makeMessage(line1, line2, line3), nolabel=nolabel, yeslabel=yeslabel) + return dialog.yesno(heading, message, nolabel=nolabel, yeslabel=yeslabel) def dialog_select(heading, _list, preselect=0, useDetails=False): @@ -75,9 +68,9 @@ def dialog_multiselect(heading, _list, autoclose=0, preselect=[], useDetails=Fal return xbmcgui.Dialog().multiselect(heading, _list, autoclose=autoclose, preselect=preselect, useDetails=useDetails) -def dialog_progress(heading, line1, line2=" ", line3=" "): +def dialog_progress(heading, message): dialog = xbmcgui.DialogProgress() - dialog.create(heading, makeMessage(line1, line2, line3)) + dialog.create(heading, message) return dialog diff --git a/servers/debriders/realdebrid.py b/servers/debriders/realdebrid.py index 22b7ff4b..558ddbc9 100755 --- a/servers/debriders/realdebrid.py +++ b/servers/debriders/realdebrid.py @@ -112,8 +112,8 @@ def authentication(): intervalo = data["interval"] dialog_auth = platformtools.dialog_progress(config.get_localized_string(70414), - config.get_localized_string(60252) % verify_url, - config.get_localized_string(70413) % user_code, + config.get_localized_string(60252) % verify_url + '\n' + + config.get_localized_string(70413) % user_code + '\n' + config.get_localized_string(60254)) # Generalmente cada 5 segundos se intenta comprobar si el usuario ha introducido el código diff --git a/service.py b/service.py index 22a7956a..4dee0dda 100644 --- a/service.py +++ b/service.py @@ -48,8 +48,7 @@ def update(path, p_dialog, i, t, serie, overwrite): if channel_enabled: heading = config.get_localized_string(20000) - p_dialog.update(int(math.ceil((i + 1) * t)), heading, config.get_localized_string(60389) % (serie.contentSerieName, - serie.channel.capitalize())) + p_dialog.update(int(math.ceil((i + 1) * t)), heading, config.get_localized_string(60389) % (serie.contentSerieName, serie.channel.capitalize())) try: pathchannels = filetools.join(config.get_runtime_path(), "channels", serie.channel + '.py') logger.log("loading channel: " + pathchannels + " " + diff --git a/specials/search.py b/specials/search.py index 4fa53992..135dde4d 100644 --- a/specials/search.py +++ b/specials/search.py @@ -201,7 +201,7 @@ def channel_search(item): searching_titles += channel_titles cnt = 0 - progress = platformtools.dialog_progress(config.get_localized_string(30993) % item.title, config.get_localized_string(70744) % len(channel_list), ', '.join(searching_titles)) + progress = platformtools.dialog_progress(config.get_localized_string(30993) % item.title, config.get_localized_string(70744) % len(channel_list) + '\n' + ', '.join(searching_titles)) config.set_setting('tmdb_active', False) search_action_list = [] @@ -254,7 +254,7 @@ def channel_search(item): progress.close() cnt = 0 - progress = platformtools.dialog_progress(config.get_localized_string(30993) % item.title, config.get_localized_string(60295), config.get_localized_string(60293)) + progress = platformtools.dialog_progress(config.get_localized_string(30993) % item.title, config.get_localized_string(60295) + '\n' + config.get_localized_string(60293)) config.set_setting('tmdb_active', True) # res_count = 0 diff --git a/tests/test_generic.py b/tests/test_generic.py index 43a5fef3..eb872eca 100644 --- a/tests/test_generic.py +++ b/tests/test_generic.py @@ -28,7 +28,7 @@ if 'KOD_TST_CH' not in os.environ: xbmc.get_add_on_info_from_calling_script = add_on_info -import HtmlTestRunner +# import HtmlTestRunner import parameterized from platformcode import config, logger @@ -145,7 +145,7 @@ for chItem in channel_list: serversFound = {} for it in mainlist: - print 'preparing ' + ch + ' -> ' + it.title + print('preparing ' + ch + ' -> ' + it.title) if it.action == 'channel_config': hasChannelConfig = True @@ -177,7 +177,7 @@ for chItem in channel_list: from specials import news dictNewsChannels, any_active = news.get_channels_list() -print channels +print(channels) # only 1 server item for single server serverNames = [] serversFinal = [] @@ -207,7 +207,7 @@ class GenericChannelTest(unittest.TestCase): title, itemlist in ch['menuItemlist'].items()]) class GenericChannelMenuItemTest(unittest.TestCase): def test_menu(self): - print 'testing ' + self.ch + ' --> ' + self.title + print('testing ' + self.ch + ' --> ' + self.title) self.assertTrue(self.module.host, 'channel ' + self.ch + ' has not a valid hostname') self.assertTrue(self.itemlist, 'channel ' + self.ch + ' -> ' + self.title + ' is empty') self.assertTrue(self.serversFound, @@ -245,7 +245,7 @@ class GenericChannelMenuItemTest(unittest.TestCase): self.assertTrue(nextPageItemlist, 'channel ' + self.ch + ' -> ' + self.title + ' has nextpage not working') - print '
test passed' + print('
test passed') @parameterized.parameterized_class(serversFinal) @@ -253,7 +253,7 @@ class GenericServerTest(unittest.TestCase): def test_get_video_url(self): module = __import__('servers.%s' % self.name, fromlist=["servers.%s" % self.name]) page_url = self.server.url - print 'testing ' + page_url + print('testing ' + page_url) self.assert_(hasattr(module, 'test_video_exists'), self.name + ' has no test_video_exists') try: if module.test_video_exists(page_url)[0]: @@ -261,7 +261,7 @@ class GenericServerTest(unittest.TestCase): server_parameters = servertools.get_server_parameters(self.name) self.assertTrue(urls or server_parameters.get("premium"), self.name + ' scraper did not return direct urls for ' + page_url) - print urls + print(urls) for u in urls: spl = u[1].split('|') if len(spl) == 2: @@ -274,7 +274,7 @@ class GenericServerTest(unittest.TestCase): h, v = name.split('=') h = str(h) headers[h] = str(v) - print headers + print(headers) if 'magnet:?' in directUrl: # check of magnet links not supported continue page = downloadpage(directUrl, headers=headers, only_headers=True, use_requests=True)