Skip to content

Commit 538d3e5

Browse files
committed
feat: set libtorrent flags
1 parent 60e0b39 commit 538d3e5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

python_rpc/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
if start_seeding_payload:
3737
initial_seeding = json.loads(urllib.parse.unquote(start_seeding_payload))
3838
for seed in initial_seeding:
39-
torrent_downloader = TorrentDownloader(torrent_session)
39+
torrent_downloader = TorrentDownloader(torrent_session, lt.torrent_flags.upload_mode)
4040
downloads[seed['game_id']] = torrent_downloader
4141
torrent_downloader.start_download(seed['url'], seed['save_path'], "")
4242

@@ -156,7 +156,7 @@ def action():
156156
if downloader:
157157
downloader.cancel_download()
158158
elif action == 'resume_seeding':
159-
torrent_downloader = TorrentDownloader(torrent_session)
159+
torrent_downloader = TorrentDownloader(torrent_session, lt.torrent_flags.upload_mode)
160160
downloads[game_id] = torrent_downloader
161161
torrent_downloader.start_download(data['url'], data['save_path'], "")
162162
elif action == 'pause_seeding':

python_rpc/torrent_downloader.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import libtorrent as lt
22

33
class TorrentDownloader:
4-
def __init__(self, torrent_session):
4+
def __init__(self, torrent_session, flags = lt.torrent_flags.auto_managed):
55
self.torrent_handle = None
66
self.session = torrent_session
7+
self.flags = flags
78
self.trackers = [
89
"udp://tracker.opentrackr.org:1337/announce",
910
"http://tracker.opentrackr.org:1337/announce",
@@ -102,9 +103,8 @@ def __init__(self, torrent_session):
102103
]
103104

104105
def start_download(self, magnet: str, save_path: str, header: str):
105-
params = {'url': magnet, 'save_path': save_path, 'trackers': self.trackers}
106+
params = {'url': magnet, 'save_path': save_path, 'trackers': self.trackers, 'flags': self.flags}
106107
self.torrent_handle = self.session.add_torrent(params)
107-
self.torrent_handle.set_flags(lt.torrent_flags.auto_managed)
108108
self.torrent_handle.resume()
109109

110110
def pause_download(self):

0 commit comments

Comments
 (0)