Beispiel #1
0
def run(argv):
    path = argv[0]
    handle = int(argv[1])

    options = None
    if len(argv) > 2:
        # get the options but remove the leading ?
        params = argv[2][1:]
        if params:
            options = parse_qs(params)

    log('path = {}, handle = {}, options = {}'.format(path, handle, params), xbmc.LOGDEBUG)

    url = urlparse(path)
    action = url.path
    if action[0] == '/':
        action = action[1:]

    if not action in ACTIONS:
        log('cannot process unknown action: {}'.format(action), xbmc.LOGERROR)
        sys.exit(0)

    actionMethod = ACTIONS[action]
    if not actionMethod:
        log('action not implemented: {}'.format(action), xbmc.LOGWARNING)
        sys.exit(0)

    # initialize some global variables
    plex.Initialize()

    log('executing action "{}"...'.format(action), xbmc.LOGDEBUG)
    actionMethod(handle, options)
def run(argv: list):
    """Function runner: Reads call type from input args and calls associated function

    :param argv: Input arguments, <path> <handle> <options>
    :type argv: list
    """
    path = argv[0]
    handle = int(argv[1])

    options = {}
    if len(argv) > 2:
        # get the options but remove the leading ?
        params = argv[2][1:]
        if params:
            options = parse_qs(params)

    log(f"path = {path}, handle = {handle}, options = {options}",
        xbmc.LOGDEBUG)

    url = urlparse(path)
    action = url.path
    if action[0] == '/':
        action = action[1:]

    if action not in ACTIONS:
        log(f"cannot process unknown action: {action}", xbmc.LOGERROR)
        sys.exit(0)

    actionMethod = ACTIONS[action]
    if not actionMethod:
        log(f"action not implemented: {action}", xbmc.LOGWARNING)
        sys.exit(0)

    # initialize some global variables
    plex.Initialize()

    log(f"executing action '{action}'...", xbmc.LOGDEBUG)
    actionMethod(handle, options)
Beispiel #3
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
#  Copyright (C) 2019 Sascha Montellese <*****@*****.**>
#
#  SPDX-License-Identifier: GPL-2.0-or-later
#  See LICENSES/README.md for more information.
#

import sys
import plex
from lib import importer
from lib.utils import log


if __name__ == '__main__':
    # initialize some global variables
    plex.Initialize()

    log('Plex Media Import importer started')
    importer.run(sys.argv)