Beispiel #1
0
    async def add_torrent(self, torrent_file, download_path, name):
        if not self._initialized:
            message = 'Unable to add torrent in {}: not fully started up yet.'.format(
                self._name)
            logger.error(message)
            raise Exception(message)

        logger.info('Adding torrent in {}', self._name)
        t_torrent = await self._executor.add_torrent(torrent_file,
                                                     download_path, name)
        info_hash = t_torrent.hashString
        self._deleted_info_hashes.discard(info_hash)

        batch = TorrentBatchUpdate()
        torrent_data = self._register_t_torrent_update(batch, t_torrent)
        self._orchestrator.on_torrent_batch_update(self, batch)
        return torrent_data.to_dict()
Beispiel #2
0
    async def remove_torrent(self, info_hash):
        if not self._initialized:
            message = 'Unable to delete torrent {} from {}: not fully started up yet.'.format(
                info_hash, self._name)
            logger.error(message)
            raise Exception(message)

        logger.info('Deleting torrent {} from {}', info_hash, self._name)
        torrent_state = self._torrent_states[info_hash]
        await self._executor.remove_torrent(torrent_state.transmission_id)
        self.clean_torrent_directories(torrent_state.download_path,
                                       torrent_state.name)
        self._deleted_info_hashes.add(info_hash)

        batch = TorrentBatchUpdate()
        self._register_t_torrent_delete(batch, info_hash)
        self._orchestrator.on_torrent_batch_update(self, batch)
Beispiel #3
0
 async def pause_torrent(self, info_hash):
     data = await self._exec(self._session.pause_torrent, info_hash)
     batch = TorrentBatchUpdate()
     batch.updated[data['info_hash']] = data
     self._orchestrator.on_torrent_batch_update(self, batch)