• Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login
RetroPie forum home
  • Recent
  • Tags
  • Popular
  • Home
  • Docs
  • Register
  • Login

[SCRIPT] RetroPie Limit Last Played Games

Scheduled Pinned Locked Moved Projects and Themes
shell scriptlast playedgameslimit
57 Posts 5 Posters 6.0k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C
    cyperghost @hiulit
    last edited by 10 Sept 2018, 18:51

    @hiulit The restart file
    Because ES entitiy deletes the file on restart and if it was created by root it won't work

    H 1 Reply Last reply 10 Sept 2018, 18:58 Reply Quote 1
    • H
      hiulit @cyperghost
      last edited by 10 Sept 2018, 18:58

      @cyperghost got it. Thanks! I'll try it ;)

      My little contributions to the RetroPie project:

      • Shell-Script-Boilerplate
      • Fun-Facts-Splashscreens
      • Limit-Last-Played-Games
      1 Reply Last reply Reply Quote 0
      • M
        MadHorse
        last edited by 10 Sept 2018, 19:38

        @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 same lastplayed date and time unless someone manually edit the file and make some mistakes, so probably is not a big deal.

        H 1 Reply Last reply 10 Sept 2018, 20:10 Reply Quote 1
        • H
          hiulit @MadHorse
          last edited by 10 Sept 2018, 20:10

          @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.

          My little contributions to the RetroPie project:

          • Shell-Script-Boilerplate
          • Fun-Facts-Splashscreens
          • Limit-Last-Played-Games
          M 1 Reply Last reply 10 Sept 2018, 21:26 Reply Quote 0
          • M
            MadHorse @hiulit
            last edited by 10 Sept 2018, 21:26

            @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 the name and the path, by doing this i also duplicated the lastplayed 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.

            H 1 Reply Last reply 10 Sept 2018, 21:50 Reply Quote 1
            • H
              hiulit @MadHorse
              last edited by hiulit 9 Oct 2018, 22:53 10 Sept 2018, 21:50

              @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

              My little contributions to the RetroPie project:

              • Shell-Script-Boilerplate
              • Fun-Facts-Splashscreens
              • Limit-Last-Played-Games
              1 Reply Last reply Reply Quote 0
              • M
                MadHorse
                last edited by 11 Sept 2018, 06:27

                @hiulit No problem mate, I will be happy to test the new version.
                Thank you and happy holiday :)

                1 Reply Last reply Reply Quote 0
                • H
                  hiulit
                  last edited by 12 Sept 2018, 11:28

                  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.

                  My little contributions to the RetroPie project:

                  • Shell-Script-Boilerplate
                  • Fun-Facts-Splashscreens
                  • Limit-Last-Played-Games
                  1 Reply Last reply Reply Quote 1
                  • H
                    hiulit
                    last edited by 12 Sept 2018, 11:42

                    Updated the documentation for v2.1.0 - 2018-09-12 in the first post.

                    My little contributions to the RetroPie project:

                    • Shell-Script-Boilerplate
                    • Fun-Facts-Splashscreens
                    • Limit-Last-Played-Games
                    1 Reply Last reply Reply Quote 0
                    • M
                      MadHorse
                      last edited by 12 Sept 2018, 19:15

                      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 it Failed 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 the XSLT-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 same lastplayed 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 ?

                      H 2 Replies Last reply 12 Sept 2018, 20:16 Reply Quote 0
                      • H
                        hiulit @MadHorse
                        last edited by 12 Sept 2018, 20:16

                        @madhorse whooops, it's getting tricky! Haha! Would you mind copying a couple of your gamelists into pastebin.com or something similar so I can test with real game lists? In the virtual machine where I develop the scripts I only have a couple of games to test.

                        The first issue involving the characters, I think I can escape them so it doesn't crash. The second one needs a little bit more of testing.

                        Thanks a lot for helping me test the script, btw!

                        My little contributions to the RetroPie project:

                        • Shell-Script-Boilerplate
                        • Fun-Facts-Splashscreens
                        • Limit-Last-Played-Games
                        C 1 Reply Last reply 12 Sept 2018, 21:05 Reply Quote 0
                        • H
                          hiulit @MadHorse
                          last edited by 12 Sept 2018, 20:18

                          @madhorse your Daphne and Amiga game lists would be enough, I think.

                          My little contributions to the RetroPie project:

                          • Shell-Script-Boilerplate
                          • Fun-Facts-Splashscreens
                          • Limit-Last-Played-Games
                          M 1 Reply Last reply 12 Sept 2018, 20:47 Reply Quote 0
                          • M
                            MadHorse @hiulit
                            last edited by 12 Sept 2018, 20:47

                            @hiulit said in [SCRIPT] RetroPie Limit Last Played Games:

                            @madhorse your Daphne and Amiga game lists would be enough, I think.

                            No Problem,
                            This is the Daphne Gamelist and this is the Amiga Gamelist

                            Thanks a lot for helping me test the script, btw!

                            Thanks to you for your work and for helping us to Limit the Last Played list :)

                            1 Reply Last reply Reply Quote 1
                            • C
                              Clyde @hiulit
                              last edited by 12 Sept 2018, 21:05

                              @hiulit said in [SCRIPT] RetroPie Limit Last Played Games:

                              @madhorse whooops, it's getting tricky! Haha!

                              In my head, I heard your words in the voice of the first Doctor Who. Especially the laughter! 😄

                              1 Reply Last reply Reply Quote 1
                              • H
                                hiulit
                                last edited by hiulit 13 Sept 2018, 09:31

                                Retropie Limit Last Played Games v2.1.1 is out!

                                CHANGELOG

                                Fixed

                                • Issue with duplicate game names but different <lastplayed> tags in gamelist.xml. Now the script takes both the game name and its <lastplayed> tag to avoid duplicates. If there are more than one game with same name and <lastplayed> tag, the script won't work.
                                • Escape game names with single quotes in gamelist.xml.
                                • Escape ampersands (&) in gamelist.xml.

                                @MadHorse all your issues should now be fixed! :P

                                EDIT: Until you find more, hehe! ;)

                                My little contributions to the RetroPie project:

                                • Shell-Script-Boilerplate
                                • Fun-Facts-Splashscreens
                                • Limit-Last-Played-Games
                                1 Reply Last reply Reply Quote 1
                                • M
                                  MadHorse
                                  last edited by 13 Sept 2018, 18:35

                                  AND THE WINNER IS @hiulit :D

                                  You did it man, I made some fast test with the new version and it's working perfectly, it' s awesome.
                                  Now, because I'm a BAD guy, i tried to trick the script and made a gamelist with 2 exactly duplicate games, same name and same date, obviously the script gave an error, and then it completed the work.

                                  Anyway, if someone has messed up the gamelist.xml so badly is what I-(he) deserve :)))

                                  You are the best, thank you for your hard work, i love your script.

                                  1 Reply Last reply Reply Quote 0
                                  • M
                                    MadHorse
                                    last edited by 19 Sept 2018, 21:12

                                    Hi @hiulit I'm here again, unfortunately for another bug.
                                    Usually in the gamelist.xml the & character is written as &amp;, probably there is something tricky with the escape of & because after you execute the script, it will transform it to &amp;amp;, if you execute it another time you will get &amp;amp;amp;
                                    I'm so sorry to bring you bad news.

                                    H 1 Reply Last reply 20 Sept 2018, 08:51 Reply Quote 1
                                    • H
                                      hiulit @MadHorse
                                      last edited by 20 Sept 2018, 08:51

                                      @madhorse Hey! Yeah, totally my bad... Such a noob thing to do :( Or in this case, NOT to do..

                                      I only check for unescaped & because in one of your gamelist.xml there were a lot of them and the software that parses the xml, which is xmlstarlet, was crashing because of that. So I assumed that scrapers would always add the unescaped & and I didn't take into account that it was possible for some scrapers to have the escaped version &amp;.

                                      I'll fix it asap.

                                      Thanks for the heads up! ;)

                                      My little contributions to the RetroPie project:

                                      • Shell-Script-Boilerplate
                                      • Fun-Facts-Splashscreens
                                      • Limit-Last-Played-Games
                                      1 Reply Last reply Reply Quote 0
                                      • H
                                        hiulit
                                        last edited by 20 Sept 2018, 13:43

                                        New RetroPie Limit Last Played Games 2.1.2 is out!

                                        @MadHorse if you could give it a try.... hehe! ;) Thanks!

                                        CHANGELOG

                                        [2.1.2] - 2018-09-20

                                        Fixed

                                        • Escape special characters function.

                                        Added

                                        • Validate XML function.

                                        My little contributions to the RetroPie project:

                                        • Shell-Script-Boilerplate
                                        • Fun-Facts-Splashscreens
                                        • Limit-Last-Played-Games
                                        1 Reply Last reply Reply Quote 1
                                        • M
                                          MadHorse
                                          last edited by 20 Sept 2018, 22:10

                                          @hiulit hi, I made a quick test and now the & and &amp; aren't changed, great work.
                                          I will do some more test hoping to not find more bugs, I don't want you to hate me :)

                                          Thank you very much, you and your script are awesome

                                          H 1 Reply Last reply 21 Sept 2018, 10:49 Reply Quote 1
                                          44 out of 57
                                          • First post
                                            44/57
                                            Last post

                                          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.

                                            This community forum collects and processes your personal information.
                                            consent.not_received