Hi all, Plex (and Python) newbie here. I wonder if anyone could help me with this question:
How to access URL services from a channel plugin? (if possible at all)
To clarify: suppose I'm trying to create a channel for a blog-like website that reads information about available videos from pages that list videos. But on the individual detail pages, where video player is embedded, I can't tell which player is it without loading that page - it may be youtube, vimeo, maybe even some others.
Now, I've figured out how to make a URL Service for the blog's detail pages (generally following this tutorial) and I'm just listing the pages URLs in a DirectoryObject, which works well. But in the URL Service code's PlayVideo method I have to look for the different embedded players which I think might be there and get the Video URL from whichever one I find.
So I've made it that far by using docs and following tutorials.
What I'd like to do is if I find a youtube player on the page, I'd call a youtube URL Service that's already installed, to play the video. And similarly with the other services, so that I don't have to reinvent the wheel. And if there's no URL service for the embedded player, then well, I'll go ahead and implement some Shared Code for getting the Video stream.
Here's an example of how you can call that sort of thing. Just be cautious to not end up in recursive loops and the like (I did that exact thing working on a new channel yesterday, DOH!)
So what I really want the Youtube URL Service to do is to PlayVideo, but I can't seem to be able to call it directly. And if I understand the URL Services guide correctly, that the MediaObjectsForURL is better not doing any HTTP requests, then the most appropriate place to request the detail pages is MetadataObjectForURL. That's where I parse the detail page, detect any embedded players and, if I detect a Youtube player, I'll hand the Youtube URL to its own URL Service. I still might want to edit the metadata it returns though, based on the info from my detail pages.
But I suspect, that I still won't get MediaObjects from Youtube that way. But I may then call the URL Service's MediaObjectsForURL, get the media objects with links to Youtube's PlayVideo and add them to my VideoClipObject, the guide says it's possible. Would you call it a "good practice" to do so?
If I understand correctly that seems like a pretty decent way to do things. You can use the one (MediaObjects) without having to use the other (Metadata) ... so it sounds like you want to control/set your own metadata and then if it's a youtube video had off the MediaObjects to the Youtube URL service for the actual playing of it (and therefore you also get it's PlayVideo method) ... so yes if I understand correctly that seems totally fine. Just because you use one doesn't mean you have to use the other. I would say you are better doing this than recreating it without need ... also that means that if (more like when) the Youtube URL service gets updated your channel will always use the latest code for actually playing the video (which is always a good thing).