Last active
November 26, 2018 16:51
-
-
Save chrisross/bb83c1b51c3ad138327e to your computer and use it in GitHub Desktop.
This script scans for connected usb media, selects the first one and creates a playlist from the USB's top-level directory. Connect to the same network as the raspberry pi and scp the script to /home/osmc/.kodi/userdata (this may vary depending on OS). This is meant for a Raspberry Pi used as a media player, with OSMC installed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Autoplay videodirectory | |
import os, xbmc, time | |
usb_dir = "/media" # path of external media | |
delay = 10 # seconds to delay media player | |
# Collect directories (USBs) in usb directory | |
usb_list = [] | |
for fname in os.listdir(usb_dir): | |
fpath = os.path.join(usb_dir, fname) | |
if os.path.isdir(fpath): | |
usb_list.append(fpath) | |
usb_list.sort() | |
path = usb_list[0] | |
dir_list = os.listdir(path) | |
dir_list.sort() | |
video_list = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) | |
video_list.clear() | |
for fname in dir_list: | |
video_list.add(path + "\\" + fname) | |
# shuffle playlist | |
# video_list.unshuffle() | |
# put playlist on repeat | |
xbmc.executebuiltin("xbmc.playercontrol(RepeatAll)") | |
# delay play | |
time.sleep(delay) | |
# play playlist | |
xbmc.Player().play(video_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scp -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -q ./autoexec.py [email protected]:/home/osmc/.kodi/userdata |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment