Kodi Community Forum

Full Version: Jellyfin for kodi: Trigger scan on start?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi! (Not sure where to post this..)

Having Jellyfin server installed on my Windows 11.
Kodi omega on my Nvidia Shield.
Using drives on both my NAS (NFS) and on Windows.

I'm having problems getting newly added content scanned within a short timeframe. The auto-scan is not really working in JF because of the networkdrives.
Tried Radarr with webhook and that does not seem to work very well either..

Anyway... In kodi there is this option "Update library on startup". Meaning, every time I start kodi to watch something, it adds the latest stuff..
But I assume this option does not actually trigger a scan within my JF server. (?)

So I'm looking for the same function, but that works with "Jelly for Kodi".
Maybe there is a way to trigger a Phyton script when Kodi starts?

(Bash) Something like: curl -d "" http://[jellyfin ip]:[port]/library/refresh?api_key=[yourapikey]
(PS1) Invoke-RestMethod -Uri "http://[jellyfin ip]/library/refresh?api_key=[yourapikey]" -Method POST

I'm not a coder, so I don't know how that would look in Phyton.
Okay I think I actually managed to code my first phyton script and get it to run on kodi start.. Tongue



Android\data\org.xbmc.kodi\files\.kodi\addons\service.autoexec\autoexec.py


Code:
import requests


headers = {

    'Content-Type': 'application/x-www-form-urlencoded',

}


params = {

    'api_key': 'JELLY-API-KEY',

}


response = requests.post('http://YOUR-IP:PORT/library/refresh', params=params, headers=headers)

And then also

Android\data\org.xbmc.kodi\files\.kodi\addons\service.autoexec\addon.xml
 
Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.autoexec" name="Autoexec Service" version="1.0.0" provider-name="your username">

<requires>

<import addon="xbmc.python" version="3.0.0"/>

<import addon="script.module.requests" version="3.0.0"/>

</requires>

<extension point="xbmc.service" library="autoexec.py">

</extension>

<extension point="xbmc.addon.metadata">

<summary lang="en_GB">Automatically run python code when Kodi starts.</summary>

<description lang="en_GB">The Autoexec Service will automatically be run on Kodi startup.</description>

<platform>all</platform>

<license>GNU GENERAL PUBLIC LICENSE Version 2</license>

</extension>

</addon>