Starting a playlist after boot

I am attempting to start a playlist after OSMC finishes booting on my Raspberry Pi 3B+

I have a script called mainplaylists.sh:
The script works if I call it by hand, and it writes to the log every time it boots, so SOMETHING is working.

#!/bin/bash

now=$(date +"%Y %b %d %H:%M:%S")

echo "Stream Launched at $now" >> /home/osmc/scripts/logs/oofstream.log

/usr/bin/kodi-send --action=PlayerControl"(repeatall)"

/usr/bin/kodi-send --action=PlayerControl"(RandomOn)"

#kodi-send --action=PlayMedia"(/home/osmc/ooftv/broadcast/musicvideos , isdir)"

/usr/bin/kodi-send --action=PlayMedia"(/home/osmc/ooftv/broadcast/playlists/today.m3u)"

Here’s the contents of my /lib/systemd/system/mainplaylist.service

[Unit]
Description = Launch the main playlist at boot 
After = paths.target 
[Service]
Type = oneshot
ExecStart = /home/osmc/scripts/mainplaylist.sh
[Install]
WantedBy = multi-user.target

So I know it’s running, but the videos never start playing. I’m thinking that the script is run too quickly, so the commands just get ignored. Any ideas what I’m doing wrong? Should I just put a delay in the shell script? That seems kind of sloppy so wondering if there was a better way to do it.

Just to confirm, adding

sleep 60 before the Kodi-send commands does the trick, so it seems like using systemd is too fast

Not to discourage your nice coding but you might just wanted to have used autoexec.py
https://kodi.wiki/view/Autoexec.py

Oh ha, yeah I guess I can try that instead. I thought that was out of date since it was still using xbmc

The python functions have not been renamed.

Although Autoexec.py is a better way, you could also change your “mainplaylist.service” to add mediacenter.service to the “After” line.