Skip to content

Commit

Permalink
Use simple script entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
MoojMidge committed Jan 23, 2024
1 parent 1ce49f0 commit 38dbbc9
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 20 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</extension>
<extension point="xbmc.service" library="resources/lib/service.py"/>
<extension point="xbmc.python.module" library="resources/lib/"/>
<extension point="xbmc.python.script" library="resources/lib/youtube_plugin/script.py">
<extension point="xbmc.python.script" library="resources/lib/script.py">
<provides>executable</provides>
</extension>
<extension point="xbmc.addon.metadata">
Expand Down
17 changes: 17 additions & 0 deletions resources/lib/script.py
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 1 addition & 1 deletion resources/lib/youtube_plugin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
}
}

__all__ = ['kodion', 'youtube', 'key_sets', 'script']
__all__ = ['kodion', 'youtube', 'key_sets', 'script_actions.py']
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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):
Expand Down Expand Up @@ -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

0 comments on commit 38dbbc9

Please sign in to comment.