basic help (for implementing osx smart folders)

Discuss issues related to PS3 Media Server development (only for programmers)

basic help (for implementing osx smart folders)

Postby glebb » Mon May 21, 2012 5:09 pm

Hi

I was thinking about implementing this old request: http://code.google.com/p/ps3mediaserver/issues/detail?id=240 about serving OS X smart folders. It's a little bit similar feature as Virtual Folders, but OSX specific. I haven't really figured out yet the internals of PMS, so maybe you could point me to right direction.

Regarding how to implement it the actual feature:
The OSX smart folders are actually xml files. The xml contains a query, which is retrieved using spotlight. Even though we cannot access spotlight directly (well, there might be a way through the native API by wrapping, but let's not go there for now), there's a command line tool called mdfind, which let's us actually perform the searches. So the Smart folder xml contains the query, and with little parsing it can be retrieved and passed to mdfind. The query though needs some editing. MDfind will provide a list of file names with full path based on query string. Everything up to this should be fairly simple to implement (though is it the best way, can be discussed).

So, let's assume I get all that implemented. How does PMS actually read the files and serve them? What classes / methods I should look into? I was checking out the db and it seems the files are stored with full path, so at least for me it seems this could be implemented (in theory?). I already implemented adding the smart folders through the UI to the folders list, and I assume somewhere there is a method that will go through the folders, and add files to the db, but before I continue I'd like some feedback (and maybe some pointers to where to start and what to consider).

Ideas? Thoughts? Should I even continue? And oh, I will be adding unit tests as I progress, at least to the new code I write and to the code I change. I also added PowerMock library to make it little bit easier. https://github.com/glebb/ps3mediaserver ... artfolders

Br,
Antti
glebb
 
Posts: 20
Joined: Mon May 21, 2012 4:20 pm
Location: Finland

Re: basic help (for implementing osx smart folders)

Postby taconaut » Mon May 21, 2012 6:23 pm

The way to go is to implement a plugin for this, an AdditionalFolderAtRoot actually. The refreshChildren and discoverChildren methods returned by getResource() will contain the code to list the correct files. Try to find an existing plugin for inspiration.
This might help http://sourceforge.net/apps/mediawiki/p ... le=Plugins

[edit]You can use FileSystemDlnaFolderPlugin as a starting point. Change the implemented class for FileSystemDlnaFolderPlugin.java to AdditionalFolderAtRoot
If you always wanted to have your most recent videos at the top of the folder in the ps3 or wished you could group all videos with the same genre in one folder, have a look at pms-mlx
taconaut
Project Member
 
Posts: 1071
Joined: Sat Apr 11, 2009 12:29 am
Location: Switzerland

Re: basic help (for implementing osx smart folders)

Postby glebb » Mon May 21, 2012 6:51 pm

Thanks, I will check that out.
glebb
 
Posts: 20
Joined: Mon May 21, 2012 4:20 pm
Location: Finland

Re: basic help (for implementing osx smart folders)

Postby taconaut » Tue May 22, 2012 11:16 am

No problem. If you've got question on how to integrate your code to make files show up on the renderer, I should be able to help out; not on how to use and access the OSX smart folders though. Good luck :)
If you always wanted to have your most recent videos at the top of the folder in the ps3 or wished you could group all videos with the same genre in one folder, have a look at pms-mlx
taconaut
Project Member
 
Posts: 1071
Joined: Sat Apr 11, 2009 12:29 am
Location: Switzerland

Re: basic help (for implementing osx smart folders)

Postby glebb » Wed May 23, 2012 10:53 am

Maybe you can help me with something else. I'm having trouble with the dev env to run plugins. I'm following instructions from https://github.com/ps3mediaserver/ps3me ... r/BUILD.md

Everything works fine without plugins. How should I setup the plugin development? For example: If I run the Run PMS maven configuration described in the BUILD.md, it fails to load the plugins I place to ${project_loc}/plugins/. It finds the plugin but always gives me java.lang.NoClassDefFoundError: net/pms/external/AdditionalFolderAtRoot. If I use the same plugin jar while manually launching PMS (created by the same build process), it works. But I really need to use Eclipse to run the PMS as I develop the plugins. So I guess this is a maven problem, but how to solve it?

Creating and compiling the plugins is no problem, though I do it separately (not with maven). And those plugins work if ran outside maven run configuration.
glebb
 
Posts: 20
Joined: Mon May 21, 2012 4:20 pm
Location: Finland

Re: basic help (for implementing osx smart folders)

Postby taconaut » Wed May 23, 2012 11:43 am

pms hasn't been set up to load plugins contained in the external libraries when debugging. This will be added when pms-mlx gets merged into pms.

If you want to debug the plugin you have to do this:
As the relative path of the plugins directory isn't the same when running from eclipse or when packaged, you have to load the plugins dir from a properites file (click) and configure the version in a properties file to run from eclipse (click) and when packaged (click). Then you can put the plugins into /src/main/external-resources/plugins.

If you need a running example, check out pms-mlx and pms-plugins in my github repo, load all projects contained in these two repos into eclipse. When running pms, you'll be able to set a break point in the plugins and debug them.
If you always wanted to have your most recent videos at the top of the folder in the ps3 or wished you could group all videos with the same genre in one folder, have a look at pms-mlx
taconaut
Project Member
 
Posts: 1071
Joined: Sat Apr 11, 2009 12:29 am
Location: Switzerland

Re: basic help (for implementing osx smart folders)

Postby glebb » Wed May 23, 2012 6:43 pm

I was able to setup the location for the plugins by your example, but it still fails when trying to debug/run from eclipse due to same reason. I almost got it working by installing the plugins directly to root of target (as I believe the plugin loader tries to access the interfaces directly under classes/), but then something else went wrong. I also checked your pms-mlx and noticed the plugin loading systems is quite different from baseline pms, which is my target. Well, I give up now for the debugging, but it doesn't matter. Just one more reason to write proper unit tests :)
glebb
 
Posts: 20
Joined: Mon May 21, 2012 4:20 pm
Location: Finland

Re: basic help (for implementing osx smart folders)

Postby taconaut » Thu May 24, 2012 7:54 am

One more thing I forgot to tell (hope it's the last). In ExternalFactory, specify the pms classloader as the base class loader for the one instanciating the plugins (click). If you have further problems, a stack trace will probably be useful.
The plugin system in pms-mlx will be merged into the main project at some point he upcoming months. Both are pretty similar, it's mainly the basic functionalities (ExternalListener vs. PluginBase) which differ.

Btw. to be sure where to put the plugins, have a look for at the first line (containing 'loading plugins from') to know where to put the jar in. Then make sure you've got the same version of the code loaded in eclipse as the plugin jar you've added to the plugins dir and you should be able to debug.
If you always wanted to have your most recent videos at the top of the folder in the ps3 or wished you could group all videos with the same genre in one folder, have a look at pms-mlx
taconaut
Project Member
 
Posts: 1071
Joined: Sat Apr 11, 2009 12:29 am
Location: Switzerland

Re: basic help (for implementing osx smart folders)

Postby glebb » Thu May 24, 2012 5:39 pm

Great, now it works! Thank you.
glebb
 
Posts: 20
Joined: Mon May 21, 2012 4:20 pm
Location: Finland

Re: basic help (for implementing osx smart folders)

Postby taconaut » Fri May 25, 2012 8:17 am

Cool, now you can start with the fun part :)
If you always wanted to have your most recent videos at the top of the folder in the ps3 or wished you could group all videos with the same genre in one folder, have a look at pms-mlx
taconaut
Project Member
 
Posts: 1071
Joined: Sat Apr 11, 2009 12:29 am
Location: Switzerland

Next

Return to Developers

Who is online

Users browsing this forum: No registered users and 3 guests