v19 playing the video via json-rpc but still gives an error (import requests) in the log
#1
I tried two ways, but the log always gives errorcode should be different instead of import requests?


example 1.

Code:
import requests

file = open("c:\\kodi\\save.txt")
lines2 = file.readlines()
url = lines2[0].split('\n')[0]

headers = {
    'Content-Type': 'application/json',
}

data = {"jsonrpc":"2.0","method":"Player.Open","params":{"item":{"file": url}}}
requests.post('http://kodi:[email protected]:8080/jsonrpc?Base', headers = headers, json = data)


example 2.


Code:
import requests

file = open("c:\\kodi\\save.txt")
lines = file.readlines()
link = lines[0].split('\n')[0]

url = "http://kodi:[email protected]:8080/jsonrpc?Base"
data = {"jsonrpc":"2.0","method":"Player.Open","params":{"item":{"file":link}}}
resp = requests.post(url, json = data)

-----------------
save.txt
smb://192.168.1.10/@.mkv
-----------------

this is always in the error log but it plays the movie anyway

log

I usually invoke the py file via the main menu and button

<end>RunScript("c:\kodi\load.py")</end>

homescreen command
RunScript("c:\kodi\load.py")



Thanks in advance for any help!
Reply
#2
https://kodi.wiki/view/JSON-RPC_API
When first getting started, I found interactively testing json rpc commands helpful before embedding them into a Python script. In my case, I used notepad and a browser on my windows pc to send json rpc commands to kodi running on a different computer.

I also recommend studying examples. https://kodi.wiki/view/JSON-RPC_API/Examples
Reply
#3
(2021-07-03, 13:07)jmooremcc Wrote: https://kodi.wiki/view/JSON-RPC_API
When first getting started, I found interactively testing json rpc commands helpful before embedding them into a Python script. In my case, I used notepad and a browser on my windows pc to send json rpc commands to kodi running on a different computer.

I also recommend studying examples. https://kodi.wiki/view/JSON-RPC_API/Examples

thanks for the reply, but there is no information about Player.Open on these pages

by the way, if something is wrong with the script, it won't start the movie

the main problem, starts the movie but because it writes an error to the log it stops the script running 
and if I add anything else to the script it will no longer be allowed
Reply
#4
(2021-07-03, 13:22)hunadamka Wrote:
(2021-07-03, 13:07)jmooremcc Wrote: https://kodi.wiki/view/JSON-RPC_API
When first getting started, I found interactively testing json rpc commands helpful before embedding them into a Python script. In my case, I used notepad and a browser on my windows pc to send json rpc commands to kodi running on a different computer.

I also recommend studying examples. https://kodi.wiki/view/JSON-RPC_API/Examples

thanks for the reply, but there is no information about Player.Open on these pages

by the way, if something is wrong with the script, it won't start the movie

the main problem, starts the movie but because it writes an error to the log it stops the script running 
and if I add anything else to the script it will no longer be allowed
 you got no "id": 1 in your request,   also the request url is wrong.
Reply
#5
(2021-07-03, 20:58)Sidewinder_2011 Wrote:
(2021-07-03, 13:22)hunadamka Wrote:
(2021-07-03, 13:07)jmooremcc Wrote: https://kodi.wiki/view/JSON-RPC_API
When first getting started, I found interactively testing json rpc commands helpful before embedding them into a Python script. In my case, I used notepad and a browser on my windows pc to send json rpc commands to kodi running on a different computer.

I also recommend studying examples. https://kodi.wiki/view/JSON-RPC_API/Examples

thanks for the reply, but there is no information about Player.Open on these pages

by the way, if something is wrong with the script, it won't start the movie

the main problem, starts the movie but because it writes an error to the log it stops the script running 
and if I add anything else to the script it will no longer be allowed
 you got no "id": 1 in your request,   also the request url is wrong.
ohhh, you're right I forgot about thatSad
thank you very much! it's perfect now and it was able to run the rest of the scriptSmile
by the way what error did you see in my request url?
Reply
#6
(2021-07-03, 21:42)hunadamka Wrote:
(2021-07-03, 20:58)Sidewinder_2011 Wrote:
(2021-07-03, 13:22)hunadamka Wrote: thanks for the reply, but there is no information about Player.Open on these pages

by the way, if something is wrong with the script, it won't start the movie

the main problem, starts the movie but because it writes an error to the log it stops the script running 
and if I add anything else to the script it will no longer be allowed
 you got no "id": 1 in your request,   also the request url is wrong.
ohhh, you're right I forgot about thatSad
thank you very much! it's perfect now and it was able to run the rest of the scriptSmile
by the way what error did you see in my request url?

I just notice that there was no id and in the url, you added base to it , when it should be , eg http://kodi:[email protected]:8080/jsonrpc?

Glad u sorted it
Reply

Logout Mark Read Team Forum Stats Members Help
playing the video via json-rpc but still gives an error (import requests) in the log0