Several weeks back had some free weekend cycles and spent some time developing a plugin for launching emulators through Plex. I ran into some obstacles (see [here](http://forums.plexapp.com/index.php?/topic/8739-help-with-plex-exit-code-application-behavior/)) and have since not had a chance to revisit the code.
I'm attaching my code here in hopes that someone else can take it over and make something of it. It sorta works now in that it lists your roms (located at ~/Games/ConsoleName/*). It also downloads the cover art and game description from GiantBomb.
The problem is that it if you use a 360 controller to control Plex, when you launch an emulator, Plex still has control of the controller input, so that if you play a game, Plex interprets all the button presses. One possible workaround I tried was to have the pluging kill PlexHelper and relaunch it when the emulator quit, but I never quite got it working.
Hopefully someone can make some sense of what I've already done and make this better and releasable.
[Here's the existing wikipage](http://wiki.plexapp.com/index.php/Arcade). The .plugin is attached to this post.
This is an awesome start. Since I am using a Harmony Remote and a Logitech Controller (for games) I don’t run into the issue you are having with the loss of control. My only suggestion would be to add a little more flexibility in the way the plugin looks at the names of games and screenshots. Right now it seems to have trouble finding a game if the rom is named in goodtools format, such as “Legend of Zelda, The (PRG 0) (U).nes”. I ran into this type of thing all the time when developing EMUlaunch and realized that 95% of the roms out there are named in that format. Screenshots for almost all consoles can be downloaded from http://localarcade.com/screenshotarchive/screenshots.htm
Plugin looks for games in ~/Games/ConsoleName/Roms
Once it finds the rom it should look in ~/Games/ConsoleName/Screenshots
If screenshot is not found then it should look up the game at gaintbomb.com
These are only suggestions but I think it might give the most success. I chose this setup because it how MAME setup its directories. Making this change would also give users the ability to keep their EMUlaunch setup intact while this plugin is being developed. Nice start on this plugin.
I’m looking at refactoring this at the moment. This is my first attempt at plug-in development, but I’m fairly familiar with Python so it’s been fairly easy going to so far.
I’ve come up with a few questions.
[list=1]
[]Is there a generic Item Object that can be put in a media container? There’s nothing mentioned on this list: http://forums.osxbmc.com/docs/Objects.html - Trevor’s existing code uses DirectoryItems and then loads the emulator when Plex calls back to the plug-in for a listing, but this seems like a bit of a hack.
[]Is there a limitation on the size of a .jpg that can be used for the art= parameter? I’m trying to add graphics for the various systems, but for some reason, specifying an art parameter doesn’t always load the image
[]How do I add my own configurable preferences? I’d like to let the user specify their Games root rather than hardcoding ~/Games
[](Wishful thinking) Is there any way for a plug-in to add a new item to the top level? I’d like to add a “Games” option along side TV and Movies, rather than hiding the icon in Applications as it’s currently set up to do
[/list]
If anyone has some great high-res icons or backgrounds for consoles/emulators please post up links
I've done a bit of work with the plugin too. Like yourself, I am new to Plex plugins, but I know Python pretty well.
I can't help with any of your questions, but I would like to know the answers to #3 & 4 as well. Once I get around to it, I'm hoping to put what I have so far onto github, so hopefully we can pool our efforts on the same codebase.
i dont think so, ive made plugins with 1080p backdrops that have worked fine. a lot of times though you need to put the image call inside a R() to get plex to look in the right place in the plugin bundle for it, like:
thumb=R('whatever.png')
or
MediaContainer.art = R('art-default.png')
3. this one's easy see: http://dev.plexapp.com/docs/mod_Prefs.html , but basically you add a CreatePrefs(): function, in my LMA plugin it looks like:
def CreatePrefs():<br />
Prefs.Add(id='lossless', type='bool', default=False, label='Prefer Lossless (Flac16, SHN)')<br />
Prefs.Add(id='flac24', type='bool', default=False, label='Prefer FLAC24 if Available (needs fairly good internet connection)')
then to call the prefrences dialog in the plugin you add to your main menu function:
dir.Append(PrefsItem("Preferences...", thumb=""))
then to recall a prefs setting you call Prefs.Get("prefID") , again in my LMA plugin I use it like:
if Prefs.Get('lossless') == True:<br />
blah<br />
blah<br />
blah
but you can do whatever you want with the returned value, and the prefs support a lot more types than just bool, for what you’re doing use type=‘text’
4. not currenlty possible except maybe a skin hack to point to the plugin, though it has been said that this could be will likely be something coming somewhere in the plex/9 series. (although then, we will hopefully be able to have roms/games as a propper library module and not a plugin)
What do I have to do to let Plex automaticly open the rom? On this moment I only have got the screenshots working but nothing is happening after clicking on one of the games. In finder I already change the settings of the roms so OSX is using the right emulator with the right sort of rom. Also I tried installing the emulator in the games folder where the rom folder is located like in EMUlaunch, without succes. Could someone please explain what I have forgotten?
Made some progress on this, it’s now launching my CPS2/CPS3 roms using SDLMame, and everything works great using my 360 controller.
I’m a working programmer but not real familiar with Python, so just a few questions for you guys:
In order for SDLMame to work, I need to leave the ROM filename intact (i.e. sfiii3an.zip for Street Fighter 3 Third Strike). For MAME Roms, I’d like to look up the rom filename using MAWS (maws.mameworld.info) and then parse out the title. Anybody know of a good way to parse HTML within the plugin Python library?
What’s a good place to look up NES/SNES/SEGA/etc games by rom name?
alexis, do you have any code that might save me some time here? (getting the full game title from the rom filename)
Right now I’m coding the preferences so that you can pick and choose which command runs for which folder type (ex. “Roms/Arcade” -> /Applications/SDLMame/mame), and when it gets a bit more fleshed out I’ll post it up here.
Off the top of my head, what i did for EMUlaunch was to use the list.xml file that you can create from SDLMame.
I believe the command for this is sdlmame -listxml
The listxml file found in EMUlaunch has been stripped of all the unnecessary junk since all you need from this xml file is the game and description tag such as
PuckMan (Japan set 1, Probably Bootleg)
Then I made a php script which would match the rom file name to the the entry in listxml. You can find the php for this after you run EMUlaunch once in /Users/yourusername/Library/Preferences/EMUlaunch-mame.php
For console games I really suggest trying to get the names from GoodTools. But then again its been a long time since I have looked at the current rom management tools. I suggest this cause most screenshots are named in this format such as http://localarcade.com/screenshotarchive/ (beware the site is down right now but I saw in some forum that it will be back up soon).
Hope that helps.
edit here is the snippet of code that compares your current roms to listxml
plugin framework docs are here: http://dev.plexapp.com/docs/index.html
and heres a good xpath tutorial: http://www.zvon.org/xxl/XPathTutorial/General/examples.html
i recommend the firefox addon Xpather
Would someone mind posting an update or any new code on this topic? I’m very much looking forward to playing around with it.
One thing that is unclear from the posts to this point is the method by which emulators actually get launched. Is there a particular one to be using? Does it just use the “Open With” capability of OS X? If so, mine’s not working.
A little more info on the expected outcome would be very helpful. I am able to see my file listings but not execute anything.
I've posted it up on git. Feel free to fork and go nuts. I haven't touched the code in a while and it looks like from the other posters it might not be working anymore.