URL Services Metadata and duplication of effort

Can someone help me understand when and where to use URL services for metadata? (MetadataObjectForURL) Right now i have a bunch of code in my main init.py script that gathers all of the metadata i need to create a complete EpisodeObject or VideoClipObject. (URL, title, summary, rating, thumb, etc) I’ve been looking at a lot of examples of how other developers use URL Services (specifically the MetadataObjectForURL function) and am a bit confused. The Hulu plugin, for example, almost fully duplicates effort and returns almost the exact same EpisodeObjects & VideoClipObjects through it’s URL Service MetadataObjectForURL() function as it does through the code in the init.py script. Is this not slowing down the plugin?



So, i guess my question is, when and how should i use URL services for MetadataObjectForURL. Should i be extremely conservative in my primary script and put all of the metadata scraping code into the services code? (Example: Just passing an EpisodeObject with a URL and nothing more and let the URL service do the rest) Or should i not worry at all about using MetadataObjectForURL() in my service code and just focus on the MediaObjectsForURL().



Or maybe i’m missing something and just don’t understand exactly what the URL Services MetadataObjectForURL actually does. Does it not just supplement the existing data for a given EpisodeObject/VideoClipObject?



Thanks for the advice!

You typically need the full deal in both areas. The URL services are used in various places, including when people use things like the PlexIt bookmark for myPlex, for recommendations to friends, etc. I’m pretty sure there will be more ways they are used in the future too. They are also used by various clients on the “info” type screens, when someone wants to see all the details. You don’t actually use them directly from your channel code (aside from them getting used when you have url=foo in your objects, then the URL service takes over there).

This may be a dumb question (I’m no Python expert), but is it possible to call MetadataObjectForURL() from within init.py (to avoid code duplication)?



Also, suppose I develop a MetadataObjectForURL() function in ServiceCode.pys. When is that function ever called? How do I ever test it? From within the Plex Client, how would I force that function to be used?


Yes, that is possible. The reason why we almost never do this, is because it makes loading directories very slow. If you have a website that lists 10 videos per page, processing those videos inside the plugin takes 1 http request. If you're going to let the URL Service handle each video it'll take 1 + 10 = 11 http requests.


It's used for functionality in places outside the channel. See Gerk's reply above.


You can check the XML output from the Plex Media Server: http:****//localhost:32400/system/services/url/lookup?url=
Example: http:****//localhost:32400/system/services/url/lookup?url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DQkkoHAzjnUs

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.