[SCRIPT] RetroPie Limit Last Played Games
-
-
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 .
-
@cyperghost hey, I was just thinking about adding a message but I like your idea better. Thanks for the code ;)
-
@cyperghost btw, can this code be run under 'sudo'? Because my script has an option be installed in the RetroPie menu and I think the scripts executed from there are run under 'sudo'.
-
@hiulit Yes but then the file has to be chowend to pi:pi
Added to the codebox -
@cyperghost the file being 'tmp/es-restart' or my script?
-
@hiulit The restart file
Because ES entitiy deletes the file on restart and if it was created by root it won't work -
@cyperghost got it. Thanks! I'll try it ;)
-
@hiulit I've found a little "bug", if there are more games that have the exactly same
lastplayed
it will give you this errore:Number of 'last played' games to limit is set to '1'. psx --- 'gamelist.xml' for 'psx' found! > Creating 'gamelist-backups.xml' for 'psx' ... 'gamelist-backups.xml' for 'psx' created successfully! ./retropie-limit-last-played-games.sh: line 124: [[: 0 1: syntax error in expression (error token is "1") ./retropie-limit-last-played-games.sh: line 124: [[: 0 1: syntax error in expression (error token is "1") No 'last played' games to remove. All done!
After i change the time, i just add 1 second, everything is working without a problem.
I think it's almost impossible to have more games with the samelastplayed
date and time unless someone manually edit the file and make some mistakes, so probably is not a big deal. -
@madhorse Hmmm... I'll take a look at it. But what are the odds of having the same date on different
lastplayed
tags? How is it even possible to open 2 different games at the same time? :P hehe! Anyway, I'll look into it. -
@hiulit said in [SCRIPT] RetroPie Limit Last Played Games:
@madhorse Hmmm... I'll take a look at it. But what are the odds of having the same date on different
lastplayed
tags? How is it even possible to open 2 different games at the same time? :P hehe! Anyway, I'll look into it.Exactly, in fact i manually edited the gamelist.xml to add some games because i didn't want to scrape it, copy and paste the
<game>
section and then changed thename
and thepath
, by doing this i also duplicated thelastplayed
date and time.
I just pointed out because if someone needs help for the error./retropie-limit-last-played-games.sh: line 124: [[: 0 1: syntax error in expression (error token is "1")
you know why, but i don't think you need to spend much time over this problem.
-
@madhorse I figured it out. I'll test it a bit and I'll upload a new version. It would be cool if you could help me test once this fix is uploaded. I'll let you know. Thanks!
P.S. This will be on Wednesday. Tomorrow is a holiday for me :P
-
@hiulit No problem mate, I will be happy to test the new version.
Thank you and happy holiday :) -
Version 2.1.0 of RetroPie Limit Last Played Games is here!
Added
- Dialog asking if the user wants to restart EmulationStation when the script is done.
- Output message for the games that will be shown in the 'last played' section.
Fixed
- When there are duplicated <lastplayed> tags in different games the script crashes. Now, if the scripts find duplicates, it looks for the game's name (it should be different).
Thanks to @cyperghost for the restart function and @MadHorse for testing the script.
-
Updated the documentation for v2.1.0 - 2018-09-12 in the first post.
-
Hi @hiulit,
I'm so sorry, but checking the name introduced two more trouble.
If the name contain a'
single quote, it will complain because itFailed to compile select expression
Number of 'last played' games to limit is set to '10'. daphne ------ 'gamelist.xml' for 'daphne' found! > Creating 'gamelist-backups.xml' for 'daphne' ... 'gamelist-backups.xml' for 'daphne' created successfully! Invalid predicate: /gameList/game[name='Dragon's Lair II: Time Warp (US v3.19)']/playcount compilation error: element with-param XSLT-with-param: Failed to compile select expression '/gameList/game[name='Dragon's Lair II: Time Warp (US v3.19)']/playcount' Invalid predicate: /gameList/game[name='Dragon's Lair']/playcount compilation error: element with-param XSLT-with-param: Failed to compile select expression '/gameList/game[name='Dragon's Lair']/playcount' > Removing the 'last played' games surplus for 'daphne' ... ERROR: There aren't enough 'last played' games to remove. Try lowering the '--nth' number. Now it's set to '10' and there are only 4 games in 'daphne'.
Daphne
gamelist.xml
contains 6 played games, but 2 games are not counted beacuse of theXSLT-with-param: Failed to compile select expression
.The other error is, if there are more games with the same name, it will give you another error
Number of 'last played' games to limit is set to '10'. amiga ----- 'gamelist.xml' for 'amiga' found! > Creating 'gamelist-backups.xml' for 'amiga' ... 'gamelist-backups.xml' for 'amiga' created successfully! ./retropie-limit-last-played-games.sh: line 125: [[: 1 1: syntax error in expression (error token is "1") ./retropie-limit-last-played-games.sh: line 125: [[: 1 1: syntax error in expression (error token is "1") > Removing the 'last played' games surplus for 'amiga' ... ERROR: There aren't enough 'last played' games to remove. Try lowering the '--nth' number. Now it's set to '10' and there is only 1 game in 'amiga'.
and instead of the same
lastplayed
date and time, finding more games witht he same name is easier, you may have multiple version of the same game, for example you may have the same Amiga games on CD32,CDTV, ADF or for example in many languages, but when you scrape the games, you will have the same name for every version of the game unless you don't manually change it.
One las note, the 2 amiga games with the same name, didn't have the samelastplayed
date<game> <path>./Turrican2_v1.4_CDTV.lha</path> <name>Turrican II : The Final Fight</name> <desc>Turrican II: The Final Fight is a platformer/shooter as typically seen on consoles, but designed for home computers from the ground up. Its plot is - naturally - very simple: an evil mega-robot called The Machine attacks the United Planets Ship Avalon 1, slaughtering all who resist. All - except Bren McGuire, who manages to escape and slips into the experimental Turrican bionic armor. As Turrican, he strives to show The Machine who's the boss. Unlike other games of its type, this game contains three levels of horizontal shooter action in the spirit of R-Type or the developers' own Katakis. Six large worlds are to be explored, where you are basically free to go everywhere you want, since there is no automatic scrolling and the levels are packed with hidden extra lives and weapons. All those levels are very different: the first one in the rock desert is pretty colorful with parallaxing rainbow background and happy music, while the following worlds get darker and darker.</desc> <image>./media/images/Turrican 2 (CDTV).png</image> <rating>0.95</rating> <releasedate>19910101T000000</releasedate> <developer>Factor 5</developer> <publisher>Rainbow Arts Software</publisher> <genre>Platform</genre> <playcount>1</playcount> <lastplayed>20180719T150228</lastplayed> </game> <game> <path>./Turrican2_v1.7_0029.lha</path> <name>Turrican II : The Final Fight</name> <desc>Turrican II: The Final Fight is a platformer/shooter as typically seen on consoles, but designed for home computers from the ground up. Its plot is - naturally - very simple: an evil mega-robot called The Machine attacks the United Planets Ship Avalon 1, slaughtering all who resist. All - except Bren McGuire, who manages to escape and slips into the experimental Turrican bionic armor. As Turrican, he strives to show The Machine who's the boss. Unlike other games of its type, this game contains three levels of horizontal shooter action in the spirit of R-Type or the developers' own Katakis. Six large worlds are to be explored, where you are basically free to go everywhere you want, since there is no automatic scrolling and the levels are packed with hidden extra lives and weapons. All those levels are very different: the first one in the rock desert is pretty colorful with parallaxing rainbow background and happy music, while the following worlds get darker and darker.</desc> <image>./media/images/Turrican 2 (CDTV).png</image> <rating>0.95</rating> <releasedate>19910101T000000</releasedate> <developer>Factor 5</developer> <publisher>Rainbow Arts Software</publisher> <genre>Platform</genre> <playcount>1</playcount> <lastplayed>20180720T005157</lastplayed> </game>
I beg your pardon, if it wasn't for me, you made a perfectly working script unless someone don't mess with the
gamelist.sml
file.
I'm so sorry, may I help you in any way ?
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.