torrent-downloader-react 1.0.16__py3-none-any.whl → 1.0.18__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,7 +73,9 @@ DOWNLOAD_PATH = get_downloads_dir()
73
73
 
74
74
  # Initialize libtorrent session
75
75
  session = lt.session()
76
- session.listen_on(6881, 6891)
76
+ settings = session.get_settings()
77
+ settings['listen_interfaces'] = '0.0.0.0:6881'
78
+ session.apply_settings(settings)
77
79
 
78
80
  # Store active torrents
79
81
  active_torrents: Dict[str, lt.torrent_handle] = {}
@@ -129,6 +131,8 @@ async def list_torrents() -> List[TorrentInfo]:
129
131
  state_str = "finished"
130
132
  elif status.state == lt.torrent_status.checking_files:
131
133
  state_str = "checking"
134
+ elif status.state == lt.torrent_status.paused:
135
+ state_str = "paused"
132
136
 
133
137
  info = TorrentInfo(
134
138
  id=torrent_id,
@@ -165,6 +169,40 @@ async def open_downloads():
165
169
  raise HTTPException(status_code=500, detail="Failed to open downloads folder")
166
170
  return {"message": "Downloads folder opened successfully"}
167
171
 
172
+ @app.post("/api/torrent/{torrent_id}/pause")
173
+ async def pause_torrent(torrent_id: str):
174
+ """Pause a specific torrent."""
175
+ if torrent_id not in active_torrents:
176
+ raise HTTPException(status_code=404, detail="Torrent not found")
177
+
178
+ handle = active_torrents[torrent_id]
179
+ handle.pause()
180
+ return {"message": "Torrent paused successfully"}
181
+
182
+ @app.post("/api/torrent/{torrent_id}/resume")
183
+ async def resume_torrent(torrent_id: str):
184
+ """Resume a specific torrent."""
185
+ if torrent_id not in active_torrents:
186
+ raise HTTPException(status_code=404, detail="Torrent not found")
187
+
188
+ handle = active_torrents[torrent_id]
189
+ handle.resume()
190
+ return {"message": "Torrent resumed successfully"}
191
+
192
+ @app.post("/api/torrent/pause-all")
193
+ async def pause_all_torrents():
194
+ """Pause all active torrents."""
195
+ for handle in active_torrents.values():
196
+ handle.pause()
197
+ return {"message": "All torrents paused successfully"}
198
+
199
+ @app.post("/api/torrent/resume-all")
200
+ async def resume_all_torrents():
201
+ """Resume all active torrents."""
202
+ for handle in active_torrents.values():
203
+ handle.resume()
204
+ return {"message": "All torrents resumed successfully"}
205
+
168
206
  def main():
169
207
  """Entry point for the application."""
170
208
  import uvicorn