Skip to content

Commit

Permalink
fix connection validating
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilky3 committed Nov 2, 2023
1 parent be93ae4 commit 44cd322
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 16 deletions.
6 changes: 5 additions & 1 deletion resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -347,7 +351,7 @@ msgid "Sorting..."
msgstr ""

msgctxt "#32754"
msgid "{}... {}/{} indexers done"
msgid "{}... {}/{} requests done"
msgstr ""

msgctxt "#32754"
Expand Down
6 changes: 5 additions & 1 deletion resources/language/messages.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -348,7 +352,7 @@ msgid "Sorting..."
msgstr ""

msgctxt "#32754"
msgid "{}... {}/{} indexers done"
msgid "{}... {}/{} requests done"
msgstr ""

msgctxt "#32754"
Expand Down
1 change: 1 addition & 0 deletions src/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
18 changes: 7 additions & 11 deletions src/jackett.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "()\"':.[]<>/\\?"

Expand All @@ -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"):
Expand Down
12 changes: 9 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,21 @@
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

from logger import log

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
Expand All @@ -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(
Expand Down

0 comments on commit 44cd322

Please sign in to comment.