From 38dbbc9785e9407e0dc6ccb918eca9475c6bc681 Mon Sep 17 00:00:00 2001
From: MoojMidge <56883549+MoojMidge@users.noreply.github.com>
Date: Mon, 22 Jan 2024 02:27:51 +1100
Subject: [PATCH] Use simple script entry point
---
addon.xml | 2 +-
resources/lib/script.py | 17 +++++++
resources/lib/youtube_plugin/__init__.py | 2 +-
.../{script.py => script_actions.py} | 49 ++++++++++++-------
4 files changed, 50 insertions(+), 20 deletions(-)
create mode 100644 resources/lib/script.py
rename resources/lib/youtube_plugin/{script.py => script_actions.py} (92%)
diff --git a/addon.xml b/addon.xml
index 29f59368b..401b3ffd8 100644
--- a/addon.xml
+++ b/addon.xml
@@ -12,7 +12,7 @@
-
+
executable
diff --git a/resources/lib/script.py b/resources/lib/script.py
new file mode 100644
index 000000000..98b3dd30b
--- /dev/null
+++ b/resources/lib/script.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+"""
+
+ Copyright (C) 2024-present plugin.video.youtube
+
+ SPDX-License-Identifier: GPL-2.0-only
+ See LICENSES/GPL-2.0-only for more information.
+"""
+
+from __future__ import absolute_import, division, unicode_literals
+
+import sys
+
+from youtube_plugin import script_actions
+
+
+script_actions.run(sys.argv)
diff --git a/resources/lib/youtube_plugin/__init__.py b/resources/lib/youtube_plugin/__init__.py
index 44b1ba27b..8aa54b157 100644
--- a/resources/lib/youtube_plugin/__init__.py
+++ b/resources/lib/youtube_plugin/__init__.py
@@ -26,4 +26,4 @@
}
}
-__all__ = ['kodion', 'youtube', 'key_sets', 'script']
+__all__ = ['kodion', 'youtube', 'key_sets', 'script_actions.py']
diff --git a/resources/lib/youtube_plugin/script.py b/resources/lib/youtube_plugin/script_actions.py
similarity index 92%
rename from resources/lib/youtube_plugin/script.py
rename to resources/lib/youtube_plugin/script_actions.py
index 3ff79f8df..9dbfa8b4b 100644
--- a/resources/lib/youtube_plugin/script.py
+++ b/resources/lib/youtube_plugin/script_actions.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""
- Copyright (C) 2018-2018 plugin.video.youtube
+ Copyright (C) 2024-present plugin.video.youtube
SPDX-License-Identifier: GPL-2.0-only
See LICENSES/GPL-2.0-only for more information.
@@ -11,13 +11,12 @@
import os
import socket
-import sys
-from kodion.compatibility import parse_qsl, xbmc, xbmcaddon, xbmcvfs
-from kodion.constants import DATA_PATH, TEMP_PATH
-from kodion.context import Context
-from kodion.network import get_client_ip_address, is_httpd_live
-from kodion.utils import rm_dir
+from .kodion.compatibility import parse_qsl, xbmc, xbmcaddon, xbmcvfs
+from .kodion.constants import DATA_PATH, TEMP_PATH
+from .kodion.context import Context
+from .kodion.network import get_client_ip_address, is_httpd_live
+from .kodion.utils import rm_dir
def _config_actions(action, *_args):
@@ -271,22 +270,36 @@ def switch_to_user(user):
return True
-if __name__ == '__main__':
- args = sys.argv[1:]
+def run(argv):
+ args = argv[1:]
if args:
args = args[0].split('/')
- num_args = len(args)
- category = args[0] if num_args else None
- action = args[1] if num_args > 1 else None
- params = args[2] if num_args > 2 else None
- if not category:
+ num_args = len(args)
+ if num_args > 2:
+ category, action, params = args[:3]
+ elif num_args == 2:
+ category, action = args
+ params = None
+ elif num_args:
+ category = args[0]
+ action = params = None
+ else:
xbmcaddon.Addon().openSettings()
- elif action == 'refresh':
+ return
+
+ if action == 'refresh':
xbmc.executebuiltin('Container.Refresh')
- elif category == 'config':
+ return
+
+ if category == 'config':
_config_actions(action, params)
- elif category == 'maintenance':
+ return
+
+ if category == 'maintenance':
_maintenance_actions(action, params)
- elif category == 'users':
+ return
+
+ if category == 'users':
_user_actions(action, params)
+ return