I'd like to implement a failry simple thing for my channel: combine a bunch of media thumbnails into one to represent a category of media.
Does anybody have any experience with task like this?
My best guess for now is to use /Libraries/Shared/ folder to bundle some image processing library and try to use it.
My concerns are how sandbox policies are affecting shared libraries (which are quite restricting in the plugin areas I've worked with so far) and what image library would be a good choice (I figure I'd need a pure python implementation or it might become too much of a hassle if using binaries like ImageMagick - cross platform and possible restrictions concerns).
I don't have any experience with image processing (especially via a Plex plugin). The main thing to remember with Plex plugin sandboxing and external libraries, is that /Libraries/Shared/..code does not have access to Plex plugin framework methods.
I agree that a pure python implementation is the way to go. Dealing with binaries for multiple platforms is a major headache, particularly when you would need to include all of them in the plugin bundle.
Imagemagick does provide python bindings (PythonMagick) but as you said I think it would be a pain to have to try and maintain all the different versions that would be potentially needed across platforms. I've done this sort of stuff with python before but never within the channel framework. If you can find a pure python solution it would probably be the easiest to maintain, but from what you're describing I suspect it might not be worth the amount of effort just to build custom icons (that some clients won't even use to be honest).
I did a quick search and saw PIL as a suggestion .. but wow, I think it would be easier to maintain Imagemagick binaries than that one ;)
Also worth noting that it's now obsolete and they suggest using PILLOW -- but again it comes with too many requirements IMHO, Imagemagick is still a better option (but that's not saying much here). I wonder if you couldn't find (or setup) a simple web service somewhere that would do this sort of thing for you ...
Thanks for the suggestions. I've run across notices about PIL and Pillow and they also seemed too large to me. Not being able to access Plex framework from the shared libraries is totally fine, I was more afraid of running into restrictions while calling some low level functions, which image libraries might want to do.
If I find any good solution, I'll be sure to share. The best possible way I can imagine for now is adding a git submodule with the imaging library of choice and creating a connector somewhere in the plugin.
Can you point me to any examples of channels that have any shared libraries to use as an inspiration for a way of plugging them in and using by a channel code?
@Gerk, I'm not sure I'm following your comment about some Plex clients not using custom icons. For now, I only test my work in Windows Home Theater client and it sure displays the thumbnails I put into DirectoryObjects. My idea was to get rid of generic category icons on these directory objects and provide a quick glance on what's inside. I've already figured out how to call the thumbnail asynchronously from the Plex client, so there shouldn't be much harm in generating images on the fly.
Yep no worries, I was misunderstanding what you were trying to do with the icons, what you want to do all plex clients should totally support.
For shared code I think that the PBS channel/URL service uses some. In that case (and I think all cases?) the Shared Code goes into the URL service if both things need to access it. That could probably also work in a local URL service too but I don't think I've ever tried it like that.
I did a quick search and saw PIL as a suggestion .. but wow, I think it would be easier to maintain Imagemagick binaries than that one ;)
Also worth noting that it's now obsolete and they suggest using PILLOW -- but again it comes with too many requirements IMHO, Imagemagick is still a better option (but that's not saying much here). I wonder if you couldn't find (or setup) a simple web service somewhere that would do this sort of thing for you ...
That's a shame, I was just about to ask if PIL/Pillow was included or not. Would have been nice to draw a no smoking-kinda-circle over the thumbnails for videos that are no longer available. ;)
Well if you can tell that the videos are no longer available why not just remove them from the listings? Or prepend/append to the video title to show that it's not available?
Well if you can tell that the videos are no longer available why not just remove them from the listings? Or prepend/append to the video title to show that it's not available?
Imho, by default it would seem a bit odd to not retain the same list of videos that are provided on the main site. Although I haven't really looked into prefs yet, I was assuming I would have a way to add an option to my prefs to hide invalid videos from view...this way the user is aware of their choice, and understands why they're not displaying.
My concern with scripting a site that relies on random urls from random sites is the consistent drop of content, and the assumption that my script is the culprit. I just don't want a bunch of unnecessary questions plaguing me later on so I'd prefer to let the user choose to do it and understand why from their choice.
Later on I will be looking to implement a method to report the broken links but before that can be done I need to take a bit more time to ensure the links are definitely dead. ;)
Now trying out things to integrate it with the channel code.
Edit: although after getting the library to work in the channel and attempting to actually do stuff with it, I learned about issues with the jpeg format decoder...
But since then I've been experimenting with ImageMagick and Wand-py library. If one goes through the trouble of installing the correct ImageMagick binaries, there's a fairly easy way to do images manipulation, although that makes the channel kind of undistributable. Would be so much easier, if Plex had it bundled.
I've made a simple "connector" that links Wand library, that is added as git submodule to the channel shared code. Check it out here if you like:
The library's repo root doesn't have __init__.py, so it can't be imported directly, if added as git submodule. So what this code does, is to kind of hack the library into the import search paths, in addition to a few factory methods. I've also added some example code in readme.