Skip to content

Commit

Permalink
🧹 Cleanup modules in common
Browse files Browse the repository at this point in the history
  • Loading branch information
jurialmunkey committed Jul 26, 2023
1 parent bb04419 commit dde620f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 25 deletions.
10 changes: 0 additions & 10 deletions resources/lib/jsonrpc.py

This file was deleted.

19 changes: 15 additions & 4 deletions resources/lib/method.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,38 @@
# Module: default
# Author: jurialmunkey
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
import xbmc
import time
from resources.lib.jsonrpc import get_jsonrpc
from jurialmunkey.parser import try_int


def set_player_subtitle(set_player_subtitle, reload_property='UID', **kwargs):
import time
import xbmc
from jurialmunkey.jsnrpc import get_jsonrpc
from jurialmunkey.parser import try_int
method = "Player.SetSubtitle"
params = {"playerid": 1, "subtitle": try_int(set_player_subtitle), "enable": True}
get_jsonrpc(method, params)
xbmc.executebuiltin(f'SetProperty({reload_property},{time.time()})')


def set_player_audiostream(set_player_audiostream, reload_property='UID', **kwargs):
import time
import xbmc
from jurialmunkey.jsnrpc import get_jsonrpc
from jurialmunkey.parser import try_int
method = "Player.SetAudioStream"
params = {"playerid": 1, "stream": try_int(set_player_audiostream)}
get_jsonrpc(method, params)
xbmc.executebuiltin(f'SetProperty({reload_property},{time.time()})')


def set_editcontrol(set_editcontrol, text, window_id=None, setfocus=None, setfocus_wait='00:00', **kwargs):
import xbmc
from jurialmunkey.jsnrpc import get_jsonrpc
xbmc.executebuiltin(f'SetFocus({set_editcontrol})')
get_jsonrpc("Input.SendText", {"text": text, "done": True})
xbmc.executebuiltin(f'AlarmClock(Refocus,SetFocus({setfocus}),{setfocus_wait},silent)') if setfocus else None


def set_dbid_tag(set_dbid_tag, dbtype, dbid, **kwargs):
from jurialmunkey.jsnrpc import set_tags
set_tags(int(dbid), dbtype, [set_dbid_tag])
2 changes: 1 addition & 1 deletion resources/lib/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import xbmcplugin
from xbmcgui import ListItem
from jurialmunkey.parser import parse_paramstring
from resources.lib.jsonrpc import get_jsonrpc
from jurialmunkey.jsnrpc import get_jsonrpc
from resources.lib.method import set_player_subtitle, set_player_audiostream


Expand Down
12 changes: 3 additions & 9 deletions resources/lib/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
# Author: jurialmunkey
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
import sys
from importlib import import_module


def importmodule(module_name, import_attr=None):
module = import_module(module_name)
if not import_attr:
return module
return getattr(module, import_attr)
from jurialmunkey.modimp import importmodule


class Script(object):
Expand All @@ -27,14 +20,15 @@ def map_args(arg):
k, v = map_args(arg)
self.params[k] = v

# lambda **kwargs: importmodule('resources.lib.script.method', 'split_value')(**kwargs),
routing_table = {
'set_player_subtitle':
lambda **kwargs: importmodule('resources.lib.method', 'set_player_subtitle')(**kwargs),
'set_player_audiostream':
lambda **kwargs: importmodule('resources.lib.method', 'set_player_audiostream')(**kwargs),
'set_editcontrol':
lambda **kwargs: importmodule('resources.lib.method', 'set_editcontrol')(**kwargs),
'set_dbid_tag':
lambda **kwargs: importmodule('resources.lib.method', 'set_dbid_tag')(**kwargs),
}

def run(self):
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/viewtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from json import loads, dumps
from jurialmunkey.parser import try_int, merge_dicts
from jurialmunkey.futils import check_hash, make_hash, write_skinfile, write_file, load_filecontent
from resources.lib.jsonrpc import get_jsonrpc
from jurialmunkey.jsnrpc import get_jsonrpc
from resources.lib.kodiutils import isactive_winprop
from resources.lib.xmlhelper import make_xml_includes, get_skinfolders

Expand Down

0 comments on commit dde620f

Please sign in to comment.