mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-31 06:41:03 +00:00
feat: add ablity to pause and resume the seeding process
This commit is contained in:
@@ -121,6 +121,10 @@ class Handler(BaseHTTPRequestHandler):
|
||||
elif data['action'] == 'kill-torrent':
|
||||
torrent_downloader.abort_session()
|
||||
torrent_downloader = None
|
||||
elif data['action'] == 'pause-seeding':
|
||||
torrent_downloader.pause_seeding(data['game_id'])
|
||||
elif data['action'] == 'resume-seeding':
|
||||
torrent_downloader.resume_seeding(data['game_id'], data['magnet'], data['save_path'])
|
||||
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
|
||||
@@ -189,3 +189,16 @@ class TorrentDownloader:
|
||||
response.append(torrent_info)
|
||||
|
||||
return response
|
||||
|
||||
def pause_seeding(self, game_id: int):
|
||||
torrent_handle = self.torrent_handles.get(game_id)
|
||||
if torrent_handle:
|
||||
torrent_handle.pause()
|
||||
torrent_handle.unset_flags(lt.torrent_flags.auto_managed)
|
||||
|
||||
def resume_seeding(self, game_id: int, magnet: str, save_path: str):
|
||||
params = {'url': magnet, 'save_path': save_path, 'trackers': self.trackers}
|
||||
torrent_handle = self.session.add_torrent(params)
|
||||
self.torrent_handles[game_id] = torrent_handle
|
||||
torrent_handle.set_flags(lt.torrent_flags.auto_managed)
|
||||
torrent_handle.resume()
|
||||
|
||||
Reference in New Issue
Block a user