# -*- coding: utf-8 -*-
from setuptools import setup

modules = \
['kodi_cli']
install_requires = \
['requests>=2.28.0,<3.0.0']

entry_points = \
{'console_scripts': ['kodi-cli = kodi_cli:main']}

setup_kwargs = {
    'name': 'kodi-cli',
    'version': '0.1.7',
    'description': 'Control your Kodi instance(s) via the commandline',
    'long_description': '# kodi-cli\n\n## Command Line Interface for Kodi\n\nThis tool can be used from the command line to execute commands against a target Kodi host via the RPC interface defined at  https://kodi.wiki/view/JSON-RPC_API/v12.  \n\nThe available commands are defined via a json file ([**kodi_namespaces.json**](https://github.com/JavaWiz1/kodi-cli/blob/develop/kodi_namespaces.json)) which describes all the namespaces, methods and parameters available for managing the kodi device remotely. \n\n**Note** \n- Not all the commands are fully defined, further iterations of the code will include updates to this json file to make more commands available.\n- Namespace and Methods are case-sensitive.  Use help parameter or refer to the [Kodi RPC page](https://kodi.wiki/view/JSON-RPC_API/v12) for proper capitalization.\n- An *entrypoint* is created on install that allows the script to be run without specifying ***python kodi_cli.py***, simply type ***kodi-cli*** to execute the script.\n</br></br>\nThe documentation will reflect calls using the entrypoint as described above.\n\n\n\n</br>\n\n---\n## Overall Description\n\n*Commands* are based on Kodi **namespaces and methods**.  Each namespace (i.e. Application, System,...) has a set of pre-defned methods.  When executing a command you supply the **Namespace.Method parameter(s)** (case-sensitive).\n\nFor example, to display the mute and volume level settings on host kodi001, the command is constructed as follows:<br>\n\n  `kodi-cli -H kodi001 -f Application.GetProperties properties=\'[muted,volume]\'`\n- **-H kodi001** identifies the target host\n- **-f** indicates the output should be formatted\n- **Application.GetProperties** is the command\n    - *Application* is the namespace\n    - *GetProperties* is the method\n    - *properties=[muted,volume]* are the parameters\n\nThe output of the tool is the json response from the Kodi endpoint the command was targeted to.\n```\n{\n  "id": 1,\n  "jsonrpc": "2.0",\n  "result": {\n    "muted": false,\n    "volume": 100\n  }\n}\n```\n\n## Some terms:\n\n| Term | Description |\n| ------------- | ---------------------------- |\n| namespace | The data model is split into namespace components which can be called via the API |\n| methods | Each namespace has a number of methods which perform some function within that namespace |\n| command | A command is a namespace method combiniation used to control Kodi function (fmt: Namespace.Method) |\n</br>\n\n---\n\n## Usage\n\n```\nusage: \n  kodi-cli [-h] [-H HOST] [-P PORT] [-u USER] [-p PASSWORD] [-C] [-f] [-v] [-i] [command [command ...]]\n\npositional arguments:\n  command               RPC command namespace.method (help namespace to list)\n\noptional arguments:\n  -h, --help            show this help message and exit\n  -H HOST, --host HOST  Kodi hostname\n  -P PORT, --port PORT  Kodi RPC listen port\n  -u USER, --user USER  Kodi authenticaetion username\n  -p PASSWORD, --password PASSWORD\n                        Kodi autentication password\n  -C, --create_config   Create empty config\n  -f, --format_output   Format json output\n  -v, --verbose         Verbose output, -v = INFO, -vv = DEBUG\n  -i, --info            display program info and quit\n  ```\n<br>\n\n**TIPS - When calling the script:**\n| action | description |\n| ------ | ----------- |\n| add -h option | to display script syntax and list of option parameters |\n| enter help | as a parameter for help on namespace or namespace.method |\n| add -i | to output runtime and program information |\n| add -f | to format the json output into a friendly format |\n| add -c | to create a config file with runtime defaults (see "Create config file to store defaults" below)|\n</br>\n\n**Help commands:**\nYou can get help from the command line to view namespaces, namespace methods and calling requirements. \n\nHelp Examples\n| action | example |\n| ------ | ------- |\n| list of namespaces |    `kodi-cli help` |\n| Methods for Namespace | `kodi-cli Application help` |\n| Parameters for Method | `kodi-cli Application.GetProperties help` <br>Note, to get the detailed calling signature add -v |\n\nDetails for namespaces, methods and parameters may be found at https://kodi.wiki/view/JSON-RPC_API/v12\n \n</br>\n\n---\n## Prerequsites:\n\n**Python 3.7+**<br>\n**Python packages**\n- requests package\n<br>\nCode can be installed via pip or pipx:\n- pip install kodi-cli [--user]\n- pipx install kodi-cli\n\n**Kodi configuration**\n- Remote control via HTTP must be enabled.\n- Enable in Kodi UI - Settings -> Services -> Control\n</br></br>\n\n---\n## Usage Examples\n---\n### Create a config file to store defaults\nTo minimize command-line entry, you can store defaults in a config file which will default values on startup.  The\nvalues can be over-ridded at run-time by providing the optional command-line argument.\n\nTo create a default config file, type your standard defaults as if you were going to execute the CLI and add -C at the end.\nThe config file will be written with the values.\n```\nSYNTAX:\n  kodi-cli -u myId -p myPassword -P 8080 -C\n\nOUTPUT:\n  a file (kodi_cli.cfg will be written as:\n    {\n      "host": "localhost",\n      "port": 8080,\n      "user": "myId",\n      "password": "myPassword",\n      "format_output": false\n    }\n```\n</br></br>\n\n---\n### List all **namespaces**\n\nNamespaces are modules in Kodi, each namespace manages differ aspects of the Kodi interface\n\n```\nSYNTAX:\n  kodi-cli help\n\nOUTPUT:\n\n  Kodi namespaces -\n    Namespace       Methods\n    --------------- ----------------------------------------------------------------------------\n    AddOns          ExecuteAddon, GetAddonDetails, GetAddons, SetAddonEnabled\n\n    Application     GetProperties, Quit, SetMute, SetVolume\n\n    AudioLibrary    Clean, GetAlbumDetails, GetAlbums, GetArtistDetails,\n                    GetArtists, Scan\n\n    Favorites       AddFavorite, GetFavorites\n\n    GUI             ActivateWindow, ShowNotification\n\n    Input           Back, ButtonEvent, ContextMenu, Down, ExecuteAction,\n                    Home, Info, Left, Right, Select, SendText,\n                    ShowCodec, ShowOSD, ShowPlayProcessInfo, Up\n    ...\n```\n</br></br>\n\n---\n### List all namespace ***methods***\n\nEach namespace has a number of methods that can be called.  \n\nTo get a list of supported of supported methods for the ***Application*** namespace\n\n```\nSYNTAX:\n  kodi-cli Application help\n  or\n  kodi-cli Application\n\nOUTPUT:\n\n  Application Namespace Methods:\n\n  Method                    Description\n  ------------------------- --------------------------------------------\n  Application.GetProperties Retrieves the values of the given properties\n  Application.Quit          Quit application\n  Application.SetMute       Toggle mute/unmute\n  Application.SetVolume     Set the current volume\n```\n</br></br>\n\n---\n### List the ***method calling signature*** for a namespace method\n\nList the sytax for the Application.SetMute command\n\n```\nSYNTAX:\n  kodi-cli Application.SetMute help\n\nOUTPUT:\n\n  Syntax: Application.SetMute\n  ------------------------------------------------------\n  {\n    "description": "Toggle mute/unmute",\n    "params": [\n      {\n        "$ref": "Global.Toggle",\n        "name": "mute",\n        "required": true\n      }\n    ],\n    "permission": "ControlPlayback",\n    "returns": {\n      "description": "Mute state",\n      "type": "boolean"\n    },\n    "type": "method"\n  }\n\n```\n</br></br>\n\n---\n## Command Execution Examples\n\n### Toggle Mute on/off\n\nTo toggle the mute on, then off\n\nFirst call will toggle mute on, 2nd call will toggle mute off.\n\n```\nSYNTAX:\n  kodi-cli -H ServerName Application.SetMute mute=\'toggle\'\n\nOUTPUT:\n  kodi-cli -H MyKodiServer Application.SetMute mute=\'toggle\'\n  {"id":1,"jsonrpc":"2.0","result":true}\n\n  kodi-cli -H MyKodiServer Application.SetMute mute=\'toggle\'\n  {"id":1,"jsonrpc":"2.0","result":false}\n```\n</br></br>\n\n---\n### Retrieve Application Properties\n\nTo retrieve the muted status and volume level for server kodi001\n```\nSYNTAX:\n  kodi-cli -H kodi001 Application.GetProperties properties=\'[muted,volume]\' -f\n\nOUTPUT:\n{\n  "id": 1,\n  "jsonrpc": "2.0",\n  "result": {\n    "muted": false,\n    "volume": 100\n  }\n}\n\n```\n</br></br>\n\n---\n### List AddOns\n\nTo retrieve the list of all AddOns\n```\nSYNTAX:\n  kodi-cli -H kodi001 AddOn.GetAddons properties=\'[name,version,summary]\' limits=\'{start=0,end=99}\' -f\n\nOUTPUT:\n{\n  "id": 1,\n  "jsonrpc": "2.0",\n  "result": {\n    "addons": [\n      {\n        "addonid": "audioencoder.kodi.builtin.aac",\n        "name": "AAC encoder",\n        "summary": "AAC Audio Encoder",\n        "type": "kodi.audioencoder",\n        "version": "1.0.2"\n      },\n\n      ...\n      \n      {\n        "addonid": "webinterface.default",\n        "name": "Kodi web interface - Chorus2",\n        "summary": "Default web interface",\n        "type": "xbmc.webinterface",\n        "version": "19.x-2.4.8"\n      }\n    ],\n    "limits": {\n      "end": 43,\n      "start": 0,\n      "total": 43\n    }\n  }\n}      \n\n```\n</br></br>\n\n---\n### Display a notification on Kodi UI\nTo display a warning message on Kodi running on kodi001 for 5 seconds\n```\nSYNTAX:\n   kodi-cli -H kodi001 GUI.ShowNotification title="Dinner Time" message="Time to eat!" image="warning" displaytime=5000\n\nOUTPUT:\n{"id":1,"jsonrpc":"2.0","result":"OK"}\n\n```\n</br></br>\n\n---\nStill TODO:\n- Build out kodi_namespaces.json with additional definitions.\n- Edit parameters prior to call to avoid runtime error.\n- Provide additional help/runtime detail on parameters (i.e. enum values)',
    'author': 'Al DAmico',
    'author_email': 'JavaWiz1@hotmail.com',
    'maintainer': None,
    'maintainer_email': None,
    'url': 'https://github.com/JavaWiz1/kodi-cli',
    'py_modules': modules,
    'install_requires': install_requires,
    'entry_points': entry_points,
    'python_requires': '>=3.7,<4.0',
}


setup(**setup_kwargs)
