Guest - Testers are needed for the reworked CDateTime core component. See... https://forum.kodi.tv/showthread.php?tid=378981 (September 29) x
  • 1
  • 20
  • 21
  • 22(current)
  • 23
  • 24
  • 28
script.module.urlresolver development
Yes that is a good guide to follow for creating a new resolver, you can reference existing ones for help:

https://github.com/Eldorados/script.modu...er/plugins

To use just import urlresolver:

Code:
import urlresolver

Then you can use it in a few ways

One you can compile a list of possible hosts that you site uses and pass in to urlresolver to filter and prompt the user with a list:

Code:
sources = []
    media = urlresolver.HostedMediaFile(host=host, media_id=linkid, title='Some Host')
    sources.append(media)

    source = urlresolver.choose_source(sources)
    if source:
        stream_url = source.resolve()
    else:
        stream_url = False
      
    #Play the stream
    if stream_url:
        addon.resolve_url(stream_url)

Or filter a list of sources and send back the list to you to do as you like:

Code:
filtered_list = urlresolver.filter_source_list(host_list)

Or just resolve a straight url:

Code:
stream_url = urlresolver.resolve(url)


You can look at my RedLetterMedia addon for some easy reference:

https://github.com/Eldorados/eldorado-xb...ettermedia
Reply
Hello
first i would like to thank you for your fantastic work

i need your help , i would like to know if it is possible to create a strm file that call urlresolver and play url inside it ?
for example : i create a file called ATM.strm , inside it i paste an url like http://uptobox.com/7zof8rfe2qka and save it
I would like that when i select this strm file in my library it call urlresolver script to unrestrict the link inside (using my realdebrid account )

Is it possible ? if yes how ?
Sorry but i'm totally noob Sad
Reply
It is easily possible, are you developing a new addon to do this?

A strm file on it's own can technically call urlresolver directly, but it only returns a resolved link.. I'm guessing XBMC will do nothing after that, I don't think the player will get kicked off

I believe you need an addon to do some of the middle man work, eg. the strm file will contain a call to your addon and passing in your link, which then calls urlresolver who returns a resolved link, your addon then passes that link to xbmc player

Take a peak at some of the addons that allow you to add videos to your library, take a peak at the strm files they create and you will see the syntax for doing this
Reply
(2014-03-26, 15:36)Eldorado Wrote: It is easily possible, are you developing a new addon to do this?

A strm file on it's own can technically call urlresolver directly, but it only returns a resolved link.. I'm guessing XBMC will do nothing after that, I don't think the player will get kicked off

I believe you need an addon to do some of the middle man work, eg. the strm file will contain a call to your addon and passing in your link, which then calls urlresolver who returns a resolved link, your addon then passes that link to xbmc player

Take a peak at some of the addons that allow you to add videos to your library, take a peak at the strm files they create and you will see the syntax for doing this

Thanks a lot for your answer eldorado !
The problem is i'm totally noob in programing , if a dev see this post , maybe he could create an addon based on this idea , it would be fantastic Big Grin
Reply
If your interested in starting, an addon like this would be an easy place to start!

Lots of examples out there to put it altogether
Reply
like i said previously , i'm unable to programming , but maybe you could Eldorado ? Wink
Reply
nobody to create this ?
Reply
Please ?!
Reply
Please don't be doing that in this thread, start up a new one if you want a new addon created
Reply
erased
Reply
Hi,

I am a little bit confused about the interface to implement.
In interfaces.py the class UrlResolver has the method
Code:
get_media_url(self, web_url)
which we are supposed to implement for each new UrlResolver subclass.

What I don't understand is in all the resolver classes the signature is different:
Code:
get_media_url(self, host, media_id)

Why is that? Is it the same method?

The only place where I see the use of this method with media_id and host is in types.py in the class HostedMediaFile within the resolve method.

Could someone clarify that?

Thank you.
Image
_____________________________

Repositories Installer: select and install unofficial repositories / TAC.TV: watch videos on TAC.TV
Installer Passion-XBMC: Download and Install Add-ons (pre-Dharma only)

Image
Reply
I will need to re-familiarize myself with the code again

Are you looking to create a new resolver or implement urlresolver to use in your project?
Reply
(2014-05-07, 20:12)Temhil Wrote: Hi,

I am a little bit confused about the interface to implement.
In interfaces.py the class UrlResolver has the method
Code:
get_media_url(self, web_url)
which we are supposed to implement for each new UrlResolver subclass.

What I don't understand is in all the resolver classes the signature is different:
Code:
get_media_url(self, host, media_id)

Why is that? Is it the same method?

The only place where I see the use of this method with media_id and host is in types.py in the class HostedMediaFile within the resolve method.

Could someone clarify that?

Thank you.

They are all SUPPOSED to implement both. The idea is that if you as the caller don't know the full link, but you know it's from YouTube and the video is is l1k3j4h5, you call get_media_url("youtube.com", l1k3j4h5), but if you know the full link, you call get_media_url("http://www.youtube.com/?v=l1k3j4h5").

If you're contributing a new resolver, you SHOULD implement both methods, even if the one that takes an id and a host just assembles a link and calls the other one. If you're using the library in your addon, call whichever you need and if any of them don't work both ways, that's a bug
Reply
Hello

Sorry for my English, I will like to propose and update in the realdebrid resolver, because the method "get_all_hosters" use the URL: http://www.real-debrid.com/api/regex.php?type=all and this URL is out of date with the supports servers, and exist another URL: https://real-debrid.com/api/hosters.php that retrieve all supports hosters up date, I make some changes in my local resolver for work with this new URL, I post here the changes I made. I hope that this contribute with something.

Code:
def get_all_hosters(self):
        if self.hosters is None:
            try :
                url = 'https://real-debrid.com/api/hosters.php'
                response = self.net.http_GET(url).content.lstrip('/').rstrip('/g')
                delim = ','
                self.hosters = [host for host in re.split(delim, response.replace('"',''))]
            except:
                self.hosters = []
        common.addon.log_debug( 'RealDebrid hosters : %s' %self.hosters)
        return self.hosters
Code:
def valid_url(self, url, host):
        if self.get_setting('enabled') == 'false': return False
        if self.get_setting('login') == 'false': return False
        common.addon.log_debug('in valid_url %s : %s' % (url, host))
        self.get_all_hosters()
        for host in self.hosters :
            common.addon.log_debug('RealDebrid checking host : %s' %str(host))
            if host in url:
                common.addon.log_debug('RealDebrid Match found')
                return True
        return False

PS: I'm new in python Tongue
Reply
Thanks!

Would you by chance be familiar with github? I prefer changes to come thru there, if not I will try and find some time to move this in myself
Reply
  • 1
  • 20
  • 21
  • 22(current)
  • 23
  • 24
  • 28

Logout Mark Read Team Forum Stats Members Help
script.module.urlresolver development7