示例#1
0
def play_video(params):
    get = params.get
    mode = get("mode")
    file_list = get("file_list")
    file_list = utils.unquote_plus(file_list).split(";")
    play_list = get("play_list")
    play_list = utils.unquote_plus(play_list).split(";")
    folder = get("folder")
    folder = utils.unquote_plus(folder)
    # We might have deleted the path
    if os.path.exists(folder):
        # we trick xbmc to play avi by creating empty rars if the download is only partial
        utils.write_fake(file_list, folder)
        # Prepare potential file stacking
        if (len(play_list) > 2):
            rar = []
            for arch_rar, movie_file in zip(play_list[0::2], play_list[1::2]):
                raruri = "rar://" + utils.rarpath_fixer(folder, arch_rar) + "/" + movie_file
                rar.append(raruri)
                raruri = 'stack://' + ' , '.join(rar)
        else:
            raruri = "rar://" + utils.rarpath_fixer(folder, play_list[0]) + "/" + play_list[1]
        info = nfo.NfoLabels()
        item = xbmcgui.ListItem(info.info_labels['title'], iconImage='DefaultVideo.png', thumbnailImage=info.thumbnail)
        item.setInfo(type="Video", infoLabels=info.info_labels)
        item.setPath(raruri)
        item.setProperty("IsPlayable", "true")
        xbmcplugin.setContent(HANDLE, 'movies')
        wait = 0
        player = xbmcplayer.XBMCPlayer(xbmc.PLAYER_CORE_AUTO)
        player.sleep(1000)
        if mode == MODE_AUTO_PLAY or mode == MODE_LIST_PLAY:
            player.play( raruri, item )
        else:
            xbmcplugin.setResolvedUrl(handle=HANDLE, succeeded=True, listitem=item)
        removed_fake = False
        while player.is_active:
            player.sleep(500)
            wait+= 1
            if player.is_playing and not removed_fake:
                utils.remove_fake(file_list, folder)
                removed_fake = True
            if player.is_stopped:
                the_end(folder, player.is_stopped)
                player.is_active = False
            elif player.is_ended:
                the_end(folder)
                player.is_active = False
            elif wait >= 6000 and not player.isPlayingVideo():
                notification("Error playing file!")
                break
        if not removed_fake:
            utils.remove_fake(file_list, folder)
    else:
        notification("File deleted")
        time.sleep(1)
        xbmc.executebuiltin("Action(ParentDir)")
    return
示例#2
0
def play_video(params):
    get = params.get
    mode = get("mode")
    file_list = get("file_list")
    file_list = urllib.unquote_plus(file_list).split(";")
    play_list = get("play_list")
    play_list = urllib.unquote_plus(play_list).split(";")
    folder = get("folder")
    folder = urllib.unquote_plus(folder)
    # We might have deleted the path
    if os.path.exists(folder):
        # we trick xbmc to play avi by creating empty rars if the download is only partial
        utils.write_fake(file_list, folder)
        # Prepare potential file stacking
        if (len(play_list) > 2):
            rar = []
            for arch_rar, movie_file in zip(play_list[0::2], play_list[1::2]):
                raruri = "rar://" + utils.rarpath_fixer(
                    folder, arch_rar) + "/" + movie_file
                rar.append(raruri)
                raruri = 'stack://' + ' , '.join(rar)
        else:
            raruri = "rar://" + utils.rarpath_fixer(
                folder, play_list[0]) + "/" + play_list[1]
        item = xbmcgui.ListItem(play_list[1], iconImage='', thumbnailImage='')
        item.setInfo(type="Video", infoLabels={"Title": play_list[1]})
        item.setPath(raruri)
        item.setProperty("IsPlayable", "true")
        xbmcplugin.setContent(HANDLE, 'movies')
        time.sleep(1)
        if mode == MODE_AUTO_PLAY:
            xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(raruri, item)
        else:
            xbmcplugin.setResolvedUrl(handle=HANDLE,
                                      succeeded=True,
                                      listitem=item)
        wait = 0
        time.sleep(3)
        while (wait <= 10):
            time.sleep(1)
            wait += 1
            if xbmc.Player().isPlayingVideo():
                break
        # if the item is in the queue we remove the temp files
        utils.remove_fake(file_list, folder)
    else:
        # TODO Notification
        progressDialog = xbmcgui.DialogProgress()
        progressDialog.create('NZBS', 'File deleted')
        time.sleep(1)
        progressDialog.close()
        time.sleep(1)
        xbmc.executebuiltin("Action(ParentDir)")
    return
示例#3
0
def play_video(params):
    get = params.get
    mode = get("mode")
    file_list = get("file_list")
    file_list = urllib.unquote_plus(file_list).split(";")
    play_list = get("play_list")
    play_list = urllib.unquote_plus(play_list).split(";")
    folder = get("folder")
    folder = urllib.unquote_plus(folder)
    # We might have deleted the path
    if os.path.exists(folder):
        # we trick xbmc to play avi by creating empty rars if the download is only partial
        utils.write_fake(file_list, folder)
        # Prepare potential file stacking
        if (len(play_list) > 2):
            rar = []
            for arch_rar, movie_file in zip(play_list[0::2], play_list[1::2]):
                raruri = "rar://" + utils.rarpath_fixer(folder, arch_rar) + "/" + movie_file
                rar.append(raruri)
                raruri = 'stack://' + ' , '.join(rar)
        else:
            raruri = "rar://" + utils.rarpath_fixer(folder, play_list[0]) + "/" + play_list[1]
        item = xbmcgui.ListItem(play_list[1], iconImage='', thumbnailImage='')
        item.setInfo(type="Video", infoLabels={ "Title": play_list[1]})
        item.setPath(raruri)
        item.setProperty("IsPlayable", "true")
        xbmcplugin.setContent(HANDLE, 'movies')
        time.sleep(1)
        if mode == MODE_AUTO_PLAY:
            xbmc.Player( xbmc.PLAYER_CORE_DVDPLAYER ).play( raruri, item )
        else:
            xbmcplugin.setResolvedUrl(handle=HANDLE, succeeded=True, listitem=item)
        wait = 0
        time.sleep(3)
        while (wait <= 10):
            time.sleep(1)
            wait+= 1
            if xbmc.Player().isPlayingVideo():
                break
        # if the item is in the queue we remove the temp files
        utils.remove_fake(file_list, folder)
    else:
        # TODO Notification
        progressDialog = xbmcgui.DialogProgress()
        progressDialog.create('NZBS', 'File deleted')
        time.sleep(1)
        progressDialog.close()
        time.sleep(1)
        xbmc.executebuiltin("Action(ParentDir)")
    return
示例#4
0
def play_video(params):
    log("play_video: params: %s" % params)
    get = params.get
    mode = get("mode")
    file_list = get("file_list")
    file_list = utils.unquote_plus(file_list).split(";")
    play_list = get("play_list")
    play_list = utils.unquote_plus(play_list).split(";")
    folder = get("folder")
    folder = utils.unquote_plus(folder)
    # We might have deleted the path
    if utils.exists_incomplete(folder):
        if len(file_list) > 0 and not play_list[1].endswith(play_list[0]):
            # we trick xbmc to play avi by creating empty rars if the download is only partial
            utils.write_fake(file_list, folder)
            # Prepare potential file stacking
            if (len(play_list) > 2):
                rar = []
                for arch_rar, movie_file in zip(play_list[0::2], play_list[1::2]):
                    raruri = "rar://" + utils.rarpath_fixer(folder, arch_rar) + "/" + movie_file
                    rar.append(raruri)
                    raruri = 'stack://' + ' , '.join(rar)
            else:
                raruri = "rar://" + utils.rarpath_fixer(folder, play_list[0]) + "/" + play_list[1]
            uri = raruri
        else:
            # we have a plain file
            if (len(play_list) > 2):
                uri = "stack://%s" % ' , '.join(play_list[1::2])
            else:
                uri = play_list[1]
        log("play_video: uri: %s" % uri)
        info = nfo.NfoLabels()
        item = xbmcgui.ListItem(info.info_labels['title'], iconImage='DefaultVideo.png', thumbnailImage=info.thumbnail)
        item.setInfo(type="Video", infoLabels=info.info_labels)
        item.setPath(uri)
        item.setProperty("IsPlayable", "true")
        xbmcplugin.setContent(HANDLE, 'movies')
        wait = 0
        player = xbmcplayer.XBMCPlayer(xbmc.PLAYER_CORE_AUTO)
        player.sleep(1000)
        if mode == MODE_AUTO_PLAY or mode == MODE_LIST_PLAY:
            player.play( uri, item )
            log("play_video: player.play uri: %s" % uri)
        else:
            xbmcplugin.setResolvedUrl(handle=HANDLE, succeeded=True, listitem=item)
            log("play_video: setResolvedUrl uri: %s" % uri)
        removed_fake = False
        while player.is_active:
            player.sleep(500)
            wait+= 1
            if player.is_playing and not removed_fake:
                utils.remove_fake(file_list, folder)
                removed_fake = True
            if player.is_stopped:
                the_end(folder, player.is_stopped, params.get("nzoid"), params.get("nzoidhistory"))
                player.is_active = False
            elif player.is_ended:
                time.sleep(1)
                log("rassi: player.is_ended, player.is_stopped %s" % player.is_stopped)
                the_end(folder, True, params.get("nzoid"), params.get("nzoidhistory"))
                player.is_active = False
            elif wait >= 6000 and not player.isPlayingVideo():
                utils.notification("Error playing file!")
                break
        if not removed_fake:
            utils.remove_fake(file_list, folder)
    else:
        utils.notification("File deleted")
        time.sleep(1)
        xbmc.executebuiltin("Action(ParentDir)")
    return