Game statistics
-
@WeirdH said in Game statistics:
this would make an awesome addition to a theme, if it could be incorporated.
I totally agree. I don't know what support themes have to add custom data fields. I guess that is up to the theme, emulation station or pegasus devs et.c. to figure out.
-
@mitu Do you think this would fit somehow into retropie? And maybe you know who else might have a say if it could be part of the system.
Maybe it could fit into a menu entry in the emulation station start menu that lists your statistics? -
@langest If you'd like to add something to RetroPie, just create a Pull Request on the Github's project.
Personally, I think it's nice, but it's not something that I see included in the base image. Don't let this discourage you from developing it further, though :). -
I added support for using skyscraper cache for getting rom names to get a prettier print. However, it is much slower. I haven't profiled the implementation, but I might optimize this at some point. Also, it doesn't seem to work for all the systems. Probably has to do with which files skyscraper uses to calculate the sha1 sum.
If you want to try it:retro-stats/game_stats.py -f ../../RetroPie/game_stats.log -t ~/.skyscraper/cache/
Pass the path to skyscraper cache to the
-t
parameter. -
@langest I see this as usefull information for the MAME RoWs ;)
Hmmm.... I think this could be made better by using bash dialogs.
So you parse your output to info box and you can scroll and select with joypad.
Then I'm sure you will hit a wider audience. If you can do some coding in python then you can also set some bash scripts ;) -
@cyperghost
Yeah, that could be the next step. You don't really need to rewrite the script in bash though.
You can call the python script from bash and just format the output nicely into an info box. Would be a nice project to learn some bash.Seems like the sha1 sum is different for the arcade games as well. Maybe has something to do with them being ziped.
I think I will try to fix this problem before I create a bash module.Maybe @muldjord can point me in the right direction to figure out how and for which files skyscraper calculates the sha1? (compressed files and .cue are the ones that doesn't work)
-
@langest said in Game statistics:
You don't really need to rewrite the script in bash though.
This wasn't my intention at all ;)
You explainded later the correct situationYou can call the python script from bash and just format the output nicely into an info box. Would be a nice project to learn some bash.
👍
-
@langest Depends on the module. For ScreenScraper it does a sha1, md5, crc32 and exact filename search. If either of these return a unique result, ScreenScraper will hand back the game data. For the other modules it is filename search based. So if you have a good filename, you will have pretty good results aswell. So, for instance, a filename of "abrq10.zip" is a poor name, as it makes no sense to search for. If instead it is "Game_name_1.zip" is will work a lot better. But there are some nifty tricks on top of that which I do. For both mame and scumm names I have a lookup which converts the names such as "Golden Axe" instead of "goldnaxe" (or whatever it's called).
All of the modules are described here, which should provide at least some insight as to how each work when looking up roms.
Lastly, the CD based platforms are notoriously hard to scrape, as they often have multifiles per game and / or are based on .cue files which can vary since they are often user generated. So for these platforms even ScreenScraper is highly reliant on the exact filenames instead. So it will need to exactly match, for instance, "game_name.cue" inside of ScreenScrapers database to work.
-
@muldjord
Thanks for the informative answer.What I am doing is parsing the db.xml files. And in there the entries are stored based on sha1sums. When I use sha1sum on a rom (and when I use it in my python program I get the same result):
$ sha1sum roms/arcade/joust.zip 48c27d4b623b83e3e724ed348b40ff6193b92b1e roms/arcade/joust.zip
It is different from the sum in cache/arcade/db.xml
<resource sha1="ed1455f34143e6781dc443c064ca7d69e4093cff" type="title" source="openretro" timestamp="1562952656836">Joust</resource>
Same with .cue (understandably)
$ sha1sum roms/psx/Bishi\ Bashi\ Special\ 2\ \(Japan\).cue 3d1fb64cd75afd208f7eedb3059a0b0a09fbb78a roms/psx/Bishi Bashi Special 2 (Japan).cue
<resource sha1="cdd966e49743a5571eeb81d249d6a3abefbfb408" type="title" source="thegamesdb" timestamp="1563723954281">Bishi Bashi Special 2</resource>
It works fine for files that are "plain" roms:
$ sha1sum roms/gbc/Wario\ Land\ 3\ \(World\)\ \(En\,Ja\).gbc bb7877309834441fd03adb7fa65738e5d5b2d7ba roms/gbc/Wario Land 3 (World) (En,Ja).gbc
<resource sha1="bb7877309834441fd03adb7fa65738e5d5b2d7ba" type="title" source="openretro" timestamp="1563722070330">Wario Land 3</resource>
Do you know why this happens?
-
@langest imho the FBN/MAME games or fixed by their names.
pacman.zip
is always PACMAN independent from ROM version.About PSX games .... if you check the bin/img file. Did you then get a result?
-
I also figured out why using skyscraper data is "slow". It is because you might be reading and hashing a big file, dreamcast rom et.c.
And the IO is what takes the most time. I have added a function cache to reduce this problem. But it would probably be best to cache all the results on disk so you don't have to recalculate it every time you run restart the program. -
@langest said in Game statistics:
But it would probably be best to cache all the results on disk so you don't have to recalculate it every time you run restart the program.
Isn't Skyscraper already doing this ? You could compare the
timestamp
with the file date and rely on Skyscraper's already built cache - of course, for entries which are present there (i.e. without roms added since the last scraping session). -
@langest Ah, you mean the cache rom id's. Yes, they are a mix of sha1 sums of the actual rom data and sha1 sums of filenames, depending on whether the input is a script (or zipped, read on for explanation) or an actual rom. So in the case of .cue files for instance, it is a sha1 of the filename. If the files are more than 50 megs, they are also id'd by the sha1 of their filenames for speed optimization. But please know that the cache rom id's are completely separatate from the checksums I do when using the ScreenScraper module. In fact I was thinking of renaming the "sha1" attribute in db.xml entirely to just me "id" as to avoid confusion. But then that would break backwards compatibility and the db.xml files aren't means to be edited by hand anyway. It should always be edited with
--cache edit
.And there's reason behind the madness. I could just id the files by filenames. But some people like to have games in subfolders and potentially have two games with the same filename under the same platform even if the games are different. To avoid this I use the sha1 checksum instead. But of course this doesn't make sense for scripts, which change often. So for those I have to use the sha1 of the filename instead. I also always use the sha1 of the filename for zipped files, since people might unzip them and rezip them. This would also break the id for that game. So yeah, there's some considerations behind the madness, just to let you guys know. I'm not saying it's the best way, but it's kind of locked in now, as to avoid breaking people's caches, and it works well (although slow, as you point out, for the bigger roms) so.
-
@langest said in Game statistics:
I also figured out why using skyscraper data is "slow". It is because you might be reading and hashing a big file, dreamcast rom et.c.
And the IO is what takes the most time. I have added a function cache to reduce this problem. But it would probably be best to cache all the results on disk so you don't have to recalculate it every time you run restart the program.I actually thought about doing this. Do a lookup if the file hasn't changed since last scrape. Something for 4.0 or 3. 5 I guess.
-
@muldjord
That answers my question.
It seems this leaves two options for fixing the issue.- Implement the same hashing and calculation of all the id's as they are implemented in skyscraper so I can use the db.xml as a dictionary.
or - Extend skyscraper to cache rompath -> id/sha1sum in a file given an argument.
I can't see why 1 would be a useful option, that would be double work and I don't want to extend the stats tool to have scraper functionality.
2 makes a lot of sense to me. It opens up the db.xml data to be used with external tools and it would save time if you were to run skyscraper again. I imagine this wouldn't be too complicated to implement.
Is this something you would be able to implement in the near future or should I consider taking a look? - Implement the same hashing and calculation of all the id's as they are implemented in skyscraper so I can use the db.xml as a dictionary.
-
@langest said in Game statistics:
Is this something you would be able to implement in the near future or should I consider taking a look?
I'd go with option 1 in this case. I'm not currently looking for contributions and I'm eager to work on this feature myself as it's an interesting problem (the checksum lookups) with high optimization potential. But I am not able to give you an ETA.
EDIT: Just a thought: Is it not a bit much to make this rely so much on Skyscraper's db.xml (unless it's just one of several lookup methods you plan to implement)? Just my 5 cents.
-
@muldjord
Alright,
Maybe I could suggest adding the rom path to the Resource struct
https://github.com/muldjord/skyscraper/blob/225136b245c1fca4936062f1fb5430691beed283/src/cache.h#L40
You already seem to have it in the GameEntrys path member. And then together with timestamp it would be easy to see if you need to update the resource.
You probably can't save the path to sha1 mapping in the same resource nodes that the rest of the resources use, but it shouldn't be a problem to introduce a new node either in db.xml or in a separate file. -
@langest I promise it will be well thought through and backwards compatible in the sense that it will convert old entries if needed on-the-fly. If anything this has made me realize that now is probably the time to look into this.
EDIT: A file location for the rom is not very useful. If you move your files to a different directory (or a different system entirely, or someone sends you their cache), they need to still be identifiable. This has to be contained to the file itself, so modification time makes sense for this purpose.
I might also change it to always only do the checksum on the first 512 k of data instead of the entire rom. This will make it quite a lot faster to begin with. And combined with the lookup table this will prove a significat optimization. And for anyone following this, I will of course make sure this will convert "old" cache id's on the fly, so it won't break anything. -
now is probably the time to look into this
Glad to hear it. :)
checksum on the first 512 k of data instead of the entire rom
This sounds like a really good idea.
-
@muldjord said in Game statistics:
Just a thought: Is it not a bit much to make this rely so much on Skyscraper's db.xml (unless it's just one of several lookup methods you plan to implement)? Just my 5 cents.
I implemented it as separate module. You can easily replace it with something else to get the rom meta information. You just plug in a new
get_title_info(som_path: str, system: str) -> title
. The reason why I depend on skyscraper is because I don't want to build a scraper, so I need to depend on at least one other scraper to get the meta info. And skyscraper is the one I am using on my system, so it makes sense for me to use it. I understand that the db.xml is not supposed to be part of an external api (in its current state) and that because of this it might seem a bit strange to depend on it.
You can use the tool without any meta information but then the title be whatever your rom name is. And at least for arcade this could be somewhat confusing.
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.