lidarr-dl/ra-rom-downloader/Downloader.bash

70 lines
4.1 KiB
Bash
Raw Normal View History

2023-08-18 13:32:04 +02:00
#!/usr/bin/with-contenv bash
2023-08-18 14:17:00 +02:00
scriptVersion="1.2"
2023-08-07 02:22:38 +02:00
scriptName="RA-ROM-Downloader"
2023-08-18 13:36:33 +02:00
#### Import Settings
source /config/extended.conf
2023-08-18 13:45:21 +02:00
downloadPath="$romPath/RA_collection"
2023-08-07 02:22:38 +02:00
#### Funcitons
2023-08-07 13:10:13 +02:00
logfileSetup () {
# auto-clean up log file to reduce space usage
if [ -f "/config/$scriptName.log" ]; then
if find /config -type f -name "$scriptName.log" -size +1024k | read; then
echo "" > /config/$scriptName.log
fi
fi
if [ ! -f "/config/$scriptName.log" ]; then
echo "" > /config/$scriptName.log
chmod 666 "/config/$scriptName.log"
fi
}
2023-08-10 21:06:01 +02:00
DownloadRomCountSummary () {
2023-08-18 13:32:04 +02:00
OIFS="$IFS"
IFS=$'\n'
2023-08-18 13:36:33 +02:00
romCount=$(find "$downloadPath" -type f -iname "*.zip" | wc -l)
platformCount=$(find "$downloadPath" -maxdepth 1 -mindepth 1 -type d | wc -l)
2023-08-18 13:32:04 +02:00
echo "################## ROM SUMMARY ##################" 2>&1 | tee -a /config/$scriptName.log
echo "$romCount ROMS downloaded on $platformCount different platforms!!!" 2>&1 | tee -a /config/$scriptName.log
echo "############### DETAILED SUMMARY ################" 2>&1 | tee -a /config/$scriptName.log
echo "Platforms ($platformCount):;Total:" > /config/temp
2023-08-18 13:36:33 +02:00
for romfolder in $(find "$downloadPath" -maxdepth 1 -mindepth 1 -type d); do
2023-08-10 21:06:01 +02:00
platform="$(basename "$romfolder")"
2023-08-18 13:32:04 +02:00
platformRomCount=$(find "$romfolder" -type f -iname "*.zip" | wc -l)
echo "$platform;$platformRomCount" >> /config/temp
2023-08-10 21:06:01 +02:00
done
2023-08-18 13:32:04 +02:00
echo "Totals:;$romCount;" >> /config/temp
2023-08-11 15:24:54 +02:00
data=$(cat /config/temp | column -s";" -t)
2023-08-18 13:32:04 +02:00
rm /config/temp
echo "$data" 2>&1 | tee -a /config/$scriptName.log
IFS="$OIFS"
}
DownloadRoms () {
echo "############### UPDATING ROMS #################" 2>&1 | tee -a /config/$scriptName.log
2023-08-18 14:11:43 +02:00
rclone sync -P --http-url https://archive.org ":http:/27/items/retroachievements_collection_v5" "$downloadPath" --filter="- SNES/**" --filter="- NES/**" --filter="- PlayStation Portable/**" --filter="- PlayStation/**" --filter="- PlayStation 2/**" --filter "- retroachievements_collection*" --filter "- TamperMonkeyRetroachievements*" --filter "- __ia_thumb.jpg" --filter "- rclone.txt" --local-case-sensitive --delete-before --transfers $downloadTransfers --checkers $downloadCheckers --tpslimit $downloadTpslimit --log-file="/config/rclong.log"
rclone sync -P --http-url https://archive.org ":http:/29/items/retroachievements_collection_NES/NES" "$downloadPath/NES" --local-case-sensitive --delete-before --transfers $downloadTransfers --checkers $downloadCheckers --tpslimit $downloadTpslimit --log-file="/config/rclong.log"
rclone sync -P --http-url https://archive.org ":http:/25/items/retroachievements_collection_SNES/SNES" "$downloadPath/SNES" --local-case-sensitive --delete-before --transfers $downloadTransfers --checkers $downloadCheckers --tpslimit $downloadTpslimit --filter="- *(MSU)*" --log-file="/config/rclong.log"
rclone sync -P --http-url https://archive.org ":http:/23/items/retroachievements_collection_PlayStation_Portable/PlayStation Portable" "$downloadPath/PlayStation Portable" --local-case-sensitive --delete-before --transfers $downloadTransfers --checkers $downloadCheckers --tpslimit $downloadTpslimit --log-file="/config/rclong.log"
rclone sync -P --http-url https://archive.org ":http:/31/items/retroachievements_collection_PlayStation/PlayStation" "$downloadPath/PlayStation" --local-case-sensitive --delete-before --transfers $downloadTransfers --checkers $downloadCheckers --tpslimit $downloadTpslimit --log-file="/config/rclong.log"
rclone sync -P --http-url https://archive.org ":http:/16/items/retroachievements_collection_PS2/PlayStation 2" "$downloadPath/PlayStation 2" --local-case-sensitive --delete-before --transfers $downloadTransfers --checkers $downloadCheckers --tpslimit $downloadTpslimit --log-file="/config/rclong.log"
2023-08-18 13:32:04 +02:00
}
# Loop Script
for (( ; ; )); do
let i++
logfileSetup
2023-08-18 14:17:00 +02:00
echo "############# $scriptName ###############" 2>&1 | tee -a /config/$scriptName.log
echo "Version: $scriptVersion" 2>&1 | tee -a /config/$scriptName.log
echo "Starting..." 2>&1 | tee -a /config/$scriptName.log
2023-08-18 13:32:04 +02:00
DownloadRomCountSummary
DownloadRoms
DownloadRomCountSummary
echo "Script sleeping for $downloadScriptInterval..." 2>&1 | tee -a /config/$scriptName.log
sleep $downloadScriptInterval
2023-08-07 02:22:38 +02:00
done
2023-08-03 15:52:11 +02:00
exit