Solved Question about xbmcswiff2
#1
I coding about play video, but I have question about if the url for play is incorrect (it seem 'null' string)
how can I make the OK dialog to tell user that this movie have incorrect link
I have dilog code but I don't know where to put it
Code:
msg = '[B][COLOR red]{txt}[/COLOR][/B]'.format(
            txt=_('no_valid_links'))
        plugin.log.error(msg)
        dialog = xbmcgui.Dialog()
        dialog.ok(api.long_name, msg)

and this is my play video code
Code:
@plugin.route('/play/<url>/')
def play_video(url):
    downloads = plugin.get_storage('downloads')
    if url in downloads:
        local_file = downloads[url]
        # download was already started
        import xbmcvfs  # FIXME: import from swift after fixed there
        if xbmcvfs.exists(local_file):
            # download was also finished
            log('uPlayHD log => Using local file: %s' % local_file)
            return plugin.set_resolved_url(local_file)
    playable_url = url
    log('log => Using URL: %s' % playable_url)
    return plugin.set_resolved_url(playable_url)

thank you for help!
sry for my bad english. Blush
Reply
#2
Seems like you "borrowed" some code from me ;-)

Just compare the url to the string "null", notify the user, then return None.

E.g.:
Code:
@plugin.route('/play/<url>/')
def play_video(url):
    if url == 'null':
        msg = '[B][COLOR red]{txt}[/COLOR][/B]'.format(
            txt=_('no_valid_links')
        )
        plugin.log.error(msg)
        dialog = xbmcgui.Dialog()
        dialog.ok(api.long_name, msg)
        return  # return None here
    downloads = plugin.get_storage('downloads')
    if url in downloads:
        local_file = downloads[url]
        # download was already started
        import xbmcvfs  # FIXME: import from swift after fixed there
        if xbmcvfs.exists(local_file):
            # download was also finished
            log('uPlayHD log => Using local file: %s' % local_file)
            return plugin.set_resolved_url(local_file)
    playable_url = url
    log('log => Using URL: %s' % playable_url)
    return plugin.set_resolved_url(playable_url)

But a better approach would be just hiding these entries. You can do that one view earlier (the view where you added listitems with the plugin url for "play_video" with url == 'null')
My GitHub. My Add-ons:
Image
Reply
#3
Thank you very much Dersphere.

I'm newer in python dev and programming. So I use some of your function on github sory for that.

you are my idol for dev xbmc plug-in video.

Angel
Reply
#4
(2013-08-31, 19:30)iClosedz Wrote: I'm newer in python dev and programming. So I use some of your function on github sory for that.

You don't need to apologize, its open source (GPL). The only thing which isn't very nice, is copying the code without a small note that you took some code from others work Wink

But, especially if you are newer to python you should really try to write (or at least understand) every line yourself...
There are still some parts from my hd-trailers add-on which don't make sense in your add-on.
My GitHub. My Add-ons:
Image
Reply

Logout Mark Read Team Forum Stats Members Help
Question about xbmcswiff20