mmatyas / pegasus-frontend

A cross platform, customizable graphical frontend for launching emulators and managing your game collection.
http://pegasus-frontend.org
Other
1.25k stars 112 forks source link

LaunchBox Integration - Video Snap Support #496

Closed ecleese closed 4 years ago

ecleese commented 5 years ago

After watching a couple demo videos I see Pegasus supports video snaps but I don't see any appearing for my instance. Does the LaunchBox integration support video snaps or can it be added?

Thanks

mmatyas commented 5 years ago

It supports images only at the moment, but probably video support could be added too. I just didn't have any at the time I wrote the code, but will check them again.

mmatyas commented 5 years ago

Hm I tried to download videos for my games, but LaunchBox didn't find any. Am I supposed to set up something to make it work?

ecleese commented 5 years ago

Sign up for a free account with Emu Movies and enter your account credentials into the LaunchBox configuration.

Tools/Options/Legacy/Search/Emu Movies

https://emumovies.com/

mmatyas commented 5 years ago

Ah, so that's a requirement? I see, will try.

ecleese commented 5 years ago

A paid subscription includes higher quality video snaps but I don't believe it's a requirement any longer. A free account includes standard quality video snaps.

https://emumovies.com/acctupgrades/

mmatyas commented 5 years ago

Unfortunately LaunchBox didn't download videos even with the EmuMovies account :( It did download music files though, so I'll add support for that (though there's no theme yet that would actually play them).

However, if you can send me a file list or a sample of the videos folder, I think I could work with that too. I just need a general idea about the files, then I can add support for them.

ecleese commented 5 years ago

Game video files are stored here: LaunchBox/Videos/<Platform Name>/<Game Title>.mp4

Example:

- Game title: Bomberman
- Video snap: Bomberman (USA).mp4

Platform videos are stored here: LaunchBox/Videos/Platforms/<Platform Name.mp4>

Examples:

- TurboGrafx-16.mp4
- Capcom Play System 1.mp4
- Nintendo Game Boy Advance.mp4

Platform category videos are stored here: LaunchBox/Videos/Platform Categories/<Platform Category Name.mp4>

Examples:

- Consoles.mp4
- Arcade.mp4
- Handhelds.mp4

As long as the name matches the rom file name or the name of the game inside of LaunchBox, it automatically works in LaunchBox. I'm not sure how you'll implement this in Pegasus since the exact filename isn't stored in the platform XML files. But then again, neither are the image files so I'm sure you have a way to do it.

mmatyas commented 5 years ago

Thanks, so it's like the music files. I've pushed an update, could you try if it works correctly?

ecleese commented 5 years ago

I just downloaded the latest alpha12-37-g99a83e8 but don't see any video snaps or hear any music. Both work in LaunchBox for the games I've tested. lastrun.log doesn't have any useful debugging information regarding snaps and music. Anywhere else I can look for more information to help?

mmatyas commented 5 years ago

Thanks, found the issue (the file names were slightly different than the images), it should work now. The current default theme doesn't play music, but the music file detection is there so it's possible to create themes that play them.

ecleese commented 5 years ago

Video snap support is working but most games are not displaying the video so my guess is it's not recognizing the file name for most video snaps.

mmatyas commented 5 years ago

Could you send the list of all files under Videos/Sega Genesis/? Perhaps there is some file naming part I'm still missing. For the games that have missing videos, do they also miss the image assets too?

ecleese commented 5 years ago

Here is an example directory list: dirlist.txt

All images assets work fine, it's just the video snap for most games that don't display.

mmatyas commented 5 years ago

Thanks! That helped, I've just updated the video detection. Unfortunately there are cases where it can't be properly guessed which game does a video belong to, as the video file names don't really match the title or filename. For example, if a video is called Lost World, The - Jurassic Park (USA, Europe).mp4, it can't be automatically figured out that the game is actually called 'Jurassic Park 2: The Lost World', or that Alien 3 belongs to Alien³. However it did work for ~80% of the videos on the list when I tested. I wonder if LaunchBox stores video info somewhere...

ecleese commented 5 years ago

Video snaps are working much better now. I'll have to go through my own collection and rename ones that are too far off from the game title.

I dug through as many LaunchBox config files as I could to look for video snap location settings but never found any.

mmatyas commented 5 years ago

I guess this could be closed now. Feel free to report any further issues!

PlayingKarrde commented 5 years ago

I know this is closed but I just took another look at using Launchbox and there are way too many instances where this fails. I feel like there has to be a better solution than having to rename files.

Since the video is being set directly within the metadata (under Other > Game Video Path) can you not just use the file name directly from here instead of using the name of the rom? The direct XML tag is but for some reason it looks like it only gets set if it is set manually (which is very strange since all of mine have videos set there, but they don't get the tag set if it is filled in manually by the scraper.

Anyway, if you would be willing to reopen this for further investigation I would be very grateful!

-edit- Another thought I had would be to replace any special characters within the rom name (ie : or ' mostly) with _. This is what the files have which is why they are not showing up. I'm not sure if that would be an efficient way to do it though unless you are caching this information somewhere (likely no right?)

mmatyas commented 5 years ago

Hm so if you manually set a video through the UI it adds a video tag, but if you're using its scraping tool it doesn't? Interesting, if there's any tag like this then yes it could be used. I wonder if the same is true for images and music?

Special characters are replaced when searching for images and music, and used to be for videos too, but was disabled after it turned they can contain such characters, according to the file list above. Perhaps a different set of special chars is used there? Video downloading didn't work for me, so if you have a list of filenames produced by the downloader, without changes, that could help. Also XML examples for games with/without/before/after setting/unsetting video or other assets could be interesting too.

PlayingKarrde commented 5 years ago

https://pastebin.com/jVXvi9FD Here's a directory untouched.

https://pastebin.com/6QGSiPAV Untouched XML generated for that platform

https://pastebin.com/9ftmxc5N Changed the video path within Launchbox to point to a video file (look specifically for Castlevania II: Belmont's Revenge)

I think this does apply to music files also yes. The characters that I have noticed that are 100% replaced with underscores are colons and apostrophes. I think there is another but I will have to track that down a bit more.

Also, technically unrelated to the videos, but rather than open a new ticket, I am also unable to get my Windows playlist to show within Pegasus (and indeed if I change any of the names of the playlists (say Genesis to Mega Drive) they also don't show. Here's a pastebin of the windows playlist: https://pastebin.com/jHr4v9fx

mmatyas commented 5 years ago

Interesting, thanks! I think I can add support for VideoPath, yes. Have you tried other asset types? Looking into the depths of LB, apparently there should be MusicPath, ImagePath and ManualPath too.

Also what exactly happened to Pokémon? In the case of Pokemon_ Blue Version.mp4 what was replaced by _? A :? The <Title> doesn't seem to have any special chars. As for Pok‚mon Blue Version is that the real filename or just the Windows terminal unable to deal with "é"?

Feel free to open a new issue, it's not like there's a limit :)

PlayingKarrde commented 5 years ago

It looks like that's just the windows filelist command not interpreting é correctly yes. The filename is Pokémon Red Version.mp4 or whatever. VideoPath support would be great for sure but I think the best solution (or addition?) would be for Pegasus to convert the filename if it contains special characters and no videoPath is found. That's about the only way I can see to make this automated.

PlayingKarrde commented 5 years ago

Oh and yes the other media types you mention have the exact same naming conventions so if you were to add support for the video, it should also work for music and manuals also (assuming you have support for these). I was thinking I would add support for the music if it's there although it only looks like launchbox scrapes a few systems for this (or I should say only finds a few systems). Still, it might be a nice option to add if people really wanted to go all out with their setups.

spektor56 commented 5 years ago

You can always give my exporter plugin a try: https://github.com/spektor56/PegasusExportPlugin/releases

made it back in June and has worked quite well for my simple collection. It uses launchbox's own API to find all the proper media so it will never break.

mmatyas commented 5 years ago

My only problem with the filenames is what counts as a special character. According to the file list above, it seemed the videos can contain special chars, yet the one posted by @PlayingKarrde doesn't have them (eg. 's). I suppose @ecleese didn't manually set 700 game videos, but just in case I'd be interested if they have been touched in any way.

PlayingKarrde commented 5 years ago

@mmatyas What I find interesting is that the dir you listed actually has the names listed as (for example) Contra - Hard Corps, whereas mine is Contra: Hard Corps, which would then get changed to Contra_ Hard Corps for the video. So I suspect that LaunchBox changed the way it named it's games and in doing so needed to come up with a different naming system for the files (since Windows doesn't allow these special characters).

@spektor56 I was aware of this plugin a while ago but never actually looked at it (too busy to deal with theme work unfortunately) but I just tried it out and it's really great! Thanks for this. I would still ideally like to have LaunchBox support fully figured out due to this requiring just one extra step, but it will be super useful for when I move my setup to other systems (ie Shield, Android, Rpi etc). Thanks again.

spektor56 commented 5 years ago

LaunchBox has a filehelper class that renames files:

EX: `private static readonly string[] reservedWords = new string[25] { "CON", "PRN", "AUX", "CLOCK$", "NUL", "COM0", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT0", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" }; private static readonly string invalidChars = Regex.Escape(new string(Path.GetInvalidFileNameChars()) + "'");

public static string CoerceValidFileName(string filename) { string pattern1 = string.Format((IFormatProvider) CultureInfo.InvariantCulture, "[{0}]+", (object) FileHelper.invalidChars); string input = Regex.Replace(filename, pattern1, "_"); string[] strArray = input.Split('.'); bool flag = false; foreach (string str in strArray) { foreach (string reservedWord in FileHelper.reservedWords) { if (reservedWord.Equals(str, StringComparison.OrdinalIgnoreCase)) { flag = true; break; } } if (flag) break; } if (flag) { foreach (object reservedWord in FileHelper.reservedWords) { string pattern2 = string.Format((IFormatProvider) CultureInfo.InvariantCulture, "^{0}\.", reservedWord); input = Regex.Replace(input, pattern2, "reservedWord.", RegexOptions.IgnoreCase); } } return input; }`

mmatyas commented 5 years ago

@PlayingKarrde I've just made a build where I've restored the original video searching code, could you check how it performs?

PlayingKarrde commented 5 years ago

@mmatyas Looks like it's all working well on my end - thanks!

mmatyas commented 5 years ago

That's nice to hear, yet it's interesting since it was changed especially due to the file list above... well, I'll assume @ecleese has them set as VideoPaths then, I'll see if I can add support for it the next days, then add this autodetection change too.

mmatyas commented 4 years ago

@PlayingKarrde could you check this build: pegasus-fe_alpha13-4-gccfa57f_win-mingw-static.zip? It has VideoPath and MusicPath support in it.

PlayingKarrde commented 4 years ago

@PlayingKarrde could you check this build: pegasus-fe_alpha13-4-gccfa57f_win-mingw-static.zip? It has VideoPath and MusicPath support in it.

I wasn't able to test the musicpath since I haven't set it up in my theme yet but the video path is giving me this error when I set it manually:

DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80004005 ()

However it works fine still when not set.

mmatyas commented 4 years ago

It seems the DirectShowPlayerService::doSetUrlSource lines appear when the file was not found. I've added a check for that and logging if that's the case: pegasus-fe_alpha13-5-g692d5fe_win-mingw-static.zip

PlayingKarrde commented 4 years ago

It seems like it's not reading that value at all now. It's simply playing the default video no matter what is placed in the video tag.

mmatyas commented 4 years ago

Interesting; you should now see a new message in the log if the file could not be loaded.

PlayingKarrde commented 4 years ago

Nothing is being logged. It's finding A video, just not the one in the videopath which is why it's maybe not logging anything?

mmatyas commented 4 years ago

Ok I made it some more verbose: pegasus-fe_alpha13-6-g4d17468_win-mingw-static.zip

PlayingKarrde commented 4 years ago

haha ok my bad it may have been logging it before too I didn't realise it was at the game loading section.

Anyway I'm not getting printouts for the title I'm testing. For the ones that don't have a video at all I'm getting

2019-10-14T14:33:09 [i] OKAY LOOK I'M TRYING TO OPEN THIS THINGY: "Videos\Nintendo Entertainment System\Balloon Fight.mp4" 2019-10-14T14:33:09 [i] BUT IT JUST DOESN'T EXISTS! 2019-10-14T14:33:09 [w] LaunchBox: asset path Videos\Nintendo Entertainment System\Balloon Fight.mp4 doesn't exist, ignored

Also, on a side note, I've noticed that for the ones that don't work (like the above) I'm still getting something back in my gameData.assets.videos.length check since it's showing my preview button despite there being no video. This isn't a new thing with your tests, but it is a symptom of moving to launchbox as a source so possibly related?

mmatyas commented 4 years ago

Ah so you have relative paths, I see; I can add support for it tomorrow. The "special logging" happens only for Video/MusicPath.

I'm still getting something back in my gameData.assets.videos.length

Hm I wonder what's in gameData.assets.videos then.

PlayingKarrde commented 4 years ago

Actually I'm getting 0 as the length so it's most likely something I'm doing wrong in my check. Don't worry about that I'll consider that a bug for me.

mmatyas commented 4 years ago

Another build, relative paths should now work: pegasus-fe_alpha13-7-gd961850_win-mingw-static.zip

PlayingKarrde commented 4 years ago

Yep appears to be working fine now. Thanks for taking the time with this one. Makes a big difference.