From f779782cdc7e8c7efda641f5bff0626471544bc2 Mon Sep 17 00:00:00 2001 From: marco <10120390+mac12m99@users.noreply.github.com> Date: Wed, 25 Nov 2020 21:03:40 +0100 Subject: [PATCH] =?UTF-8?q?Nuovi=20messaggi=20di=20errore,=20fix=20autopla?= =?UTF-8?q?y=20(wstream=20aveva=20sempre=20la=20priorit=C3=A0)=20e=20modif?= =?UTF-8?q?iche=20varie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/filetools.py | 1 - core/servertools.py | 8 +-- core/support.py | 31 +++++++--- platformcode/launcher.py | 30 +++------- platformcode/logger.py | 8 ++- platformcode/platformtools.py | 57 +++++++++++++++++-- .../resource.language.en_gb/strings.po | 16 +++--- .../resource.language.it_it/strings.po | 24 ++++---- servers/wstream.json | 2 +- 9 files changed, 114 insertions(+), 63 deletions(-) diff --git a/core/filetools.py b/core/filetools.py index 481f015c..d99662bc 100644 --- a/core/filetools.py +++ b/core/filetools.py @@ -8,7 +8,6 @@ from __future__ import division # from builtins import str import io -from future.builtins import range from past.utils import old_div import sys PY3 = False diff --git a/core/servertools.py b/core/servertools.py index 8017f6c7..874e67d3 100644 --- a/core/servertools.py +++ b/core/servertools.py @@ -353,7 +353,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo video_urls.extend(response) except: logger.error("Error getting url in free mode") - error_messages.append(config.get_localized_string(60006) % server_name) + error_messages.append(config.get_localized_string(60014)) import traceback logger.error(traceback.format_exc()) @@ -370,10 +370,10 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo elif response and response[0][0]: error_messages.append(response[0][0]) else: - error_messages.append(config.get_localized_string(60006) % server_name) + error_messages.append(config.get_localized_string(60014)) except: logger.error("Server errorr: %s" % opcion) - error_messages.append(config.get_localized_string(60006) % server_name) + error_messages.append(config.get_localized_string(60014)) import traceback logger.error(traceback.format_exc()) @@ -394,7 +394,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo # If we do not have urls or error messages, we put a generic one elif not video_urls and not error_messages: - error_messages.append(config.get_localized_string(60006) % get_server_parameters(server)["name"]) + error_messages.append(config.get_localized_string(60014)) return video_urls, len(video_urls) > 0, "
".join(error_messages) diff --git a/core/support.py b/core/support.py index cebac317..4ba22c2d 100755 --- a/core/support.py +++ b/core/support.py @@ -385,7 +385,10 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t it.__setattr__(lg, match[lg]) if 'itemHook' in args: - it = args['itemHook'](it) + try: + it = args['itemHook'](it) + except: + raise logger.ChannelScraperException itemlist.append(it) return itemlist, matches @@ -407,7 +410,6 @@ def scrape(func): args = func(*args) function = func.__name__ if not 'actLike' in args else args['actLike'] # info('STACK= ',inspect.stack()[1][3]) - item = args['item'] action = args.get('action', 'findvideos') @@ -469,23 +471,33 @@ def scrape(func): typeActionDict, blacklist, search, pag, function, lang, sceneTitle, group) if 'itemlistHook' in args: - itemlist = args['itemlistHook'](itemlist) + try: + itemlist = args['itemlistHook'](itemlist) + except: + raise logger.ChannelScraperException # if url may be changed and channel has findhost to update if 'findhost' in func.__globals__ and not itemlist: info('running findhost ' + func.__module__) ch = func.__module__.split('.')[-1] - host = config.get_channel_url(func.__globals__['findhost'], ch, True) + try: + host = config.get_channel_url(func.__globals__['findhost'], ch, True) - parse = list(urlparse.urlparse(item.url)) - parse[1] = scrapertools.get_domain_from_url(host) - item.url = urlparse.urlunparse(parse) + parse = list(urlparse.urlparse(item.url)) + parse[1] = scrapertools.get_domain_from_url(host) + item.url = urlparse.urlunparse(parse) + except: + raise logger.ChannelScraperException data = None itemlist = [] matches = [] else: break + if not data: + from platformcode.logger import WebErrorException + raise WebErrorException(urlparse.urlparse(item.url)[1], item.channel) + if group and item.grouped or args.get('groupExplode'): import copy nextArgs = copy.copy(args) @@ -548,7 +560,10 @@ def scrape(func): itemlist = thumb(itemlist, genre=True) if 'fullItemlistHook' in args: - itemlist = args['fullItemlistHook'](itemlist) + try: + itemlist = args['fullItemlistHook'](itemlist) + except: + raise logger.ChannelScraperException # itemlist = filterLang(item, itemlist) # causa problemi a newest diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 6bba9076..efe5cc19 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -341,13 +341,10 @@ def run(item=None): logger.error(traceback.format_exc()) - patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\", "\\\\") + r'([^.]+)\.py"' - Channel = scrapertools.find_single_match(traceback.format_exc(), patron) - platformtools.dialog_ok( - config.get_localized_string(59985) + Channel, - config.get_localized_string(60013) %(e)) - except: + config.get_localized_string(59985) % e.channel, + config.get_localized_string(60013) % e.url) + except Exception as e: import traceback from core import scrapertools @@ -356,26 +353,15 @@ def run(item=None): patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\", "\\\\") + r'([^.]+)\.py"' Channel = scrapertools.find_single_match(traceback.format_exc(), patron) - try: - import xbmc - if config.get_platform(True)['num_version'] < 14: - log_name = "xbmc.log" - else: - log_name = "kodi.log" - log_message = config.get_localized_string(50004) + xbmc.translatePath("special://logpath") + log_name - except: - log_message = "" - - if Channel: + if Channel or e.__class__ == logger.ChannelScraperException: if item.url: - if platformtools.dialog_yesno(config.get_localized_string(60087) % Channel, config.get_localized_string(60014) + '\n' + log_message, nolabel='ok', yeslabel=config.get_localized_string(70739)): + if platformtools.dialog_yesno(config.get_localized_string(60087) % Channel, config.get_localized_string(60014), nolabel='ok', yeslabel=config.get_localized_string(70739)): run(Item(action="open_browser", url=item.url)) else: - platformtools.dialog_ok(config.get_localized_string(60087) % Channel, config.get_localized_string(60014) + '\n' + log_message) + platformtools.dialog_ok(config.get_localized_string(60087) % Channel, config.get_localized_string(60014)) else: - platformtools.dialog_ok( - config.get_localized_string(60038), - config.get_localized_string(60015) + '\n' + log_message) + if platformtools.dialog_yesno(config.get_localized_string(60038), config.get_localized_string(60015)): + run(Item(channel="setting", action="report_menu")) def new_search(item, channel=None): diff --git a/platformcode/logger.py b/platformcode/logger.py index e312617a..47d6740d 100644 --- a/platformcode/logger.py +++ b/platformcode/logger.py @@ -53,5 +53,11 @@ def log(*args, **kwargs): class WebErrorException(Exception): - def __init__(self, *args, **kwargs): + def __init__(self, url, channel, *args, **kwargs): + self.url = url + self.channel = channel Exception.__init__(self, *args, **kwargs) + + +class ChannelScraperException(Exception): + pass \ No newline at end of file diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index d70a04ff..b70a5de7 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -179,6 +179,50 @@ def dialog_register(heading, user=False, email=False, password=False, user_defau return dialog def dialog_info(item, scraper): + class TitleOrIDWindow(xbmcgui.WindowXMLDialog): + def Start(self, item, scraper): + self.item = item + self.item.exit = False + self.title = item.show if item.show else item.fulltitle + self.id = item.infoLabels.get('tmdb_id', '') if scraper == 'tmdb' else item.infoLabels.get('tvdb_id', '') + self.scraper = scraper + self.label = 'TMDB ID:' if scraper == 'tmdb' else 'TVDB ID:' + self.doModal() + return self.item + + def onInit(self): + #### Kodi 18 compatibility #### + if config.get_platform(True)['num_version'] < 18: + self.setCoordinateResolution(2) + self.getControl(10000).setText(config.get_localized_string(60228) % self.title) + self.getControl(10001).setText(self.title) + self.getControl(10002).setLabel(self.label) + self.getControl(10002).setText(self.id) + self.getControl(10002).setType(1, self.label) + self.setFocusId(10001) + + def onClick(self, control): + if control in [10003]: + if self.getControl(10001).getText(): + if self.scraper == 'tmdb': + self.item.contentTitle = self.getControl(10001).getText() + else: + self.item.contentSerieName = self.getControl(10001).getText() + if self.scraper == 'tmdb' and self.getControl(10002).getText(): + self.item.infoLabels['tmdb_id'] = self.getControl(10002).getText() + elif self.scraper == 'tvdb' and self.getControl(10002).getText(): + self.item.infoLabels['tvdb_id'] = self.getControl(10002).getText() + self.close() + + elif control in [10004, 10005]: + self.item.exit = True + self.close() + + def onAction(self, action): + if (action in [92] and self.getFocusId() not in [10001, 10002]) or action in [10]: + self.item.exit = True + self.close() + dialog = TitleOrIDWindow('TitleOrIDWindow.xml', config.get_runtime_path()).Start(item, scraper) return dialog @@ -587,11 +631,11 @@ def play_video(item, strm=False, force_direct=False, autoplay=False): # Open the selection dialog to see the available options opciones, video_urls, seleccion, salir = get_dialogo_opciones(item, default_action, strm, autoplay) - if salir: return + if salir: exit() # get default option of addon configuration seleccion = get_seleccion(default_action, opciones, seleccion, video_urls) - if seleccion < 0: return # Canceled box + if seleccion < 0: exit() # Canceled box logger.debug("selection=%d" % seleccion) logger.debug("selection=%s" % opciones[seleccion]) @@ -848,13 +892,14 @@ def get_dialogo_opciones(item, default_action, strm, autoplay): if not autoplay: if item.server != "": if "
" in motivo: - ret = dialog_yesno(config.get_localized_string(60362), motivo.split("
")[0] + '\n' + motivo.split("
")[1] + '\n' + item.url, nolabel='ok', yeslabel=config.get_localized_string(70739)) + ret = dialog_yesno(config.get_localized_string(60362) % item.server, motivo.split("
")[0] + '\n' + motivo.split("
")[1], nolabel='ok', yeslabel=config.get_localized_string(70739)) else: - ret = dialog_yesno(config.get_localized_string(60362), motivo + '\n' + item.url, nolabel='ok', yeslabel=config.get_localized_string(70739)) + ret = dialog_yesno(config.get_localized_string(60362) % item.server, motivo, nolabel='ok', yeslabel=config.get_localized_string(70739)) else: - ret = dialog_yesno(config.get_localized_string(60362), config.get_localized_string(60363) + '\n' + config.get_localized_string(60364) + '\n' + item.url, nolabel='ok', yeslabel=config.get_localized_string(70739)) + ret = dialog_yesno(config.get_localized_string(60362) % item.server, config.get_localized_string(60363) + '\n' + config.get_localized_string(60364), nolabel='ok', yeslabel=config.get_localized_string(70739)) if ret: - xbmc.executebuiltin("Container.Update (%s?%s)" % (sys.argv[0], Item(action="open_browser", url=item.url).tourl())) + xbmc.executebuiltin("Container.Update (%s?%s)" % + (sys.argv[0], Item(action="open_browser", url=item.url).tourl())) if item.channel == "favorites": # "Remove from favorites" opciones.append(config.get_localized_string(30154)) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index ee4ebcb3..351de1e5 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -589,7 +589,7 @@ msgid "%.2f %s of %.2f %s a %.2f %s/s (%d/%d)" msgstr "" msgctxt "#59985" -msgid "Error in the channel " +msgid "Channel %s unreachable" msgstr "" msgctxt "#59986" @@ -669,7 +669,7 @@ msgid "" msgstr "" msgctxt "#60006" -msgid "An error has occurred in %s" +msgid "[B]An error has occurred in %s:[/B]" msgstr "" msgctxt "#60007" @@ -697,15 +697,15 @@ msgid "No video to play" msgstr "" msgctxt "#60013" -msgid "This website seems to be unavailable, try later, if the problem persists, check with a browser: %s. If the web page is working correctly, please report the error on : https://t.me/kodiondemand" +msgid "This website [B]%s[/B] seems to be unavailable, try later. if the web page is working correctly, please report the error on: https://github.com/kodiondemand/addon/issues" msgstr "" msgctxt "#60014" -msgid "It may be due to a connection problem, the web page of the channel has changed its structure, or an internal error of KoD. To have more details, see the log file." +msgid "It may be due to a connection problem, the web page of the channel has changed its structure, or an internal error of KoD. If on browser it works, report the issue using [B]Help->Report an issue.[B]" msgstr "" msgctxt "#60015" -msgid "Check the log for more details on the error." +msgid "Do you want to report the issue?\n(Be sure you follow all steps and give a clear and comprehensive explanation of what happened" msgstr "" msgctxt "#60016" @@ -800,8 +800,8 @@ msgctxt "#60038" msgid "An error has occurred in KoD" msgstr "" -msgctxt "#60039" -msgid "Error on channel %s" +msgctxt "60039" +msgid "Channel %s unreachable" msgstr "" msgctxt "#60040" @@ -1633,7 +1633,7 @@ msgid "Super favourites menu" msgstr "" msgctxt "#60362" -msgid "You can't watch this video because..." +msgid "Unexpected error on server %s" msgstr "" msgctxt "#60363" diff --git a/resources/language/resource.language.it_it/strings.po b/resources/language/resource.language.it_it/strings.po index 7ed448ed..b8c72df9 100644 --- a/resources/language/resource.language.it_it/strings.po +++ b/resources/language/resource.language.it_it/strings.po @@ -588,8 +588,8 @@ msgid "%.2f %s of %.2f %s a %.2f %s/s (%d/%d)" msgstr "%.2f %s di %.2f %s a %.2f %s/s (%d/%d)" msgctxt "#59985" -msgid "Error in the channel " -msgstr "Errore nel canale " +msgid "Channel %s unreachable" +msgstr "Canale %s irraggiungibile" msgctxt "#59986" msgid "Error loading the server: %s\n" @@ -668,8 +668,8 @@ msgid "" msgstr "" msgctxt "#60006" -msgid "An error has occurred in %s" -msgstr "Si è verificato un errore in %s" +msgid "[B]An error has occurred in %s:[/B]" +msgstr "[B]Si è verificato un errore in %s:[/B]" msgctxt "#60007" msgid "An error has occurred on %s" @@ -696,16 +696,16 @@ msgid "No video to play" msgstr "Nessun video da riprodurre" msgctxt "#60013" -msgid "This website seems to be unavailable, try later, if the problem persists, check with a browser: %s. If the web page is working correctly, please report the error on : https://t.me/kodiondemand" -msgstr "Questo sito non sembra essere disponibile, riprova più tardi, se il problema persiste verifica mediante un browser: %s. Se la pagina web funziona correttamente segnala l'errore su : https://t.me/kodiondemand" +msgid "This website [B]%s[/B] seems to be unavailable, try later. if the web page is working correctly, please report the error on: https://github.com/kodiondemand/addon/issues" +msgstr "Il sito [B]%s[/B] non sembra essere disponibile, riprova più tardi. Se la pagina web funziona correttamente segnala l'errore qui: https://github.com/kodiondemand/addon/issues" msgctxt "#60014" -msgid "It may be due to a connection problem, the web page of the channel has changed its structure, or an internal error of KoD. To have more details, see the log file." -msgstr "Potrebbe essere dovuto a un problema di connessione, la pagina web del canale ha cambiato la sua struttura, oppure un errore interno di KoD. Per avere maggiori dettagli, consulta il file di log." +msgid "It may be due to a connection problem, the web page of the channel has changed its structure, or an internal error of KoD. If on browser it works, report the issue using [B]Help->Report an issue.[B]" +msgstr "Potrebbe essere dovuto a un problema di connessione, la pagina web del canale ha cambiato la sua struttura, oppure un errore interno di KoD. Se sul browser funziona, segnala il problema andando in [B]Aiuto->Segnala un problema[/B]." msgctxt "#60015" -msgid "Check the log for more details on the error." -msgstr "Controlla il log per avere maggiori dettagli sull'errore." +msgid "Do you want to report the issue?\n(Be sure you follow all steps and give a clear and comprehensive explanation of what happened" +msgstr "Vuoi fare una segnalazione agli sviluppatori?\n(Assicurati di seguire bene tutti i punti e dai una spiegazione chiara ed esaustiva di quanto accaduto)" msgctxt "#60016" msgid "Segna film come non visto" @@ -1632,8 +1632,8 @@ msgid "Super favourites menu" msgstr "Menu super favoriti" msgctxt "#60362" -msgid "You can't watch this video because..." -msgstr "Non è possibile vedere questo video perchè..." +msgid "Unexpected error on server %s" +msgstr "Errore inaspettato sul server %s" msgctxt "#60363" msgid "The server on which it is hosted" diff --git a/servers/wstream.json b/servers/wstream.json index 5f7cd897..f9668a6a 100644 --- a/servers/wstream.json +++ b/servers/wstream.json @@ -31,7 +31,7 @@ "visible": true }, { - "default": "100", + "default": 0, "enabled": true, "id": "favorites_servers_list", "label": "$ADDON[plugin.video.kod 60655]",