Ejemplo n.º 1
0
    def setup_engine(self):
        encryption = Encryption.ENABLED if self.__settings__.getSetting('encryption') == 'true' else Encryption.DISABLED

        if self.__settings__.getSetting("connections_limit") not in ["",0,"0"]:
            connections_limit = int(self.__settings__.getSetting("connections_limit"))
        else:
            connections_limit = None

        use_random_port = True if self.__settings__.getSetting('use_random_port') == 'true' else False

        listen_port=int(self.__settings__.getSetting("listen_port")) if self.__settings__.getSetting(
            "listen_port") != "" else 6881

        if '1' != self.__settings__.getSetting("keep_files") and 'Saved Files' not in self.storageDirectory:
            keep_complete = False
            keep_incomplete = False
        else:
            keep_complete = True
            keep_incomplete = True

        dht_routers = ["router.bittorrent.com:6881", "router.utorrent.com:6881"]
        user_agent = ''
        self.engine = Engine(uri=file_url(localize_path(self.torrentFile)), download_path=self.storageDirectory,
                             connections_limit=connections_limit,
                             encryption=encryption, keep_complete=keep_complete, keep_incomplete=keep_incomplete,
                             dht_routers=dht_routers, use_random_port=use_random_port, listen_port=listen_port,
                             user_agent=user_agent)
Ejemplo n.º 2
0
def get_files(t_url):
    engine = Engine(uri=t_url,download_path=temp_dir,bind_host='127.0.0.1',bind_port=5001)
    file_id = None
    files=[]
    try:
        with closing(engine):
            engine.start(0)
            files = engine.list(media_types=[MediaType.VIDEO])
            n=files[0].name
    except Error as err:
        print "Error"
        print err
    return files
Ejemplo n.º 3
0
    def setup_engine(self):
        #uri=None, binaries_path=None, platform=None, download_path=".",
        #bind_host='127.0.0.1', bind_port=5001, connections_limit=None, download_kbps=None, upload_kbps=None,
        #enable_dht=True, enable_lsd=True, enable_natpmp=True, enable_upnp=True, enable_scrape=False,
        #log_stats=False, encryption=Encryption.ENABLED, keep_complete=False, keep_incomplete=False,
        #keep_files=False, log_files_progress=False, log_overall_progress=False, log_pieces_progress=False,
        #listen_port=6881, use_random_port=False, max_idle_timeout=None, no_sparse=False, resume_file=None,
        #user_agent=None, startup_timeout=5, state_file=None, enable_utp=True, enable_tcp=True,
        #debug_alerts=False, logger=None, torrent_connect_boost=50, connection_speed=50,
        #peer_connect_timeout=15, request_timeout=20, min_reconnect_time=60, max_failcount=3,
        #dht_routers=None, trackers=None)

        encryption = Encryption.ENABLED if self.__settings__.getSetting('encryption') == 'true' else Encryption.DISABLED
        upload_limit = int(self.__settings__.getSetting("upload_limit"))*1024/8 if self.__settings__.getSetting(
            "upload_limit") != "" else 0
        download_limit = int(self.__settings__.getSetting("download_limit"))*1024/8 if self.__settings__.getSetting(
            "download_limit") != "" else 0

        if self.__settings__.getSetting("connections_limit") not in ["",0,"0"]:
            connections_limit = int(self.__settings__.getSetting("connections_limit"))
        else:
            connections_limit = None

        use_random_port = True if self.__settings__.getSetting('use_random_port') == 'true' else False

        listen_port=int(self.__settings__.getSetting("listen_port")) if self.__settings__.getSetting(
            "listen_port") != "" else 6881

        if '1' != self.__settings__.getSetting("keep_files") and 'Saved Files' not in self.userStorageDirectory:
            keep_complete = False
            keep_incomplete = False
            keep_files = False
            resume_file = None
        else:
            keep_complete = True
            keep_incomplete = True
            keep_files = True
            resume_file=os.path.join(self.userStorageDirectory, 'torrents', os.path.basename(self.torrentUrl)+'.resume_data')

        enable_dht = self.__settings__.getSetting("enable_dht") == 'true'
        dht_routers = ["router.bittorrent.com:6881","router.utorrent.com:6881"]
        user_agent = 'uTorrent/2200(24683)'
        self.pre_buffer_bytes = int(self.__settings__.getSetting("pre_buffer_bytes"))*1024*1024

        self.engine = Engine(uri=file_url(self.torrentUrl), download_path=self.userStorageDirectory,
                             connections_limit=connections_limit, download_kbps=download_limit, upload_kbps=upload_limit,
                             encryption=encryption, keep_complete=keep_complete, keep_incomplete=keep_incomplete,
                             dht_routers=dht_routers, use_random_port=use_random_port, listen_port=listen_port,
                             keep_files=keep_files, user_agent=user_agent, resume_file=resume_file, enable_dht=enable_dht)
Ejemplo n.º 4
0
def list(uri):
    # Create instance of Engine
    engine = Engine(uri)
    files = []
    # Ensure we'll close engine on exception
    with closing(engine):
        # Start engine
        engine.start()
        # Wait until files received
        while not files and not xbmc.abortRequested:
            # Will list only video files in torrent
            files = engine.list(media_types=[MediaType.VIDEO])
            # Check if there is loading torrent error and raise exception
            engine.check_torrent_error()
            xbmc.sleep(200)
    return files
Ejemplo n.º 5
0
    def setup_engine(self):

        encryption = Encryption.ENABLED if self.__settings__.getSetting('encryption') == 'true' else Encryption.DISABLED
        upload_limit = int(self.__settings__.getSetting("upload_limit"))*1024/8 if self.__settings__.getSetting(
            "upload_limit") != "" else 0
        download_limit = int(self.__settings__.getSetting("download_limit"))*1024/8 if self.__settings__.getSetting(
            "download_limit") != "" else 0

        if self.__settings__.getSetting("connections_limit") not in ["",0,"0"]:
            connections_limit = int(self.__settings__.getSetting("connections_limit"))
        else:
            connections_limit = None

        use_random_port = True if self.__settings__.getSetting('use_random_port') == 'true' else False

        listen_port=int(self.__settings__.getSetting("listen_port")) if self.__settings__.getSetting(
            "listen_port") != "" else 6881

        if '1' != self.__settings__.getSetting("keep_files") and 'Saved Files' not in self.userStorageDirectory:
            keep_complete = False
            keep_incomplete = False
            keep_files = False
            resume_file = None
        else:
            keep_complete = True
            keep_incomplete = True
            keep_files = True
            resume_file=os.path.join(self.userStorageDirectory, 'torrents', os.path.basename(self.torrentUrl)+'.resume_data')

        enable_dht = self.__settings__.getSetting("enable_dht") == 'true'
        dht_routers = ["router.bittorrent.com:6881","router.utorrent.com:6881"]
        user_agent = ''
        self.pre_buffer_bytes = int(self.__settings__.getSetting("pre_buffer_bytes"))*1024*1024

        self.engine = Engine(uri=file_url(self.torrentUrl), download_path=self.userStorageDirectory,
                             connections_limit=connections_limit, download_kbps=download_limit, upload_kbps=upload_limit,
                             encryption=encryption, keep_complete=keep_complete, keep_incomplete=keep_incomplete,
                             dht_routers=dht_routers, use_random_port=use_random_port, listen_port=listen_port,
                             keep_files=keep_files, user_agent=user_agent, resume_file=resume_file, enable_dht=enable_dht)
    def _AddTorrent(self, path):

        if filesystem.exists(path):
            if path.startswith(r'\\') or '://' in path:
                tempPath = xbmc.translatePath('special://temp').decode('utf-8')
                destPath = filesystem.join(tempPath, 't2h.torrent')
                filesystem.copyfile(path, destPath)
                path = destPath

            uri = path2url(path)
        else:
            uri = path

        self.debug('AddTorrent: ' + uri)

        add_trackers = []
        if getSetting('add_tracker'):
            add_trackers.append(getSetting('add_tracker'))

        download_path = self.settings.storage_path
        if download_path == '':
            download_path = xbmc.translatePath('special://temp')

        self.debug('download_path: %s' % download_path)
        self.download_path = download_path

        encryption = self.debug_assignment(
            Encryption.ENABLED if getSetting('encryption') == 'true' else
            Encryption.DISABLED, 'encryption')
        upload_limit = self.debug_assignment(
            int(getSetting("upload_limit")) *
            1024 if getSetting("upload_limit") != "" else 0, "upload_limit")
        download_limit = self.debug_assignment(
            int(getSetting("download_limit")) *
            1024 if getSetting("download_limit") != "" else 0,
            "download_limit")

        if getSetting("connections_limit") not in ["", 0, "0"]:
            connections_limit = self.debug_assignment(
                int(getSetting("connections_limit")), "connections_limit")
        else:
            connections_limit = None

        use_random_port = self.debug_assignment(
            True if getSetting('use_random_port') == 'true' else False,
            'use_random_port')
        listen_port = self.debug_assignment(
            int(getSetting("listen_port"))
            if getSetting("listen_port") != "" else 62881, "listen_port")
        if listen_port == 6881:
            use_random_port = True

        keep_files = getSetting('action_files').decode('utf-8') != u'удалить'

        args = {
            'uri': uri,
            'download_path': download_path,
            'user_agent': user_agent,
            'encryption': encryption,
            'upload_kbps': upload_limit,
            'download_kbps': download_limit,
            'connections_limit': connections_limit,
            'keep_incomplete': False,
            'keep_complete': keep_files,
            'keep_files': keep_files,
            'dht_routers': dht_routers,
            'use_random_port': use_random_port,
            'listen_port': listen_port,
            'log_files_progress': True,
            'trackers': add_trackers,
            'startup_timeout': 1000
        }

        try:
            if keep_files:
                args['resume_file'] = filesystem.join(
                    self.settings.torrents_path(), self.info_hash + '.resume')
        except BaseException as e:
            log.print_tb(e)
            if keep_files:
                args['resume_file'] = filesystem.join(
                    download_path, self.info_hash + '.resume')

        if args.get('resume_file'):
            self.debug('resume file is: ' + args['resume_file'])

        self.engine = Engine(**args)
Ejemplo n.º 7
0
def sub_play(params):
    if params['r'][:4] == 'http':
        purl = urllib.unquote_plus(params['r'])
        item = xbmcgui.ListItem(path=purl)
        xbmcplugin.setResolvedUrl(handle, True, item)
        return

    if params['r'][:4] == 'myvi':
        url = urllib.unquote_plus(params['r']).replace('myvi', 'http')
        data = get_myvi_data(url)

        item = xbmcgui.ListItem(path=data['url'])
        xbmcplugin.setResolvedUrl(handle, True, item)
        return

    file_id = int(params.get('i', 0))
    uri = sections['get_torrent'] + '/' + params['r'] + '/' + params['t']

    torrent = get_html(uri)

    temp_name = os.path.join(xt('special://masterprofile'), 'shiza.torrent')

    temp_file = open(
        temp_name.decode('utf-8') if sys.platform == 'win32' else temp_name,
        "wb")
    temp_file.write(torrent)
    temp_file.close()

    uri = 'file://' + temp_name.replace('\\', '//')

    if addon.getSetting('Engine') == '1':
        sub_play_yatp(uri, file_id)
        return

    if addon.getSetting('Engine') == '2':
        sub_play_tam(temp_name, file_id)
        return

    if addon.getSetting('Engine') == '3':
        sub_play_elem(temp_name, file_id)
        return

    #, cwd=os.path.dirname(binary_path)) in torrent2html engine.py

    from torrent2http import State, Engine, MediaType
    progressBar = xbmcgui.DialogProgress()
    from contextlib import closing
    DDir = xt('special://masterprofile')

    progressBar.create('Torrent2Http', 'Запуск')
    # XBMC addon handle
    # handle = ...
    # Playable list item
    # listitem = ...
    # We can know file_id of needed video file on this step, if no, we'll try to detect one.
    # file_id = None
    # Flag will set to True when engine is ready to resolve URL to XBMC
    ready = False
    # Set pre-buffer size to 24Mb. This is a size of file that need to be downloaded before we resolve URL to XMBC
    pre_buffer_bytes = 24 * 1024 * 1024

    engine = Engine(uri, download_path=DDir)
    with closing(engine):
        # Start engine and instruct torrent2http to begin download first file,
        # so it can start searching and connecting to peers
        engine.start(file_id)
        progressBar.update(0, 'Torrent2Http', 'Загрузка торрента', "")
        while not xbmc.abortRequested and not ready:
            xbmc.sleep(500)

            if progressBar.iscanceled():
                ready = False
                break

            status = engine.status()
            # Check if there is loading torrent error and raise exception
            engine.check_torrent_error(status)
            # Trying to detect file_id
            if file_id is None:
                # Get torrent files list, filtered by video file type only
                files = engine.list(media_types=[MediaType.VIDEO])
                # If torrent metadata is not loaded yet then continue
                if files is None:
                    continue
                # Torrent has no video files
                if not files:
                    progressBar.close()
                    break
                # Select first matching file
                file_id = files[0].index
                file_status = files[0]
            else:
                # If we've got file_id already, get file status
                file_status = engine.file_status(file_id)
                # If torrent metadata is not loaded yet then continue
                if not file_status:
                    continue
            if status.state == State.DOWNLOADING:
                # Wait until minimum pre_buffer_bytes downloaded before we resolve URL to XBMC
                if file_status.download >= pre_buffer_bytes:
                    ready = True
                    break
                #print file_status
                #downloadedSize = status.total_download / 1024 / 1024
                getDownloadRate = status.download_rate / 1024 * 8
                #getUploadRate = status.upload_rate / 1024 * 8
                getSeeds = status.num_seeds

                progressBar.update(
                    100 * file_status.download / pre_buffer_bytes,
                    'Предварительная буферизация: ' +
                    str(file_status.download / 1024 / 1024) + " MB",
                    "Сиды: " + str(getSeeds),
                    "Скорость: " + str(getDownloadRate)[:4] + ' Mbit/s')

            elif status.state in [State.FINISHED, State.SEEDING]:
                #progressBar.update(0, 'T2Http', 'We have already downloaded file', "")
                # We have already downloaded file
                ready = True
                break

            # Here you can update pre-buffer progress dialog, for example.
            # Note that State.CHECKING also need waiting until fully finished, so it better to use resume_file option
            # for engine to avoid CHECKING state if possible.
            # ...
        progressBar.update(0)
        progressBar.close()
        if ready:
            # Resolve URL to XBMC
            item = xbmcgui.ListItem(path=file_status.url)
            xbmcplugin.setResolvedUrl(handle, True, item)
            xbmc.sleep(3000)
            # Wait until playing finished or abort requested
            while not xbmc.abortRequested and xbmc.Player().isPlaying():
                xbmc.sleep(500)
Ejemplo n.º 8
0
def play(uri, handle, file_id=0, DDir=""):
    if DDir == "":
        DDir = os.path.join(xbmc.translatePath("special://home/"), "userdata")
    progressBar.create('Torrent2Http', 'Запуск')
    # XBMC addon handle
    # handle = ...
    # Playable list item
    # listitem = ...
    # We can know file_id of needed video file on this step, if no, we'll try to detect one.
    # file_id = None
    # Flag will set to True when engine is ready to resolve URL to XBMC
    ready = False
    # Set pre-buffer size to 15Mb. This is a size of file that need to be downloaded before we resolve URL to XMBC
    pre_buffer_bytes = 15 * 1024 * 1024
    engine = Engine(uri, download_path=DDir)
    with closing(engine):
        # Start engine and instruct torrent2http to begin download first file,
        # so it can start searching and connecting to peers
        engine.start(file_id)
        progressBar.update(0, 'Torrent2Http', 'Загрузка торрента', "")
        while not xbmc.abortRequested and not ready:
            xbmc.sleep(500)
            status = engine.status()
            # Check if there is loading torrent error and raise exception
            engine.check_torrent_error(status)
            # Trying to detect file_id
            if file_id is None:
                # Get torrent files list, filtered by video file type only
                files = engine.list(media_types=[MediaType.VIDEO])
                # If torrent metadata is not loaded yet then continue
                if files is None:
                    continue
                # Torrent has no video files
                if not files:
                    break
                    progressBar.close()
                # Select first matching file
                file_id = files[0].index
                file_status = files[0]
            else:
                # If we've got file_id already, get file status
                file_status = engine.file_status(file_id)
                # If torrent metadata is not loaded yet then continue
                if not file_status:
                    continue
            if status.state == State.DOWNLOADING:
                # Wait until minimum pre_buffer_bytes downloaded before we resolve URL to XBMC
                if file_status.download >= pre_buffer_bytes:
                    ready = True
                    break
                print file_status
                progressBar.update(
                    100 * file_status.download / pre_buffer_bytes,
                    'Torrent2Http',
                    xt('Предварительная буферизация: ' +
                       str(file_status.download / 1024 / 1024) + " MB"), "")

            elif status.state in [State.FINISHED, State.SEEDING]:
                #progressBar.update(0, 'T2Http', 'We have already downloaded file', "")
                # We have already downloaded file
                ready = True
                break

            if progressBar.iscanceled():
                progressBar.update(0)
                progressBar.close()
                break
            # Here you can update pre-buffer progress dialog, for example.
            # Note that State.CHECKING also need waiting until fully finished, so it better to use resume_file option
            # for engine to avoid CHECKING state if possible.
            # ...
        progressBar.update(0)
        progressBar.close()
        if ready:
            # Resolve URL to XBMC
            #listitem = xbmcgui.ListItem(path=file_status.url)
            #xbmcplugin.SetResolvedUrl(handle, True, listitem)
            xbmc.Player().play(file_status.url)
            # Wait until playing finished or abort requested
            while not xbmc.abortRequested and xbmc.Player().isPlaying():
                xbmc.sleep(500)
Ejemplo n.º 9
0
        #selfile="file://"+get_tor(slink,ref)
        t=get_files(selfile)
        for f in t:
            url=build_url({'mode':'playtorrent', 'sname':f.name, 'sid':f.index, 'slink':selfile})
            add_link(url,f.name)
        endoflist()    
    else:
        print "no url entered"

elif mode[0] == 'playtorrent':
    surl=args['slink'][0]
    sname=args['sname'][0]
    sid=int(args['sid'][0])
    ready = False
    pre_buffer_bytes = 15*1024*1024
    engine = Engine(uri=surl,download_path=temp_dir,bind_host='127.0.0.1',bind_port=5001)
     
    progress = xbmcgui.DialogProgress()
    progress.create('Downloading', 'Prebuffering...')
    
    try:
        with closing(engine):
            engine.start(sid)
            #xbmcgui.DialogProgress()
            while not xbmc.abortRequested and not ready and not progress.iscanceled():
                xbmc.sleep(500)
                status = engine.status()
                print "Status:",status
                engine.check_torrent_error(status)
                files = engine.list(media_types=[MediaType.VIDEO])
                file_status = engine.file_status(sid)
Ejemplo n.º 10
0
    def play(self, uri, item, subtitle=None, subtitle_provider=None):
        #
        torrent2http_options = {
            "uri": str(uri),
            # Files
            "download_path": xbmc.validatePath(xbmc.translatePath(__addon__.getSetting("download_path"))) or CACHE_DIR,
            "keep_files": __addon__.getSetting("keep_files") == 'true' and True or False,
            "keep_complete": __addon__.getSetting("keep_complete") == 'true' and True or False,
            "keep_incomplete": __addon__.getSetting("keep_incomplete") == 'true' and True or False,
            # Network
            "download_kbps": int(__addon__.getSetting("download_kbps")) or 0,
            "upload_kbps":  int(__addon__.getSetting("upload_kbps")) or 0,
            "connections_limit": int(__addon__.getSetting("connections_limit")) or 200,
            "encryption": int(__addon__.getSetting("encryption")) or 1,
            # Port
            "listen_port": int(__addon__.getSetting("listen_port")) or 6881,
            "use_random_port": __addon__.getSetting("use_random_port") == 'true' and True or False,
            # Peers
            "torrent_connect_boost": int(__addon__.getSetting("torrent_connect_boost")) or 50,
            "connection_speed": int(__addon__.getSetting("connection_speed")) or 50,
            "peer_connect_timeout": int(__addon__.getSetting("peer_connect_timeout")) or 15,
            "min_reconnect_time": int(__addon__.getSetting("min_reconnect_time")) or 60,
            "max_failcount": int(__addon__.getSetting("max_failcount")) or 3,
            # Features
            "enable_tcp": __addon__.getSetting("enable_tcp") == 'true' and False or True,
            "enable_dht": __addon__.getSetting("enable_dht") == 'true' and False or True,
            "enable_lsd": __addon__.getSetting("enable_lsd") == 'true' and False or True,
            "enable_utp": __addon__.getSetting("enable_utp") == 'true' and False or True,
            "enable_scrape": __addon__.getSetting("enable_scrape") == 'true' and True or False,
            "enable_upnp": __addon__.getSetting("enable_upnp") == 'true' and False or True,
            "enable_natpmp": __addon__.getSetting("enable_natpmp") == 'true' and False or True,
            # Additional
            "trackers": not __addon__.getSetting("trackers") == "" and __addon__.getSetting['trackers'].split(',') or None,
            "dht_routers": not __addon__.getSetting("dht_routers") == "" and __addon__.getSetting['dht_routers'].split(',') or None,
            # Log / Debug
            "log_stats": __addon__.getSetting("debug") == 'true' and True or False,
            "debug_alerts": __addon__.getSetting("debug_alerts") == 'true' and True or False,
            # Bin
            "binaries_path": os.path.join(RESOURCES_PATH, 'bin')
        }
        # List item
        self.item = item

        ###
        if torrent2http_options['download_kbps'] <= 0:
            torrent2http_options['download_kbps'] = None

        if torrent2http_options['upload_kbps'] <= 0:
            torrent2http_options['upload_kbps'] = None
        elif torrent2http_options['upload_kbps'] < 15:
            notify(__addon__.getLocalizedString(30313))
            torrent2http_options['upload_kbps'] = 15
            __addon__.setSetting('upload_kbps', '15')

        log('(Player) Start the torrent2http file', xbmc.LOGDEBUG)
        with closing(Engine(**torrent2http_options)) as engine:
            # Start engine and instruct torrent2http to begin download first file
            engine.start(0)

            log('(Player) Pre-Loading the movie', xbmc.LOGDEBUG)
            ready = False
            with closing(SafeDialogProgress(delay_create=0)) as dialog:
                dialog.create(self.item['info']['title'])
                dialog.update(self.progressed, *self._get_status_lines())

                file_id = None
                while not xbmc.abortRequested and not dialog.iscanceled():
                    xbmc.sleep(self.progressSleepTime)

                    # Get status
                    status = engine.status()
                    # Check if there is loading error and raise exception 
                    engine.check_torrent_error(status)

                    # We need a file id
                    if file_id is None:
                        # Get torrent files list, filtered by video file type only
                        files = engine.list(media_types=[MediaType.VIDEO])
                        if files is None:
                            continue
                        # Torrent has no video files
                        if not files:
                            raise AnErrorOccurred(30316)
                        # Select first matching file                    
                        file_id = files[0].index
                        file_status = files[0]

                    # Get file status
                    file_status = engine.file_status(file_id)
                    if not file_status:
                        continue

                    if status.state == State.DOWNLOADING:
                        self._calculate_progress(int(self.item['info'].get('duration', 0)), status, file_status)
                        if self.progressed >= 100:
                            ready = True
                            break
                        dialog.update(int(self.progressed), *self._get_status_lines(status))
                        continue

                    if status.state in [State.FINISHED, State.SEEDING]:
                        ready = True
                        break

                if ready:
                    log('(Player) Finished with pre-loading the movie', xbmc.LOGDEBUG)
                    # Download subtitle
                    if subtitle:
                        log('(Player) Download subtitle', xbmc.LOGDEBUG)
                        dialog.update(99, *[__addon__.getLocalizedString(30019), ' ', ' '])
                        path = file_status.save_path
                        subtitle = subtitle_provider.download(subtitle, os.path.dirname(path), ".".join([os.path.splitext(os.path.basename(path))[0], self.item['stream_info']['subtitle']['language']]))
                    dialog.update(100, *[__addon__.getLocalizedString(30020), ' ', ' '])
                elif xbmc.abortRequested or dialog.iscanceled():
                    log('(Player) Pre-Loading was canceled or interrupted', xbmc.LOGDEBUG)

            if ready:
                # Resolve URL to XBMC
                self.item.update({"path": file_status.url})

                # Starts the playback
                log('(Player) Start the playback', xbmc.LOGDEBUG)
                #xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, self.item)
                plugin.set_resolved_url(self.item)
                for _ in xrange(60):
                    if not self.isPlaying():
                        xbmc.sleep(1000)
                        continue

                    if subtitle:
                        log('(Player) Adds the subtitle to the player', xbmc.LOGDEBUG)
                        self.setSubtitles(subtitle)

                    # Wait for the playback to finish
                    log('(Player) Wait for the playback to finish', xbmc.LOGDEBUG)
                    with closing(OverlayText()) as self.overlay:
                        while not xbmc.abortRequested and self.isPlaying():
                            if self.overlay.isShowing():
                                self.overlay.setText("\n".join(self._get_status_lines(engine.status())))
                            xbmc.sleep(100)

                    log('(Player) Playback is finished', xbmc.LOGDEBUG)
                    if subtitle and torrent2http_options["keep_files"] == False and torrent2http_options["keep_complete"] == False and torrent2http_options["keep_incomplete"] == False:
                        # Delete subtitle
                        log('(Player) Delete subtitle', xbmc.LOGDEBUG)
                        subtitle_provider.remove(subtitle)
                    break
                else:
                    log('(Player) Playback is terminated due to timeout', xbmc.LOGERROR)