mirror of
https://github.com/Febbweiss/rclone_script.git
synced 2026-03-04 22:25:36 +00:00
Added support for custom save file paths
This commit is contained in:
@@ -2,6 +2,15 @@
|
|||||||
<emulators>
|
<emulators>
|
||||||
<emulator>
|
<emulator>
|
||||||
<name>lr-ppsspp</name>
|
<name>lr-ppsspp</name>
|
||||||
|
<saveFileExtensions>
|
||||||
|
<ext>SYS</ext>
|
||||||
|
<ext>PNG</ext>
|
||||||
|
<ext>SFO</ext>
|
||||||
|
<ext>state</ext>
|
||||||
|
</saveFileExtensions>
|
||||||
|
</emulator>
|
||||||
|
<emulator>
|
||||||
|
<name>ppsspp</name>
|
||||||
<saveFilePath>/opt/retropie/configs/psp/PSP/SAVEDATA</saveFilePath>
|
<saveFilePath>/opt/retropie/configs/psp/PSP/SAVEDATA</saveFilePath>
|
||||||
<saveStatePath>/opt/retropie/configs/psp/PSP/PPSSPP_STATE</saveStatePath>
|
<saveStatePath>/opt/retropie/configs/psp/PSP/PPSSPP_STATE</saveStatePath>
|
||||||
<saveFileExtensions>
|
<saveFileExtensions>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ UNDERLINE=$(tput smul)
|
|||||||
# include settings file
|
# include settings file
|
||||||
config=~/scripts/rclone_script/rclone_script.ini
|
config=~/scripts/rclone_script/rclone_script.ini
|
||||||
source ${config}
|
source ${config}
|
||||||
logLevel=2
|
logLevel=3
|
||||||
|
|
||||||
# include emulator specific settings
|
# include emulator specific settings
|
||||||
emu_settings=~/scripts/rclone_script/emulator_settings.xml
|
emu_settings=~/scripts/rclone_script/emulator_settings.xml
|
||||||
@@ -136,6 +136,23 @@ function getROMFileName ()
|
|||||||
romfileext="${romfilename#*.}" # extension of $rom
|
romfileext="${romfilename#*.}" # extension of $rom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getSaveFilePath ()
|
||||||
|
{
|
||||||
|
saveFilePath=$(xmlstarlet sel -t -m "emulators/emulator[name='${emulator}']" -v "saveFilePath" "${emu_settings}")
|
||||||
|
|
||||||
|
# If no save file path specified
|
||||||
|
if [ -z "${saveFilePath// }" ]
|
||||||
|
then
|
||||||
|
|
||||||
|
log 3 "Using default save file path for emulator: ${emulator}"
|
||||||
|
|
||||||
|
# Default to the normal saves directory
|
||||||
|
saveFilePath="~/RetroPie/saves/${system}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
log 3 "Save file path: ${saveFilePath}"
|
||||||
|
}
|
||||||
|
|
||||||
# Builds patterns compatible with find and rclone
|
# Builds patterns compatible with find and rclone
|
||||||
function prepareSaveFilters ()
|
function prepareSaveFilters ()
|
||||||
{
|
{
|
||||||
@@ -156,7 +173,7 @@ function prepareSaveFilters ()
|
|||||||
else
|
else
|
||||||
|
|
||||||
# Otherwise, build custom filters
|
# Otherwise, build custom filters
|
||||||
log 2 "Custom save extentions defined for emulator: ${emulator}"
|
log 3 "Custom save extentions defined for emulator: ${emulator}"
|
||||||
i=0
|
i=0
|
||||||
|
|
||||||
# Build the filters for the extensions
|
# Build the filters for the extensions
|
||||||
@@ -276,7 +293,7 @@ function downloadSaves ()
|
|||||||
log 2 "Found remote files"
|
log 2 "Found remote files"
|
||||||
|
|
||||||
# download saves and states to corresponding ROM
|
# download saves and states to corresponding ROM
|
||||||
rclone copy retropie:${remotebasedir}/${system} ~/RetroPie/saves/${system} --include "${remoteFilter}" --update >> ${logfile}
|
rclone copy retropie:${remotebasedir}/${system} ${saveFilePath} --include "${remoteFilter}" --update >> ${logfile}
|
||||||
retval=$?
|
retval=$?
|
||||||
|
|
||||||
if [ "${retval}" = "0" ]
|
if [ "${retval}" = "0" ]
|
||||||
@@ -320,7 +337,7 @@ function uploadSaves ()
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
localfiles=$(find ~/RetroPie/saves/${system} -type f "${localFilter[@]}")
|
localfiles=$(find ${saveFilePath} -type f "${localFilter[@]}")
|
||||||
|
|
||||||
if [ "${localfiles}" = "" ]
|
if [ "${localfiles}" = "" ]
|
||||||
then # no local files found
|
then # no local files found
|
||||||
@@ -328,7 +345,7 @@ function uploadSaves ()
|
|||||||
showNotification "Uploading saves and states to ${remoteType}... No local files found"
|
showNotification "Uploading saves and states to ${remoteType}... No local files found"
|
||||||
else # local files found
|
else # local files found
|
||||||
# upload saves and states to corresponding ROM
|
# upload saves and states to corresponding ROM
|
||||||
rclone copy ~/RetroPie/saves/${system} retropie:${remotebasedir}/${system} --include "${remoteFilter}" --update >> ${logfile}
|
rclone copy ${saveFilePath} retropie:${remotebasedir}/${system} --include "${remoteFilter}" --update >> ${logfile}
|
||||||
retval=$?
|
retval=$?
|
||||||
|
|
||||||
if [ "${retval}" = "0" ]
|
if [ "${retval}" = "0" ]
|
||||||
@@ -394,6 +411,7 @@ if [ "${direction}" == "up" ] && [ "${system}" != "kodi" ]
|
|||||||
then
|
then
|
||||||
getROMFileName
|
getROMFileName
|
||||||
prepareSaveFilters
|
prepareSaveFilters
|
||||||
|
getSaveFilePath
|
||||||
getTypeOfRemote
|
getTypeOfRemote
|
||||||
uploadSaves
|
uploadSaves
|
||||||
fi
|
fi
|
||||||
@@ -402,6 +420,7 @@ if [ "${direction}" == "down" ] && [ "${system}" != "kodi" ]
|
|||||||
then
|
then
|
||||||
getROMFileName
|
getROMFileName
|
||||||
prepareSaveFilters
|
prepareSaveFilters
|
||||||
|
getSaveFilePath
|
||||||
getTypeOfRemote
|
getTypeOfRemote
|
||||||
downloadSaves
|
downloadSaves
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user