Esempio n. 1
0
def handlePush(data, from_gui=False):
    if not from_gui and checkForWindow():  # Do nothing if the window is open
        return False
    if data.get("type") == "link":
        url = data.get("url", "")
        if StreamExtractor.mightHaveVideo(url):
            vid = StreamExtractor.getVideoInfo(url)
            if vid:
                if vid.hasMultipleStreams():
                    vlist = []
                    for info in vid.streams():
                        vlist.append(info["title"] or "?")
                    idx = xbmcgui.Dialog().select(util.T(32091), vlist)
                    if idx < 0:
                        return
                    vid.selectStream(idx)
                util.LOG(vid.streamURL())  # TODO: REMOVE
                StreamUtils.play(vid.streamURL())
                return True
        if canPlayURL(url):
            handleURL(url)
            return True
        media = getURLMediaType(url)
        if media == "video" or media == "music":
            StreamUtils.play(url)
            return True
        elif media == "image":
            import gui

            gui.showImage(url)
            return True
    elif data.get("type") == "file":
        if data.get("file_type", "").startswith("image/"):
            import gui

            gui.showImage(data.get("file_url", ""))
            return True
        elif data.get("file_type", "").startswith("video/") or data.get("file_type", "").startswith("audio/"):
            StreamUtils.play(data.get("file_url", ""))
            return True
    elif data.get("type") == "note":
        import gui

        gui.showNote(data.get("body", ""))
        return True
    elif data.get("type") == "list":
        import gui

        gui.showList(data)
        return True
    elif data.get("type") == "address":
        import urllib

        xbmc.executebuiltin(
            "XBMC.RunScript(special://home/addons/service.pushbullet.com/lib/maps.py,service.pushbullet.com,%s,None,)"
            % urllib.quote(data.get("address", ""))
        )
        return True

    return False
def handlePush(data, from_gui=False):
    if not from_gui and checkForWindow():  #Do nothing if the window is open
        return False
    if data.get('type') == 'link':
        url = data.get('url', '')
        if StreamExtractor.mightHaveVideo(url):
            vid = StreamExtractor.getVideoInfo(url)
            if vid:
                if vid.hasMultipleStreams():
                    vlist = []
                    for info in vid.streams():
                        vlist.append(info['title'] or '?')
                    idx = xbmcgui.Dialog().select(common.localise(32091),
                                                  vlist)
                    if idx < 0: return
                    vid.selectStream(idx)
                playMedia(vid.streamURL(), vid.title, vid.thumbnail,
                          vid.description)
                return True
        if canPlayURL(url):
            handleURL(url)
            return True
        media = getURLMediaType(url)
        if media == 'video' or media == 'audio':
            url += '|' + urllib.urlencode({'User-Agent': getURLUserAgent(url)})
            playMedia(url,
                      playlist_type='video' and xbmc.PLAYLIST_VIDEO
                      or xbmc.PLAYLIST_MUSIC)
            return True
        elif media == 'image':
            import gui
            gui.showImage(url)
            return True
    elif data.get('type') == 'file':
        if data.get('file_type', '').startswith('image/'):
            import gui
            gui.showImage(data.get('file_url', ''))
            return True
        elif data.get('file_type', '').startswith('video/') or data.get(
                'file_type', '').startswith('audio/'):
            playMedia(data.get('file_url', ''))
            return True
    elif data.get('type') == 'note':
        import gui
        gui.showNote(data.get('body', ''))
        return True
    elif data.get('type') == 'list':
        import gui
        gui.showList(data)
        return True
    elif data.get('type') == 'address':
        cmd = 'XBMC.RunScript({0},MAP,{1},None,)'.format(
            common.__addonid__, urllib.quote(data.get('address', '')))
        xbmc.executebuiltin(cmd)
        return True

    return False
def handlePush(data, from_gui=False):
    if not from_gui and checkForWindow():  # Do nothing if the window is open
        return False
    if data.get("type") == "link":
        url = data.get("url", "")
        if StreamExtractor.mightHaveVideo(url):
            vid = StreamExtractor.getVideoInfo(url)
            if vid:
                if vid.hasMultipleStreams():
                    vlist = []
                    for info in vid.streams():
                        vlist.append(info["title"] or "?")
                    idx = xbmcgui.Dialog().select(common.localise(32091), vlist)
                    if idx < 0:
                        return
                    vid.selectStream(idx)
                playMedia(vid.streamURL(), vid.title, vid.thumbnail, vid.description)
                return True
        if canPlayURL(url):
            handleURL(url)
            return True
        media = getURLMediaType(url)
        if media == "video" or media == "audio":
            url += "|" + urllib.urlencode({"User-Agent": getURLUserAgent(url)})
            playMedia(url, playlist_type="video" and xbmc.PLAYLIST_VIDEO or xbmc.PLAYLIST_MUSIC)
            return True
        elif media == "image":
            import gui

            gui.showImage(url)
            return True
    elif data.get("type") == "file":
        if data.get("file_type", "").startswith("image/"):
            import gui

            gui.showImage(data.get("file_url", ""))
            return True
        elif data.get("file_type", "").startswith("video/") or data.get("file_type", "").startswith("audio/"):
            playMedia(data.get("file_url", ""))
            return True
    elif data.get("type") == "note":
        import gui

        gui.showNote(data.get("body", ""))
        return True
    elif data.get("type") == "list":
        import gui

        gui.showList(data)
        return True
    elif data.get("type") == "address":
        cmd = "XBMC.RunScript({0},MAP,{1},None,)".format(common.__addonid__, urllib.quote(data.get("address", "")))
        xbmc.executebuiltin(cmd)
        return True

    return False
Esempio n. 4
0
def handlePush(data, from_gui=False):
    if not from_gui and checkForWindow():  #Do nothing if the window is open
        return False
    if data.get('type') == 'link':
        url = data.get('url', '')
        if StreamExtractor.mightHaveVideo(url):
            vid = StreamExtractor.getVideoInfo(url)
            if vid:
                if vid.hasMultipleStreams():
                    vlist = []
                    for info in vid.streams():
                        vlist.append(info['title'] or '?')
                    idx = xbmcgui.Dialog().select(util.T(32091), vlist)
                    if idx < 0: return
                    vid.selectStream(idx)
                util.LOG(vid.streamURL())  #TODO: REMOVE
                StreamUtils.play(vid.streamURL())
                return True
        if canPlayURL(url):
            handleURL(url)
            return True
        media = getURLMediaType(url)
        if media == 'video' or media == 'music':
            StreamUtils.play(url)
            return True
        elif media == 'image':
            import gui
            gui.showImage(url)
            return True
    elif data.get('type') == 'file':
        if data.get('file_type', '').startswith('image/'):
            import gui
            gui.showImage(data.get('file_url', ''))
            return True
        elif data.get('file_type', '').startswith('video/') or data.get(
                'file_type', '').startswith('audio/'):
            StreamUtils.play(data.get('file_url', ''))
            return True
    elif data.get('type') == 'note':
        import gui
        gui.showNote(data.get('body', ''))
        return True
    elif data.get('type') == 'list':
        import gui
        gui.showList(data)
        return True
    elif data.get('type') == 'address':
        import urllib
        xbmc.executebuiltin(
            'XBMC.RunScript(special://home/addons/service.pushbullet.com/lib/maps.py,service.pushbullet.com,%s,None,)'
            % urllib.quote(data.get('address', '')))
        return True

    return False
def handlePush(data,from_gui=False):
    if not from_gui and checkForWindow(): #Do nothing if the window is open
        return False
    if data.get('type') == 'link':
        url = data.get('url','')
        if StreamExtractor.mightHaveVideo(url):
            vid = StreamExtractor.getVideoInfo(url)
            if vid:
                if vid.hasMultipleStreams():
                    vlist = []
                    for info in vid.streams():
                        vlist.append(info['title'] or '?')
                    idx = xbmcgui.Dialog().select(common.localise(32091),vlist)
                    if idx < 0: return
                    vid.selectStream(idx)
                playMedia(vid.streamURL(),vid.title,vid.thumbnail,vid.description)
                return True
        if canPlayURL(url):
            handleURL(url)
            return True
        media = getURLMediaType(url)
        if media == 'video' or media == 'audio':
            url += '|' + urllib.urlencode({'User-Agent':getURLUserAgent(url)})
            playMedia(url,playlist_type='video' and xbmc.PLAYLIST_VIDEO or xbmc.PLAYLIST_MUSIC)
            return True
        elif media == 'image':
            import gui
            gui.showImage(url)
            return True
    elif data.get('type') == 'file':
        if data.get('file_type','').startswith('image/'):
            import gui
            gui.showImage(data.get('file_url',''))
            return True
        elif data.get('file_type','').startswith('video/') or data.get('file_type','').startswith('audio/'):
            playMedia(data.get('file_url',''))
            return True
    elif data.get('type') == 'note':
        import gui
        gui.showNote(data.get('body',''))
        return True
    elif data.get('type') == 'list':
        import gui
        gui.showList(data)
        return True
    elif data.get('type') == 'address':
        cmd = 'XBMC.RunScript({0},MAP,{1},None,)'.format(common.__addonid__,urllib.quote(data.get('address','')))
        xbmc.executebuiltin(cmd)
        return True

    return False