I use a Raspberry Pi to show a slideshow of pictures stored in a folder.
However, if I add pictures to the folder while the slideshow is running, the new pictures are not added to the slideshow.
How to achieve this behavior without interrupting the slideshow?
Add an autostart script to Kodi: It will run the slideshow automatically when Kodi starts and refresh the slideshow if the content of the folder changes.
This script comes from this answer: https://discourse.osmc.tv/t/refresh-picture-library/4867/13
# ~/.kodi/userdata/autoexec.py
# On Kodi startup, automatically start a Slideshow
# Refresh the slideshow if the content of the folder has been updated
import xbmc
from os import listdir
from time import sleep
xbmc.log('[refresh-slideshow] Starting')
monitor = xbmc.Monitor()
picfolder = "/PATH/TO/FOLDER"
# Generate list of images and start slideshow
l1 = listdir(picfolder)
xbmc.executebuiltin('SlideShow(%s)' %(picfolder))
xbmc.log('[refresh-slideshow] Slideshow started, monitoring')
# Wait for slideshow to start
sleep(5)
# Monitor during slideshow
while not monitor.abortRequested():
# If slideshow is still running, compare directory contents
if xbmc.getCondVisibility('Window.IsActive(slideshow)'):
l2 = listdir(picfolder)
# Restart slideshow if directory contents have changed
if l1 != l2:
xbmc.log('[refresh-slideshow] Folder contents changed, restarting slideshow')
xbmc.executebuiltin('SlideShow(%s)' %(picfolder))
l1 = l2
# If slideshow is no longer running (user has exited), exit script
else:
break
# Wait for 60 seconds, break if abort is requested
if monitor.waitForAbort(60):
break
xbmc.log('[refresh-slideshow] Finished, exiting')