mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: add initial seeding logic and separation between seeding from downloading
This commit is contained in:
parent
83b7fb83ab
commit
bd8974c7cb
6 changed files with 64 additions and 3 deletions
|
|
@ -107,6 +107,8 @@ class Handler(BaseHTTPRequestHandler):
|
|||
elif data['action'] == 'kill-torrent':
|
||||
torrent_downloader.abort_session()
|
||||
torrent_downloader = None
|
||||
elif data['action'] == 'start-seeding':
|
||||
torrent_downloader.start_seeding(data['game_id'], data['magnet'], data['save_path'])
|
||||
|
||||
self.send_response(200)
|
||||
self.end_headers()
|
||||
|
|
|
|||
|
|
@ -163,3 +163,12 @@ class TorrentDownloader:
|
|||
self.downloading_game_id = -1
|
||||
|
||||
return response
|
||||
|
||||
def start_seeding(self, game_id: int, magnet: str, save_path: str):
|
||||
print("seed log 1")
|
||||
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.seed_mode)
|
||||
torrent_handle.resume()
|
||||
print("seed log 2")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue