[SCRIPT] RetroPie Limit Last Played Games
-
I present to you Retropie Limit Last Played Games: A tool for RetroPie to limit the number of 'last played' games.
First of all, I'd like to point out that this script came up in the thread Last Played Collection - Possible to limit? and this functionality (not the one in my script) will be merged into EmulationStation in future versions. It's actually already been merged, but in the
emulationstation-dev
package.Anyway, I started to code this script before @pjft added this feature, so I'm releasing the script at least for recreational or learning purposes :P
What this script does is parse the
gamelist.xml
of the selected systems looking for<lastplayed>
tags, sorts them in a descending order and changes the value of<playcount>
to0
for all the games except thex
limit number set.Retropie Limit Last Played Games (v2.1.4 - 2019-02-14)
A tool for RetroPie to limit the number of 'last played' games.
Installation
cd /home/pi/ git clone https://github.com/hiulit/Retropie-Limit-Last-Played-Games cd Retropie-Limit-Last-Played-Games/ sudo chmod +x retropie-limit-last-played-games.sh
Updating
cd /home/pi/Retropie-Limit-Last-Played-Games/ git pull
Usage
./retropie-limit-last-played-games.sh [OPTIONS]
Examples
./retropie-limit-last-played-games.sh --nth 25 --systems
This will set the number of 'last played' games to limit at 25 and then it will show a dialog from where it can be selected as many systems as needed.
./retropie-limit-last-played-games.sh --nth 25 --systems --debug
This will set the debug mode on. It's perfect for testing the script before actually 'harming' the gamelists.
./retropie-limit-last-played-games.sh --gui
This will start the GUI. It will ask you to enter a number to limit the number of 'last played' the games shown. Then it will ask you to choose the desired systems to apply that limit.
If no options are passed, you will be prompted with a usage example:
USAGE: ./retropie-limit-last-played-games.sh.sh [OPTIONS] Use './retropie-limit-last-played-games.sh --help' to see all the options.
Options
--help
: Print the help message and exit.--install
: Install the script in EmulationStation's RetroPie menu.--uninstall
: Uninstall the script from EmulationStation's RetroPie menu.--nth
: Set number of 'last played' games to limit per system (10 by default).--systems
: Show dialog to select systems to limit.--gui
: Start the GUI.--debug
: Set debug mode to test the script.--version
: Show script version.
Examples
--help
Print the help message and exit.
Example
./retropie-limit-last-played-games.sh --help
--install
Install the script in EmulationStation's RetroPie menu.
You'll find it as 'Limit Last Played Games'.
Example
./retropie-limit-last-played-games.sh --install
--uninstall
Uninstall the script from EmulationStation's RetroPie menu.
Example
./retropie-limit-last-played-games.sh --uninstall
--nth [OPTIONS]
Set number of 'last played' games to limit per system (10 by default).
Options
[number]
: Number to limit 'last played' games per system.
Example
./retropie-limit-last-played-games.sh --nth 25
The
--nth
option won't do anything by itself. It always has to be accompanied, at least, by--systems
.--systems
Show a dialog to select the system/s to limit.
Example
./retropie-limit-last-played-games.sh --systems
--gui
Start the GUI.
It lets you use the script in a more friendly way.
Example
./retropie-limit-last-played-games.sh --gui
--debug
Set debug mode to test the script.
No harm will be done to the gamelists ;)
If you want to explicitly know that you are under
debug mode
, use this option as the first parameter when launching the script and it will appear on the script's title.Example
./retropie-limit-last-played-games.sh --debug
--version
Show script version.
Example
./retropie-limit-last-played-games.sh --version
Screenshots
-
Hi @hiulit,
I'm tring your script but probably i don't understand how to use it.
Every time i run the script, it tells me that is removing last played games, and if i go to emulationstation -> Last Played menu, the number of games is always the same.I ran the script
./retropie-limit-last-played-games.sh -n 1 -s
and i select only theamiga
system, the results isNumber of 'last played' games to limit is set to '1'. amiga ----- 'gamelist.xml' for 'amiga' found! > Creating 'gamelist-backup.xml' for 'amiga' ... There is already a 'gamelist-backup.xml' for 'amiga'. > Removing 'last played' games for 'amiga' ... 20180902T143322 20180902T141816 20180902T141646 20180902T141045 20180902T140154 20180902T140041 20180902T135914 20180902T135359 20180902T135247 20180902T134747 20180902T134547 20180901T151127 20180901T150821 20180901T144602 20180901T143329 20180901T142836 20180901T142806 20180901T130815 20180901T115520 20180901T115418 20180901T115323 20180901T114515 20180901T110042 20180901T105134 20180901T103756 20180901T095836 20180831T230516 20180720T005157 20180719T150228 > Done! Done!
and if i run it again another time, it tells me the exact same thing.
Could you please help me?
Thank you
-
@madhorse I think you need to exit Emulationstation before runing the script.
-
Hi @mitu,
Thank you for your answer, I already tried but nothing changed. -
@madhorse Hi there! Hmmmm.... It's been a while since I used this script. Let me try it myself to see if it happens to me too and I'll get back to you :)
-
@madhorse said in [SCRIPT] RetroPie Limit Last Played Games:
Hi @mitu,
Thank you for your answer, I already tried but nothing changed.You can check the game list right after running the script by this command:
grep lastplayed /path/to/your/gamelist.xml
It will list all lines that contain "lastplayed". This way, you'll know if the problem is that the script doesn't change the file. If the file is changed, the changes are reversed later somehow.
-
Hi @Clyde and thank you for your help.
If I understand correctly, the script remove or set to 0 the
playcount
and don't touchlastplayed
, maybe this is the reason is not working, or at least don't seems to work for me.
In any case, I did wath you asked me, this is the resultspi@retropie:~/RetroPie/roms/megadrive $ grep lastplayed gamelist.xml <lastplayed>20180626T204249</lastplayed> <lastplayed>20180704T005027</lastplayed> <lastplayed>20180725T124034</lastplayed> <lastplayed>20180725T143844</lastplayed> pi@retropie:~/RetroPie/roms/megadrive $ ../retropie-limit-last-played-games.sh -s --nth 1 Number of 'last played' games to limit is set to '1'. megadrive --------- 'gamelist.xml' for 'megadrive' found! > Creating 'gamelist-backup.xml' for 'megadrive' ... There is already a 'gamelist-backup.xml' for 'megadrive'. > Removing 'last played' games for 'megadrive' ... 20180725T124034 20180704T005027 20180626T204249 > Done! Done! pi@retropie:~/RetroPie/roms/megadrive $ grep lastplayed gamelist.xml <lastplayed>20180626T204249</lastplayed> <lastplayed>20180704T005027</lastplayed> <lastplayed>20180725T124034</lastplayed> <lastplayed>20180725T143844</lastplayed>
After this, i opened thegamelist.xml for the megadrive and the file is not modified
-rw-r--r-- 1 pi pi 1145107 Sep 6 18:03 gamelist-backup.xml -rw-r--r-- 1 pi pi 15697 Jun 20 11:58 gamelist.Missing.Serial.txt -rw-r--r-- 1 pi pi 1145107 Jul 25 15:41 gamelist.xml
So it seems it create a backup and then don't change anything.
Thank you for your help, I really appreciate it.
-
@madhorse I found the bug! I'll release a new version with additional functionalities. Maybe tomorrow ;)
-
@hiulit
According to @MadHorse's test, the script removed three "last played" occurances, while grep listed four of them in the file. Is that part of the bug, or what else caused the discrepancy? Just mentioning to help you debug. :)Ah, just ignore me. The script limited the "last played" to one, thus removed three of four. It's too early here in Germany to write in forums, obviously. š
-
@clyde Almost got it! Been working hard, refactoring stuff :P I guess I'll be releasing a new version soonish.
-
-
-
@hiulit said in [SCRIPT] RetroPie Limit Last Played Games:
@madhorse whoops, sorry, hehe! You were the one with the issue, actually, and I was replying to @Clyde :P
hehe no problem :)
-
-
-
Here it is!
RetroPie Limit Last Played Games v2.0.0
Read the new docs, as there have been a few changes.
Added
- Option to install/Uninstall the script from EmulationStation's RetroPie menu.
- GUI mode.
- Debug mode - To test the script. No harm will done to the gamelists ;)
- Log files - Found in
/home/pi/Retropie-Limit-Last-Played-Games/logs
).
Fixed
- Uncommented code preventing to actually remove 'last played' games.
- Fixed #1 - Only show systems that have a gamelist.xml.
Changed
- Refactored the code to create backups. Now the folder is called
gamelist-backups
(inside the$SYSTEM_ROMS
folder) and contains all the game lists backups, named[DATE]-gamelist-backup.xml
. - Added more
error/success
output messages. - Better control of what games have to be processed.
Examples
./retropie-limit-last-played-games.sh --nth 25 --systems
This will set the number of 'last played' games to limit at 25 and then it will show a dialog from where it can be selected as many systems as needed.
./retropie-limit-last-played-games.sh --nth 25 --systems --debug
This will set the debug mode on. It's perfect for testing the script before actually 'harming' the gamelists.
./retropie-limit-last-played-games.sh --gui
This will start the GUI. It will ask you to enter a number to limit the number of 'last played' the games shown. Then it will ask you to choose the desired systems to apply that limit.
Options
--help
: Print the help message and exit.--install
: Install the script in EmulationStation's RetroPie menu.--uninstall
: Uninstall the script from EmulationStation's RetroPie menu.--nth
: Set number of 'last played' games to limit per system (10 by default).--systems
: Show dialog to select systems to limit.--gui
: Start the GUI.--debug
: Set debug mode to test the script.--version
: Show script version.
-
@hiulit Great work! (without having tested it)
-
@hiulit, first, thank you so much for your work, your work is really appreciated.
Second, yout script is awesome, it's working perfectly.
Installed the script on the Retropie menu, launched the script, choosed to keep 1 last played game, at the end of the execution you need to restart Emulationstation to see the results.Now my last played list contain only 40 games, one per system :)
Thank you again, you did a great job.
-
@hiulit I don't want to do a PR but you can add these lines to perform a restart. You can write a small yes/no dialog to perform a restart to ES.
# Restart ES! touch /tmp/es-restart chown pi:pi /tmp/es-restart kill $(pidof emulationstation)
Best wishes ;)
-
@madhorse Hey! You're welcome! I'm glad you find it useful :D
And you made a good point about EmulationStation having to be restarted to see the changes. I'll add a message to the script .
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.