Is There A Way to Exort nfo's Through a script?
#1
I have a need to have nfos generated for all my media. Previously, this was done for me by a software I was using, but it doesn't seem to want to fill in all the appropriate fields anymore. I was hoping there was some way to write a script, that I could attach to launchctl, that would export my nfos. Basically I'd want what the gui does with the export command with separate files and an overwrite. But, only the nfos and not the artwork. Does anyone have any idea about how this might be accomplished?

Thanks!
Reply
#2
@desepticon

You can do that with autoexec.py

Create the file and include the following code...

xml:
import xbmc
xbmc.executebuiltin('exportlibrary(video,true,false,true,false)')

The above code will export the video library to separate files, No artwork, overwrite existing files, No Actor images

arguments...
xml:
exportlibrary(video,true,thumbs,overwrite,actorthumbs) | The video library is exported to multiple files with the given options. Here thumbs, overwrite and actorthumbs are boolean values (true or false)
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#3
Thankie sie!
Reply
#4
Question: Where would I put this file? It doesn't seem to have any information in the script to know how to connect to Kodi.

I just get:

python:
Traceback (most recent call last):
  File "autoexec.py", line 1, in <module>
    import xbmc

if I try to run it.

I've been looking at texturecache.py to see how he does it, but I can't make heads or tails of it. Is there a way to send the command with wget or curl?
Reply
#5
Would 

wget ip:port/jsonrpc?request=exportlibrary(video,true,false,true,false)

be the correct syntax? I don't want to accidentally overwrite my artwork.
Reply
#6
Ok, thought you knew about autoexec.py.

See here... https://kodi.wiki/view/Autoexec.py

Place it in the same location as the advancedsettings.xml file. The file only works when starting Kodi. Same as the autoexec.bat
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#7
Hmm. It seems that only runs when Kodi is started. I keep Kodi on 24/7 365 days a year. Hence the need for a launchctl script.

Do you know how to make the json-rpc request with wget or curl?
Reply
#8
Ok. Sorry I do not know what a launchctl script is (and assumed it was a spelling mistake for "launch it")
My Signature
Links to : Official:Forum rules (wiki) | Official:Forum rules/Banned add-ons (wiki) | Debug Log (wiki)
Links to : HOW-TO:Create Music Library (wiki) | HOW-TO:Create_Video_Library (wiki)  ||  Artwork (wiki) | Basic controls (wiki) | Import-export library (wiki) | Movie sets (wiki) | Movie universe (wiki) | NFO files (wiki) | Quick start guide (wiki)
Reply
#9
launchctl is like cron for Mac. Don't worry about that part. It can, amongst other things, launch bash scripts. Based on the information I have pieced together so far, one can use wget or curl to invoke json-rpc commands. Thats the part I'm having trouble figuring out at this point.
Reply
#10
I think it needs to be something like

python:
curl --include --header 'content-type: application/json;' --request POST --data '{ "jsonrpc": "2.0", "method": "VideoLibrary.Export", "params": { "options": { "overwrite":true, "actorthumbs":false, "thumbs":false "images":false } }, "id": 1 }' http://10.0.1.16:8083/jsonrpc

but I just get this error when I try to run it

python:
{"error":{"code":-32602,"data":{"method":"VideoLibrary.Export","stack":{"message":"Received value does not match any of the union type definitions","name":"options","type":"object"}},"message":"Invalid params."},"id":1,"jsonrpc":"2.0"}

Edit: okay, it seems I got one step further. I fixed some spaces in the command like this:

python:
curl --include --header 'content-type: application/json;' --request POST --data '{ "jsonrpc": "2.0", "method": "VideoLibrary.Export", "params": { "options": { "overwrite": true, "actorthumbs": false, "thumbs": false "images": false } }, "id": 1 }' http://10.0.1.16:8083/jsonrpc

But, now I get this:

python:
{"error":{"code":-32700,"message":"Parse error."},"id":null,"jsonrpc":"2.0"}
Reply
#11
Okay I think I figured it out. Though I'm not sure as it still changes the modification dates of the files even when I set overwrite to "false". I cancelled the command immediately, as I don't want it overwriting my artwork. Though, I did compare some of them and they appeared to be the same.

json:
curl -X POST -H 'content-type: application/json;' --data '{ "jsonrpc": "2.0", "method": "VideoLibrary.Export", "params": { "options": { "overwrite": false, "actorthumbs": false, "images": false} }, "id": 1 }' http://10.0.1.16:8083/jsonrpc
Reply

Logout Mark Read Team Forum Stats Members Help
Is There A Way to Exort nfo's Through a script?0