Hi,
I am trying to construct a plugin for the EETV platform.
I have the beginnings working, but am struggling the URL service.
In my channel code I load all available episodes, and they list fine.
I want to ‘save’ this list within my plugin, and access it when I call the URL service, so that I do not have to make multiple calls to the source server for the data list.
I can save the data in my channel code using Data.SaveObject , however when I try and call Data.LoadObject within my URL Service it makes the service fail. I don’t know what the error is as for some reason it isn’t showing up in any of the logs.
How do you persist data between the Channel Code and the URL Service ?
Any ideas what I am doing wrong please !!??
You can’t access channel stuff like Data
and Dict
from the url service.
The url services job is just to take URLs and return something that a video player can play.
Maybe you need to prepare stuff more before going to the url service?
for example with youtube, the channel code would be for listing and organizing video objects with url=http://youtube.com/watch?v=video_key
. The channel code doesn’t need to make requests to these URLs.
The url service would make a request to it and dig around to get the actual video to play. It shouldn’t need to access any previously obtained data to make that happen.
Thanks for the answer, that explains why its not working.
I think I get the basic concept - however 1 further question if I may!
The documentation states you need to define the function :
MetadataObjectforUrl(url)
I have implemented this. At the moment my plugin is quite simple and the first ‘menu’ page just returns a list of VideoClipObjects (this may be changed later).
Anyway these display fine, I get a list of the programs from my EETV box populated with the data I have defined.
Now when I click on one of these items, plex brings up another page with only this item on it, with an image & the Audio/Subtitles and summary etc.
Then from there I can click on the image to play the video.
My question is when the plex server creates this page, it seems to call the MetadataObjectforUrl(url)
function in the URL services code.
From this I need to return some meta information (thumb picture, summary etc.) , so is it expected that I fetch the information again , parse it and return the information that I have already fetched in the plugin code ?
It seems to me this function should be alongside the plugin code ?
Without being able to share data between the plugin code and the URL service code, I am forced to load all the items in the plugin code and parse the relevant data, then do it again and again every time the MetadataObjectforUrl(url) function is called.
Am I missing something here ?
I have read about a ‘work around’ which I have currently working which involves calling the plugin-code from the URL service via an HTTP call, but this seems like adding a lot of overhead for data I have already stored in another function …
You can try a ‘Shared Code’ service.
make a file Contents/Services/Shared Code/video.pys
and have a function in there that does the http request and return metadata. (and set a cacheTime
value > 0)
then in channel code you can reference it via SharedCodeService.video.get_metadata(url)
and in the url service import video; video.get_metadata(url)
I don’t know if this actually shares the http cache, but it would save you having to write the code twice
Your channel plugin code allows you to organize any content available on a website in a nice pretty format that it easier for users to navigate and access. The function of a URL service is just to pull all the data including the media stream URL for one piece of media that is associated with a particular web page URL. And a URL service may be used independently from a channel, like with the PlexIt/Watch Later function or be used by multiple channels playing videos from the same website (for example YouTube videos are used by a lot of websites).
The metadata attributes (like title, thumb, etc) that you pull for your VideoClipObject() or EpisodeObject() in your channel is part of a directory that pulls multiple media items listed on a single web page or other document. When each Plex player app pulls the XML documents that is create by your channel plugin and sees a VideoClipObject() or EpisodeObject() listed with a url field, the Plex player app does a “URL lookup” for that url field value. The “URL lookup” finds the URL service with that URL pattern, so the Plex player app can create a Play screen for that piece of media. (the Play screen is what you see when you click on a single media item in the list of a channel)
And though the MetadataforURL() function may pull some of the same data you have already pulled in your channel, it is accessing a web page for one single media item, not a list. And it pulls everything else about that individual media stream including multiple media items (like multiple resolutions), the stream URL, etc. to build the media object for that Play screen. And often the SMIL or JSON documents you use in the URL service to build those media objects for that media stream also contains the metadata for the MetadataforURL() function.
But there are occasions where a separate URL service is not best. For example, the HGTV channel uses video playlists, so no page on their site just plays one individual video. And when we pull a list of videos for the HGTV channel, it includes a link to the SMIL document (all the data for the individual media stream) for each video. So since the specific data we need for each video is already listed when we pull the metadata in the channel and it would be difficult and confusing to write a URL service for individual URLs since they all contain multiple videos items (a URL service handles just one media item at a time), the HGTV channel does not use a separate URL service. (HGTV - github.com/plexinc-plugins/HGTV.bundle/blob/master/Contents/Code/init.py#L139).
This document may give you a little better understanding about the function of URL services - docs.google.com/document/d/1ePST3Dk0KywSmmDu3OPqpiNilpVgZDSzPgB0ns1yiFU
Just be aware that the document in that link above is still in the draft stages, so some details may need better clarification or error checking.
Also, as I said when you pull the metadata in a channel for a list of media, you are pulling one web page that lists multiple media items.
But not until you click on a particular item to play it, will it call the the URL service and make a request to each URL. And even then, if you use the indirect response code mentioned in that document I linked, it will only pull the minimum data the Plex player app needs to produce the Play screen.
Only when you actually click play will it do any additional pulls that are necessary for it to pull the media stream URL it needs to actually play the video.