Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Psp save support #21

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions emulator_settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<emulators>
<emulator>
<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/</saveFilePath>
<saveStatePath>/opt/retropie/configs/psp/PSP/PPSSPP_STATE</saveFilePath>
<saveFileExtensions>
<ext>SYS</ext>
<ext>PNG</ext>
<ext>SFO</ext>
<ext>state</ext>
</saveFileExtensions>
</emulator>
</emulators>
5 changes: 3 additions & 2 deletions rclone_script-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ function dialogShowProgress ()
function dialogShowSummary ()
{
# list all remotes and their type
remotes=$(rclone listremotes -l)
remotes=$(rclone listremotes --long)

# get line with RETROPIE remote
retval=$(grep -i "^retropie:" <<< ${remotes})
Expand Down Expand Up @@ -647,7 +647,8 @@ function 4aGetRCLONE_SCRIPT ()
wget -N -P ~/scripts/rclone_script ${url}/${branch}/rclone_script.sh --append-output="${logfile}" &&
wget -N -P ~/scripts/rclone_script ${url}/${branch}/rclone_script-menu.sh --append-output="${logfile}" &&
wget -N -P ~/scripts/rclone_script ${url}/${branch}/rclone_script-uninstall.sh --append-output="${logfile}" &&

wget -N -P ~/scripts/rclone_script ${url}/${branch}/emulator_settings.xml --append-output="${logfile}" &&

# change mod
chmod +x ~/scripts/rclone_script/rclone_script.sh >> "${logfile}" &&
chmod +x ~/scripts/rclone_script/rclone_script-menu.sh >> "${logfile}" &&
Expand Down
2 changes: 1 addition & 1 deletion rclone_script-menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function log ()
function getTypeOfRemote ()
{
# list all remotes and their type
remotes=$(rclone listremotes -l)
remotes=$(rclone listremotes --long)

# get line wiht RETROPIE remote
retval=$(grep -i "^retropie:" <<< ${remotes})
Expand Down
2 changes: 1 addition & 1 deletion rclone_script-uninstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function uninstaller ()
function saveRemote ()
{
# list all remotes and their type
remotes=$(rclone listremotes -l)
remotes=$(rclone listremotes --long)

# get line with RETROPIE remote
retval=$(grep -i "^retropie:" <<< ${remotes})
Expand Down
85 changes: 74 additions & 11 deletions rclone_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ config=~/scripts/rclone_script/rclone_script.ini
source ${config}
logLevel=2

# include emulator specific settings
emu_settings=~/scripts/rclone_script/emulator_settings.xml


# parameters
direction="$1"
Expand Down Expand Up @@ -133,16 +136,74 @@ function getROMFileName ()
romfileext="${romfilename#*.}" # extension of $rom
}

function prepareFilter ()
function getSaveFilePath ()
{
filter="${romfilebase//\[/\\[}"
filter="${filter//\]/\\]}"
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
function prepareSaveFilters ()
{
# Read in any extensions
extensions=$(xmlstarlet sel -t -m "emulators/emulator[name='${emulator}']/saveFileExtensions" -v "ext" "${emu_settings}")

# If no extensions were defined
if [ -z "${extensions// }" ]
then

log 3 "Using default save file filter for emulator: ${emulator}"

# Default to "<ROM_name>.*"
localFilter="${romfilebase//\[/\\[}"
localFilter="${localFilter//\]/\\]}.*"
remoteFilter="${localFilter}"
localFilter=("-iname" "${localFilter}")

else

# Otherwise, build custom filters
log 3 "Custom save extentions defined for emulator: ${emulator}"
i=0

# Build the filters for the extensions
while read ext; do

if [ "${i}" -eq "0" ]
then

remoteFilter="{*.${ext}"
localFilter+=("-iname" "*.${ext}")
((i++))

else

remoteFilter="${remoteFilter},*.${ext}"
localFilter+=("-o" "-iname" "*.${ext}")
fi

done <<< ${extensions}

remoteFilter="${remoteFilter}}"

fi
}

function getTypeOfRemote ()
{
# list all remotes and their type
remotes=$(rclone listremotes -l)
remotes=$(rclone listremotes --long)

# get line with RETROPIE remote
retval=$(grep -i "^retropie:" <<< ${remotes})
Expand Down Expand Up @@ -219,7 +280,7 @@ function downloadSaves ()
fi

# test for remote files
remotefiles=$(rclone lsf retropie:${remotebasedir}/${system} --include "${filter}.*")
remotefiles=$(rclone lsf retropie:${remotebasedir}/${system} --include "${remoteFilter}")
retval=$?

if [ "${retval}" = "0" ]
Expand All @@ -233,7 +294,7 @@ function downloadSaves ()
log 2 "Found remote files"

# download saves and states to corresponding ROM
rclone copy retropie:${remotebasedir}/${system} ~/RetroPie/saves/${system} --include "${filter}.*" --update >> ${logfile}
rclone copy retropie:${remotebasedir}/${system} ${saveFilePath} --include "${remoteFilter}" --update >> ${logfile}
retval=$?

if [ "${retval}" = "0" ]
Expand Down Expand Up @@ -276,16 +337,16 @@ function uploadSaves ()

return
fi

localfiles=$(find ~/RetroPie/saves/${system} -type f -iname "${filter}.*")
localfiles=$(find ${saveFilePath} -type f "${localFilter[@]}")

if [ "${localfiles}" = "" ]
then # no local files found
log 2 "No local saves and states found"
showNotification "Uploading saves and states to ${remoteType}... No local files found"
else # local files found
# upload saves and states to corresponding ROM
rclone copy ~/RetroPie/saves/${system} retropie:${remotebasedir}/${system} --include "${filter}.*" --update >> ${logfile}
rclone copy ${saveFilePath} retropie:${remotebasedir}/${system} --include "${remoteFilter}" --update >> ${logfile}
retval=$?

if [ "${retval}" = "0" ]
Expand Down Expand Up @@ -350,15 +411,17 @@ log 3 "romfileext: ${romfileext}"
if [ "${direction}" == "up" ] && [ "${system}" != "kodi" ]
then
getROMFileName
prepareFilter
prepareSaveFilters
getSaveFilePath
getTypeOfRemote
uploadSaves
fi

if [ "${direction}" == "down" ] && [ "${system}" != "kodi" ]
then
getROMFileName
prepareFilter
prepareSaveFilters
getSaveFilePath
getTypeOfRemote
downloadSaves
fi
Expand Down