Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
Sending multiple TV show updates
#1
I am trying to update only update specific TV shows when a new episode has been added. 

I have a python script that generated a several curl commands with the specific folder that kodi need to scan for new episodes

Code:
 '{ "jsonrpc": "2.0", "method": "VideoLibrary.Scan","params":{"directory": "nfs://synology/volume1/media/TV/The Mandalorian"}, "id": "mybash"}'

When I update only one show this works perfectly.   The problem I'm having is when I try to update two or more shows, every other show gets scanned in.  I can manually run curl on the skipped shows, so I know I don't have a syntax problem.
Reply
#2
it might be advantageous to use a socket connection to kodi instead of a bunch of curls which would allow your python script to run interactively with kodi instead of just dumping a bunch of commands

general example can be had if you simply telnet to kodi on port 9090
send a data payload containing your json update command
observe kodi will respond with {"id":"mybash","jsonrpc":"2.0","result":"OK"}
then a follow up you should receive
{"jsonrpc":"2.0","method":"VideoLibrary.OnScanStarted","params":{"data":null,"sender":"xbmc"}}
and upon success it should be
{"jsonrpc":"2.0","method":"VideoLibrary.OnScanFinished","params":{"data":null,"sender":"xbmc"}}

then you can continue with payloads as you desire, closing the connection only when complete


other than interactively maybe just introducing delays to allow kodi to finish each operation in time

there's also consideration that curl will reuse connections which could cause issues

if the direct socket method is not an option post your script


-----
edit:
note you need to have "allow remote control from applications" enabled for this to work, "on this system" enables localhost (127.0.0.1), "on other systems" enables 0.0.0.0, does not use "control via HTTP"
Reply
#3
here i got bored waiting for you to come back so i wrote it for you

https://paste.kodi.tv/ijotimomol

fill the folders array with the folders you want to update

it could use some additional error handling, not my strong suit

the sleep after the last update is needed to avoid an error closing the socket too quickly


issues an update command for folders[fidx], waits for kodi to send a VideoLibrary.OnScanFinished, increments fidx and if fidx is still less than total items it will reissue at the current index
otherwise report completion, wait, exit
Reply
#4
WOW I'm impressed!!  Your script works perfectly.  Sorry for the delayed response I wasn't expecting such a quick response, I was out doing errands.
Reply
#5
no worries glad it works for you, i had the skeleton for a socket based json rpc laying around from something else i wrote so i just had to fill in the details

enjoy!
Reply
#6
... a bit late to a party: your link doesn't work. Do you still have this piece of code? Smile
Would be greatly appreciated
Reply
#7
(2024-10-18, 10:23)cherjr Wrote: ... a bit late to a party: your link doesn't work. Do you still have this piece of code? Smile
Would be greatly appreciated

possibly but not currently on my PC, probably in my drawer of USB drives
when i get a moment i will dig around and see if i can locate it

-----

in the meantime, it's basically just opening a socket connection to kodi and sending json rpc payloads and receiving the responses if you want to try that until then
Reply

Logout Mark Read Team Forum Stats Members Help
Sending multiple TV show updates0