From 44cd322f530aa7500ac06c2d52862d9f5e6bbb1b Mon Sep 17 00:00:00 2001 From: vasilky3 Date: Thu, 2 Nov 2023 20:29:00 +0300 Subject: [PATCH] fix connection validating --- resources/language/English/strings.po | 6 +++++- resources/language/messages.pot | 6 +++++- src/client.py | 1 + src/jackett.py | 18 +++++++----------- src/main.py | 12 +++++++++--- 5 files changed, 27 insertions(+), 16 deletions(-) diff --git a/resources/language/English/strings.po b/resources/language/English/strings.po index 2368b0e..d2a7892 100644 --- a/resources/language/English/strings.po +++ b/resources/language/English/strings.po @@ -54,6 +54,10 @@ msgctxt "#32008" msgid "Limit torrent count (Faster)" msgstr "" +msgctxt "#32009" +msgid "Connecting to Jackett failed. Check log for more info" +msgstr "" + msgctxt "#32050" msgid "Filtering" msgstr "" @@ -347,7 +351,7 @@ msgid "Sorting..." msgstr "" msgctxt "#32754" -msgid "{}... {}/{} indexers done" +msgid "{}... {}/{} requests done" msgstr "" msgctxt "#32754" diff --git a/resources/language/messages.pot b/resources/language/messages.pot index ab2d6f0..a84b088 100644 --- a/resources/language/messages.pot +++ b/resources/language/messages.pot @@ -55,6 +55,10 @@ msgctxt "#32008" msgid "Limit torrent count (Faster)" msgstr "" +msgctxt "#32009" +msgid "Connecting to Jackett failed. Check log for more info" +msgstr "" + msgctxt "#32050" msgid "Filtering" msgstr "" @@ -348,7 +352,7 @@ msgid "Sorting..." msgstr "" msgctxt "#32754" -msgid "{}... {}/{} indexers done" +msgid "{}... {}/{} requests done" msgstr "" msgctxt "#32754" diff --git a/src/client.py b/src/client.py index 71e1aa4..a354f32 100644 --- a/src/client.py +++ b/src/client.py @@ -107,6 +107,7 @@ async def send_request(self, url, params=None): if root.tag == "error": self.proceed_resp_error(root.attrib['code'], root.attrib['description']) return + set_setting('settings_validated', 'Success') return root async def request_indexers(self): diff --git a/src/jackett.py b/src/jackett.py index deb97ad..a8b5e0f 100644 --- a/src/jackett.py +++ b/src/jackett.py @@ -20,11 +20,6 @@ from utils import get_setting from pdialoghelper import PDialog -import sys -# fix asyncio.run() on win -if sys.platform == "win32" and (3, 8, 0) <= sys.version_info < (3, 9, 0): - asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) - available_providers = 0 special_chars = "()\"':.[]<>/\\?" @@ -50,17 +45,18 @@ async def get_client(): return cli -def validate_client(): - p_dialog = xbmcgui.DialogProgressBG() +async def validate_client(): + cli = await get_client() try: - p_dialog.create('Elementum [COLOR FFFF6B00]Jackett[/COLOR]', utils.translation(32005)) - get_client() if get_setting("settings_validated") == "Success": utils.notify(utils.translation(32006), image=utils.get_icon_path()) + else: + utils.notify(utils.translation(32009), image=utils.get_icon_path()) addon.ADDON.openSettings() finally: - p_dialog.close() - del p_dialog + await cli.close_session() + del cli + def search(payload, method="general"): diff --git a/src/main.py b/src/main.py index 588ccb2..7732615 100644 --- a/src/main.py +++ b/src/main.py @@ -2,6 +2,9 @@ from os import path import sys +# Workaround for kodi RuntimeError https://kodi.wiki/view/Python_Problems#asyncio +sys.modules['_asyncio'] = None +import asyncio from elementum.provider import register from kodi_six import xbmcgui @@ -9,8 +12,11 @@ sys.path.insert(0, path.realpath(path.join(path.dirname(__file__), '..', 'resources', 'libs'))) sys.path.insert(0, path.dirname(__file__)) -# Workaround for kodi RuntimeError https://kodi.wiki/view/Python_Problems#asyncio -sys.modules['_asyncio'] = None + +# fix asyncio.run() on win +if sys.platform == "win32" and (3, 8, 0) <= sys.version_info < (3, 9, 0): + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + if __name__ == '__main__': import debugger @@ -28,7 +34,7 @@ sys.exit(1) if sys.argv[1] == "validate_settings": - jackett.validate_client() + asyncio.run(jackett.validate_client()) else: debugger.load() register(