27 Mar 2017, 19:38

Voilà un script python (besoin de la librairie "lxml") pour lister l'ensemble des jeux (et qques infos supplémentaires : date, genre, console ...). ça se base sur les fameux "gamelist.xml". Il suffit juste de configurer le chemin vers votre répertoire "roms", et ça produit un CSV (fichier excel) qui contient le tout.

#!/usr/bin/python
# -*- coding: utf-8 -*-
import os,glob,collections
from lxml.etree import pa**e

Game = collections.namedtuple('Game', 'console name genre date image path')

def genCSV(ll):
    with open("liste.csv","w+") as fid:
        for i in ll:
            fid.write(
                '%s;"%s";%s;%s\n' % (
                    i.console,
                    i.name,
                    i.genre or "",
                    i.date or ""
                )
            )

def listgames(p,opt="*"):

    def get(i,e):
        ll=i.xpath(e)
        return ll[0].text if ll else None

    ll=[]
    for f in sorted(glob.glob( os.path.join(p,opt,"gamelist.xml") )):
        for i in pa**e(f).xpath("//game"):
            fpath=os.path.dirname(f)
            console=os.path.basename(fpath)

            name,genre,date,image=get(i,"name"),get(i,"genre"),get(i,"releasedate"),get(i,"image")
            path = os.path.realpath(os.path.join(fpath,get(i,"path")))

            if genre and genre.strip().lower().startswith("bios"): continue     # zap bios file
            if image: image = os.path.join( fpath, image )                      # create realpath to image
            if date: date=date.strip()[:4]                                      # keep just the year

            ll.append( Game(console,name,genre,date,image,path) )
    return ll

if __name__ == "__main__":

    ll=listgames("/media/recalbox/roms")    # <--- just edit here !!!

    genCSV(ll)
    print( len(ll) )

ça devrait pouvoir marcher partout, pour peu que python (2.7) et la lib externe "lxml" soit installée.

C'est pratique pour moi, alors ça le sera peut être pour d'autres 😉