2022-06-26 17:41:12 +02:00
|
|
|
#!/command/with-contenv bash
|
|
|
|
|
|
|
|
echo "INFO | Parsing custom playlist..."
|
|
|
|
|
2022-12-24 13:40:42 +01:00
|
|
|
[[ -z "${CUSTOM_PLAYLIST}" ]] && \
|
|
|
|
echo "INFO | Custom Playlist is not enabled, keeping default or user-edited playlist" && \
|
|
|
|
exit 0
|
|
|
|
|
|
|
|
PLAYLIST_PATH=${PLAYLIST_PATH:-playlist.txt}
|
2022-06-26 17:41:12 +02:00
|
|
|
PLAYLIST_FILE='GameData/Tracks/MatchSettings/playlist.xml'
|
|
|
|
|
2022-12-24 13:40:42 +01:00
|
|
|
if [[ -f "${PLAYLIST_PATH}" ]]; then
|
2022-06-26 17:41:12 +02:00
|
|
|
count=1
|
|
|
|
while read l; do
|
|
|
|
xmlstarlet ed -L -s /playlist -t elem -n challenge $PLAYLIST_FILE
|
|
|
|
xmlstarlet ed -L -s "/playlist/challenge[${count}]" -t elem -n file -v "${l}" $PLAYLIST_FILE
|
|
|
|
count=$((count+1))
|
2022-12-24 13:40:42 +01:00
|
|
|
done < $PLAYLIST_PATH
|
2022-06-26 17:41:12 +02:00
|
|
|
else
|
|
|
|
xmlstarlet ed -L -s /playlist -t elem -n challenge $PLAYLIST_FILE
|
|
|
|
xmlstarlet ed -L -s "playlist/challenge[1]" -t elem -n file -v "Challenges/Nadeo/A01-Race.Challenge.Gbx" $PLAYLIST_FILE
|
|
|
|
fi
|
|
|
|
|
2022-12-24 13:40:42 +01:00
|
|
|
echo "INFO | Finished parsing playlist files"
|