Repository: Flexget/Flexget

Issue:
Kodi API has been changed in v18 (Leia) such that HTTP POST is required
<!---
Before opening an issue, verify:

- Is this a feature request? Post it on https://feathub.com/Flexget/Flexget
- Did you recently upgrade? Look at the Change Log and Upgrade Actions to make sure that you don't need to make any changes to your config https://flexget.com/ChangeLog https://flexget.com/UpgradeActions
- Are you running FlexGet as a daemon? Stop it completely and then start it again https://flexget.com/CLI/daemon
- Did you search to see if the issue already exists? https://github.com/Flexget/Flexget/issues
- Did you fill out the issue template as completely as possible?

The issue template is here because it helps to ensure you submitted all the necessary information the first time, and allows us to more quickly review issues. Please fill it out correctly and do not ignore it, no matter how irrelevant you think it may be. Thanks in advance for your help with this!
--->
### Expected behaviour:
<!---
Please don't just say "it doesn't crash" or "it works". Explain what the expected result is.
--->
Updates should work
### Actual behaviour:
Error message: `JSONRPC failed. Error -32099: Bad client permission`
### Steps to reproduce:
- Step 1: Call a kodi library scan from a task

#### Config:
```
kodi_library:
  action: scan
  category: video
  url: http://192.168.1.214
  port: 80
```

### Details
The kodi API has been changed in v18 Leia and up. In the old API, all requests were HTTP GET (even API calls that update/mutate state). They've finally updated the API to require HTTP POST for updates, but they've completely failed to update the API version or even provide sensible error messages.

https://forum.kodi.tv/showthread.php?tid=324598
https://discuss.flexget.com/t/kodi-plugin-not-working-on-kodi-18/4196

**NOTE**: I no longer use Kodi, so I'm simply creating an issue based on a forum post to keep track of the issue in case other users begin to experience it.


Discussion:

Resolving patch:
diff --git a/flexget/plugins/services/kodi_library.py b/flexget/plugins/services/kodi_library.py
--- a/flexget/plugins/services/kodi_library.py
+++ b/flexget/plugins/services/kodi_library.py
@@ -38,14 +38,13 @@ def on_task_exit(self, task, config):
 
             url = base_url + JSON_URI
             # create the params
-            json_params = {"id": 1, "jsonrpc": "2.0",
-                           'method': '{category}Library.{action}'.format(category=config['category'].title(),
-                                                                         action=config['action'].title())}
-            params = {'request': json.dumps(json_params)}
+            params = {"id": 1, "jsonrpc": "2.0",
+                      'method': '{category}Library.{action}'.format(category=config['category'].title(),
+                                                                    action=config['action'].title())}
             log.debug('Sending request params %s', params)
 
             try:
-                r = task.requests.get(url, params=params, auth=(config.get('username'), config.get('password'))).json()
+                r = task.requests.post(url, json=params, auth=(config.get('username'), config.get('password'))).json()
                 if r.get('result') == 'OK':
                     log.info('Successfully sent a %s request for the %s library', config['action'], config['category'])
                 else:


Test patch: