Created
May 26, 2019 17:27
-
-
Save henryjfry/aee0520f4709f5016e69d4a19f09ad25 to your computer and use it in GitHub Desktop.
How to refresh widgets in KODI through python with JSON-RPC, with http authorization by marking an episode watched/unwatched.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
import json | |
import base64 | |
kodi_credentials = b'user:pass' | |
kodi_encoded_credentials = base64.b64encode(kodi_credentials) | |
kodi_authorization = b'Basic ' + kodi_encoded_credentials | |
kodi_header = { 'Content-Type': 'application/json', 'Authorization': kodi_authorization } | |
kodi_ip = '127.0.0.1' | |
kodi_port = '8080' | |
kodi_url = 'http://' + kodi_ip + ':' + kodi_port + '/jsonrpc' | |
kodi_params = ('{"jsonrpc":"2.0","method":"VideoLibrary.SetEpisodeDetails","params":{"episodeid":1,"playcount": 1},"id":"1"}') | |
kodi_response = requests.post(kodi_url, headers=kodi_header, data=kodi_params) | |
json_data = json.dumps(kodi_response.json(), indent=4, sort_keys=True) | |
print(json_data) | |
kodi_params = ('{"jsonrpc":"2.0","method":"VideoLibrary.SetEpisodeDetails","params":{"episodeid":1,"playcount": 0},"id":"1"}') | |
kodi_response = requests.post(kodi_url, headers=kodi_header, data=kodi_params) | |
json_data = json.dumps(kodi_response.json(), indent=4, sort_keys=True) | |
print(json_data) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment