Skip to content

Instantly share code, notes, and snippets.

@georgboe
Created March 10, 2020 19:21
Show Gist options
  • Save georgboe/463f5bb98e08ba8c1a941e1197ca16e6 to your computer and use it in GitHub Desktop.
Save georgboe/463f5bb98e08ba8c1a941e1197ca16e6 to your computer and use it in GitHub Desktop.
Script to autoplay videofiles in KODI in random order - put this your kodi userdata directory
# Autoplay videodirectory
import os, xbmc
# set path to dir you want to play
path = "/var/media/asdf"
dirList = os.listdir(path)
dirList.sort()
videoList = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
videoList.clear()
for file in dirList:
videoList.add(path + "/" + file)
# shuffle playlist
videoList.shuffle()
# put playlist on repeat
xbmc.executebuiltin("xbmc.playercontrol(RepeatAll)")
# play playlist
xbmc.Player().play(videoList)
@georgboe
Copy link
Author

The script can also be triggered manually using kodi-send:

kodi-send -a "RunScript(/storage/.kodi/userdata/autoexec.py)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment