Get URLResolver to resolve link only when ListItem clicked?

Hello all,

I have been using the following code below to play a few video links via URLResolver. The code works and when the listItem is clicked the video link is played.

One thing I noticed though is when I added links which require pairing, such as “thevideo.me”, or “openload”. When I click the folder that contains listitems, the pairing notice is displayed before I have even clicked the listitem to play.

My code is below:

Code:
def fg():
   video10 = media_url = urlresolver.resolve('http://www.dailymotion.com/video/x2uhtzd_it-s-peanut-butter-jelly-time-10-minutes-family-guy-brian-griffin_shortfilms')
   addDir('', '', video10, 'Peanut Butter Jelly Time', icon5, icon5)
   video11 = media_url = urlresolver.resolve('https://cloud.mail.ru/public/Fpoi/uNmXT**xB')
   addDir('', '', video11, 'Surfin Bird', icon5, icon5)

By looking at my code I think the issue is that the video link is being resolved before the (addDir) listitem code is called. So the code is doing what it is meant to.

What I was wondering is, is it possible to have the link resolve only when the listitem is clicked? As I believe using this method if I add a few extra links that require pairing the user is going to be shown many pairing dialog windows before they even get to see listitems.

I had a look at the URL Resolver documentation and I seen this code:

Code:
sources = [HostedMediaFile(url='http://youtu.be/VIDEOID', title='Youtube [verified] (20 views)'),
           HostedMediaFile(url='http://putlocker.com/file/VIDEOID', title='Putlocker (3 views)')]
        source = urlresolver.choose_source(sources)
        if source:
                stream_url = source.resolve()
                addon.resolve_url(stream_url)
        else:
                addon.resolve_url(False)

I tried this code but I got a “global HostedMediaFile not defined”? Is there anything else I need to add to the import section of my addon to get HostedMediaFile to be defined?

I really appreciate if anyone has any ideas on how I could implement this method, or point me in the right direction.

Many Thanks