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

Easy way to add video and marquees tags in your gamelist for video support.

Scheduled Pinned Locked Moved Ideas and Development
videogamelistmarquees
40 Posts 12 Posters 26.9k 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.
  • N
    Nismo
    last edited by Nismo 4 Feb 2017, 02:09 26 Dec 2016, 05:01

    Since new versions have video support maybe it's a pain for some people to add video and marquees tags by hand in their gamelist.xml, so here you have an easy way.

    This will only work in windows 7 and windows 10. Windows vista not tested. This will not work on windows XP.

    • On windows create a new text document.

    Paste this code:

    $doc = [xml] (Get-Content -raw gamelist.xml)
    
    foreach ($gameEl in $doc.DocumentElement.game) { 
      # Use -replace to extract the filename without extension from the 
      # path contained in the <path> element.
      $gameName = $gameEl.path -replace '^.*/(.*)\..*$', '$1'
      # Append elements 'video' and 'marquee', but only if they don't already
      # exist.
      if ($null -eq $gameEl.video) {
        $gameEl.AppendChild($doc.CreateElement('video')).InnerText = "./videos/${gameName}.mp4"
      }
      if ($null -eq $gameEl.marquee) {
        $gameEl.AppendChild($doc.CreateElement('marquee')).InnerText = "./marquees/${gameName}.png"
      }
    }
    rename-item gamelist.xml -newname oldgamelist.xml
    $writer = [System.IO.StreamWriter] "gamelist.xml"
    $doc.Save($writer)
    $writer.Close()
    
    

    This will work for all systems if you have videos and marquees folders inside your roms folder, for example:
    rom/snes/videos and roms/snes/marquees

    or

    roms/megadrive/videos and roms/megadrive/marquees

    Or you can change the paths to fit your path for videos and marquees:

    "~/.emulationstation/roms/snes/Videos/${gameName}.mp4"
    
    "~/.emulationstation/roms/snes/Marquees/${gameName}.png"
    
    • Save the document.

    • Rename the extension from .txt to .ps1 for example "addvideo&marquees.ps1"

    Now you only need to place it inside a folder containing your gamelist.xml.

    • Then click right mouse button on the file addvideo&marquees.ps1 and select "exec with powershell".

    Your old gamelist it's not deleted, your previous gamelist it's renamed to oldgamelist.xml.

    • A new file "gamelist.xml" will be created with the tags.

    It takes the name from the <path> tag from your gamelist.xml, so then you need a program like fatmatch to match your videos and marquees with your rom name.

    Keep in mind than this will create video and marquees tags for all games in your gamelist, even if the videos or marquees doesn't exist.

    Also keep in mind that i have all my marquees in png format, so if you use some jpg files you will need a batch image converter or something similar...
    -------------------------------------------------------------------------------------------------------------------------

    Issues:
    On some computers maybe you can get an error: "cannot be loaded because running scripts is disabled on this system".

    Easy fix:

    1- Open a text document and place this inside:

    powershell -ExecutionPolicy ByPass -File addvideomarquees.ps1
    

    Make sure the name of .ps1 file is the same than in the code above and save changes.

    2- Rename the .txt extension to .bat

    3- Place it in the same folder than addvideomarquees.ps1 and do right click on the .bat file and select " exec as administrator".

    Hope this helps. Regards.

    1 Reply Last reply Reply Quote 2
    • E
      ebtalk
      last edited by 26 Dec 2016, 06:23

      @Nismo
      One thing it does is cuts off remaining characters after a period.

      For instance. If the file name is ./Zany Golf (USA, Europe) (v1.1).zip

      The mp4 name will come back Zany Golf (USA, Europe) (v1.mp4

      It cuts off everything after. Nothing major and easy to clean up but something to note. for people.

      Otherwise thanks for the script. It has saved so much time.

      1 Reply Last reply Reply Quote 0
      • E
        ebtalk
        last edited by 26 Dec 2016, 06:41

        I'm getting this error now when I try to run it in my gbc folder.

        0_1482734454176_error.png

        N 1 Reply Last reply 26 Dec 2016, 06:58 Reply Quote 0
        • N
          Nismo @ebtalk
          last edited by Nismo 26 Dec 2016, 06:58

          @ebtalk It should work perfectly, seems you have an error: the given path's format is not supported.

          Maybe you doesn't edit the file the right way. Take a look again, or tray to use it in another folder.

          It cuts afer the point because the code was thinking that after the point is the extension of the file.

          E 1 Reply Last reply 26 Dec 2016, 07:05 Reply Quote 0
          • E
            ebtalk @Nismo
            last edited by 26 Dec 2016, 07:05

            @Nismo So weird. It worked in my mastersystem folder. Then the very next folder I try it errors out. And continues to error out in any other folder I try it in. No change was made besides the mastersystem was changed to gbc.

            N 1 Reply Last reply 26 Dec 2016, 07:07 Reply Quote 0
            • N
              Nismo @ebtalk
              last edited by Nismo 26 Dec 2016, 07:07

              @ebtalk Please can you post here the code on your videofix.ps1?

              1 Reply Last reply Reply Quote 0
              • E
                ebtalk
                last edited by Floob 26 Dec 2016, 07:10

                $doc = [xml] (Get-Content -raw gamelist.xml)
                
                foreach ($gameEl in $doc.DocumentElement.game) { 
                  # Use -replace to extract the filename without extension from the 
                  # path contained in the <path> element.
                  $gameName = $gameEl.path -replace '^.*/([^.]+)\..*$', '$1'
                  # Append elements 'video' and 'marquee', but only if they don't already
                  # exist.
                   if ($null -eq $gameEl.video) {
                    $gameEl.AppendChild($doc.CreateElement('video')).InnerText = "~/.emulationstation/roms/gbc/snap/${gameName}.mp4"
                  }
                  if ($null -eq $gameEl.marquee) {
                    $gameEl.AppendChild($doc.CreateElement('marquee')).InnerText = "~/.emulationstation/roms/gbc/marquee/${gameName}.png"
                  }
                }
                
                
                $writer = [System.IO.StreamWriter] "$PWD/newFile.xml"
                $doc.Save($writer)
                $writer.Close()
                
                N 1 Reply Last reply 26 Dec 2016, 07:16 Reply Quote 0
                • N
                  Nismo @ebtalk
                  last edited by Nismo 26 Dec 2016, 07:16

                  @ebtalk Seems the code it's ok, i think the problem it's because the double back slash in the path you are trying to save, try to do it in another folder that not contains double back slash "//" in their path.

                  E 2 Replies Last reply 26 Dec 2016, 07:21 Reply Quote 0
                  • E
                    ebtalk @Nismo
                    last edited by 26 Dec 2016, 07:21

                    @Nismo Where is the double backslash. I don't see it in the code.

                    All my roms are in folders within:

                    \RETROPIE\roms\ when i'm viewing from my PC

                    so there's \RETROPIE\roms\mastersystem which worked
                    then \RETROPIE\roms\gbc - didn't work
                    \RETROPIE\roms\atari7800 - didn't work

                    1 Reply Last reply Reply Quote 0
                    • E
                      ebtalk @Nismo
                      last edited by 26 Dec 2016, 07:24

                      @Nismo in the following code: $writer = [System.IO.StreamWriter] "$PWD/newFile.xml"

                      I took out $PWD and it worked.

                      N 2 Replies Last reply 26 Dec 2016, 07:27 Reply Quote 0
                      • N
                        Nismo @ebtalk
                        last edited by Nismo 26 Dec 2016, 07:27

                        @ebtalk I told you, it's because your folder path where you are trying to save the newFile.xml conflicts.

                        The double back slash is not in the code, it's on your path. See the image with the error you send to me before.

                        Anyway your solution it's working.

                        I have edit the first post with new code so you don't need to edit path if you have videos and marquees folders inside your roms folder.

                        I also removed $PWD to avoid path errors.

                        1 Reply Last reply Reply Quote 0
                        • N
                          Nismo @ebtalk
                          last edited by Nismo 2 Nov 2017, 16:45 10 Feb 2017, 23:21

                          @ebtalk I edited the code, now the "missing characters after dot" bug it's fixed.

                          hooperreH 1 Reply Last reply 20 Feb 2017, 23:16 Reply Quote 1
                          • hooperreH
                            hooperre @Nismo
                            last edited by 20 Feb 2017, 23:16

                            @Nismo Would love to add these to my repertoire and tend to do this (mostly) manually, so I appreciate this tool.

                            Do y'all have a theme that you recommend? I've never downloaded a theme from github as I'm not sure how. I've only ever done it from the RetroPie Menu.

                            4B ~ RPi PSU 5.1V / 3.0A ~ 32GB SanDisk microSD ~ 128GB USB

                            1 Reply Last reply Reply Quote 0
                            • A
                              alaindesjardins
                              last edited by 21 Mar 2017, 03:14

                              Where and what do I add if I want to rename the gamelist.xml to oldgamelist.xml at the end of the script and then save the newfile.xml to gamelist.xml?

                              Also, I run into a problem with all my videos and marquees being in the arcade folder instead, but all the fba games are in their respective folder (/home/pi/RetroPie/roms/fba/". I suppose I could add the full path to that script before I run it... is the correct syntax "~/home/pi/RetroPie/roms/arcade/snap/${gameName}.mp4"? Is there a better way of doing it?

                              I'm kind of new to file paths in linux and powershell scripts. Thanks!

                              N 1 Reply Last reply 21 Mar 2017, 04:32 Reply Quote 0
                              • N
                                Nismo @alaindesjardins
                                last edited by 21 Mar 2017, 04:32

                                @alaindesjardins Fixed the code in first post to fix the changes you requested about renaming previous gamelist to oldgamelist and newfile it's now gamelist.xml.

                                About the path, yes, that's the way to change the path.

                                Regards.

                                1 Reply Last reply Reply Quote 0
                                • A
                                  alaindesjardins
                                  last edited by 31 Mar 2017, 04:37

                                  I don't know if you can look at the comparison differences but It's changing the output format of the scrapers and as you can see it doesn't seem to keep things proper. I would expect it to only add the video and marquee line but it's doing much more than that.

                                  I suppose I can load it up and see if it makes a difference in how it displays everything in emulation station but, is there another way of doing it so it doesn't screw up the whole formatting?

                                  1 Reply Last reply Reply Quote 0
                                  • A
                                    alaindesjardins
                                    last edited by 31 Mar 2017, 04:41

                                    I would expect it to look like this if that makes sense. The lines added have a blue dot on the line number.

                                    N 1 Reply Last reply 31 Mar 2017, 04:43 Reply Quote 0
                                    • N
                                      Nismo @alaindesjardins
                                      last edited by Nismo 31 Mar 2017, 04:43

                                      @alaindesjardins I don't see the differences, what's the problem if the xml works ok?

                                      I see the new gamelist.xml more clean...

                                      1 Reply Last reply Reply Quote 0
                                      • A
                                        alaindesjardins
                                        last edited by 31 Mar 2017, 04:49

                                        Yeah, I won't worry about it. My OCD targets the fact that the description is all different because the formatting it all screwed up after I run the powershell script.

                                        I'll try not to look at it, I just wish there was an easier way to append the <video> and <marquee> lines without changing the rest. Maybe I'll see if the sselph scraper can add that data in or request it be worked in. I just figured out how to scrape using sselph scraper and my own images/artwork so I was able to generate a gamelist.xml with metadata. Adding the videos and wheel art was the only thing left which your script does.

                                        Thanks!

                                        N 1 Reply Last reply 31 Mar 2017, 05:10 Reply Quote 0
                                        • N
                                          Nismo @alaindesjardins
                                          last edited by 31 Mar 2017, 05:10

                                          @alaindesjardins I don't know a easiest way to do it. Sorry maybe it's a stupid question but what is OCD?

                                          1 Reply Last reply Reply Quote 0
                                          • First post
                                            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.

                                            [[user:consent.lead]]
                                            [[user:consent.not_received]]