Given a valid url, is it possible to programmatically call the corresponding url service and obtain the object data programmatically?
As much as I LOVE the URL Service support, I'd like to be able to overwrite certain metadata of the object before it is displayed to keep it consistent with the main website. In Example 1 you will see that the title and summary for "102 Minutes That Changed America" is clean and proper.
Example 1:

The problem is when I click on "102 Minutes That Changed America" and it automatically switches to the metadata provided by the YouTube URL Service, as shown in Example 2.
As shown above, and at no fault of the URL Service I might add, sometimes the details returned are just really...um...well...fugly!! Maybe in the future I'll create a button to auto-comment a nasty message to the video author's page to tell them to clean up their mess, but for now I'd settle for a way to overwrite the title and summary on an object populated by a service. I guess my question is, instead of passing a url to the object to be auto-detected, can I pass a url to a function and return the appropriate data programmatically so I can create my own object with some of the data provided from the service, and the rest from other sources?
This issue is kiling me as I am not creating a YouTube or Vimeo channel, nor relying on YouTube or Vimeo's metadata to fill in the details past the media data, but because the url is loaded through URL Services I cannot properly match up the metadata with the main site.
Aside from merging the available/applicable URL Services into one immense custom service, I am not sure how this information could be overwritten? When I browse http://watchdocumentary.com/, I do not see YouTube or Vimeo's metadata, I only see the sites' custom metadata (unless I click on the player link to go to the hosting site). It just makes for an inconsistent experience for the user, and as demonstrated above, it does not make for a great UI experience. :(
While the metadata is not locked per se, I don't believe it's practically possible to overwrite it. Once the url is passed the url service, the channel code no longer has control.
I think a better solution would be to write your own url service for the site in question. That way you can use the metadata provided by the website. In the MediaObjectsForURL() method, you can cheat and use the MediaObjects from the relevant url service.
def MetadataObjectForURL(url):
'''grab the relevant metadata from the given url'''
...
return VideoClipObject(title, summary, etc.)
@deferred
def MediaObjectsForURL(url):
‘’‘parse the given page for the link to the actual source page’’’
…
‘’‘pass the actual source link along the chain for handling’’’
return URLService.MediaObjectsForURL(source_url)
The @deferred decorator tells the client app not to process the MediaObjects for the given item until a request is made. Without that, loading a menu would be very slow while the framework makes http requests to gather the MediaObject info for each item in the list.
The URLService.MediaObjectsForURL() method basically just asks the framework to find an url service for the given url and return the appropriate media objects from that URL Service. It's not commonly used for 2 reasons; first, it's rarely necessary; second, it's easy to use it improperly so it's discouraged in general. I think your situation is a prime candidate though.