Kodi Community Forum

Full Version: Urlresolver
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How do I call or set urlresolver on my addon, i had put in every where and Kodi don't use it
Can someone explain it or show a link that can help
You probably failed to import it in your addon.xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!--suppress ALL -->
<addon id="plugin.video.foo" version="0.0.1" name="foo" provider-name="tknorris">
    <requires>
        <import addon="xbmc.python" version="2.19.0"/>
        <import addon="script.module.urlresolver" version="3.0.0"/>
    </requires>
    <extension point="xbmc.python.pluginsource" library="default.py">
        <provides>video</provides>
    </extension>
    <extension point="xbmc.addon.metadata">
        <summary></summary>
        <description></description>
        <platform>all</platform>
    </extension>
</addon>
It is fine, the problem is how to call it on play it is not running
Like what is the codes I have to set and where on my default.py
If u want I can put my default.py here
(2016-11-30, 22:39)danielrodrigues Wrote: [ -> ]It is fine, the problem is how to call it on play it is not running

It's pretty straight forward. Here's an example:
Code:
import urlresolver
hmf = urlresolver.HostedMediaFile(url=hoster_url)
if not hmf:
    log('Indirect hoster_url not supported by urlresolver: %s' % (hoster_url))
else:
    try:
        stream_url = hmf.resolve()
         if not stream_url or not isinstance(stream_url, basestring):
             try: msg = stream_url.msg
             except: msg = hoster_url
             raise Exception(msg)
     except Exception as e:
         try: msg = str(e)
         except: msg = hoster_url
         kodi.notify(msg=i18n('resolve_failed') % (msg), duration=7500)
         return False
thanks for help me, but still i dont know where to put this code, do i put it on default.py on first line, do i put on addDirectory, i make it work once but the way i did it play all the urls at the same time insted to create the menu with item and wait for me to click it to play, do u undestand what i m saying
(2016-12-01, 02:16)danielrodrigues Wrote: [ -> ]thanks for help me, but still i dont know where to put this code, do i put it on default.py on first line, do i put on addDirectory, i make it work once but the way i did it play all the urls at the same time insted to create the menu with item and wait for me to click it to play, do u undestand what i m saying

You need to use one of the many addons that use urlresolver as an example. You need to write your code such that when you click a playable link it calls your addon again and then you do the resolve_host() part, not as part of setting up the directory.
Huh??
I just learn how to Add directory, I don't know how to play it I m using the default player
can u show me a simple one because they all a nest o code.
codes that they even need, so it make my head confuse
(2016-12-01, 02:32)danielrodrigues Wrote: [ -> ]I just learn how to Add directory, I don't know how to play it I m using the default player

Which player you are using has nothing to do w/ it. The best I can suggest is to look up one of my addons as an example of how to do it. I can't give you a link or refer to them specifically as it's against the rules here.
please do so
(2016-12-01, 02:37)danielrodrigues Wrote: [ -> ]can u show me a simple one because they all a nest o code.
codes that they even need, so it make my head confuse

The code I pasted above is the core code you need to call urlresolver. You just need to call your addon when someone clicks a playable listitem and then run that code and call setResolvedUrl() with the url that urlresolver returns. It's really pretty straight forward.