Skip to content

Commit c9951ce

Browse files
committed
feat: auto make torrent and add it to qb
1 parent d1b2826 commit c9951ce

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

animepipeline/bt/qb.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def make_torrent_file(file_path: Union[str, Path], torrent_file_save_path: Union
131131
"""
132132
if not Path(file_path).exists():
133133
logger.error(f"File {file_path} does not exist.")
134-
return ""
134+
raise FileNotFoundError(f"File {file_path} does not exist.")
135135

136136
new_torrent = Torrent.create_from(file_path)
137137
logger.info(f"Editing torrent file: {file_path} ...")

animepipeline/loop.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,15 @@ async def pipeline_post(self, task_info: TaskInfo) -> None:
254254
finalrip_downloaded_path = Path(task_info.download_path) / task_status.finalrip_downloaded_path
255255
torrent_file_save_path = Path(task_info.download_path) / (str(finalrip_downloaded_path.name) + ".torrent")
256256

257-
torrent_file_hash = QBittorrentManager.make_torrent_file(
258-
file_path=finalrip_downloaded_path,
259-
torrent_file_save_path=torrent_file_save_path,
260-
)
261-
logger.info(f"Torrent file created: {torrent_file_save_path}, hash: {torrent_file_hash}")
257+
try:
258+
torrent_file_hash = QBittorrentManager.make_torrent_file(
259+
file_path=finalrip_downloaded_path,
260+
torrent_file_save_path=torrent_file_save_path,
261+
)
262+
logger.info(f"Torrent file created: {torrent_file_save_path}, hash: {torrent_file_hash}")
263+
except Exception as e:
264+
logger.error(f"Failed to create torrent file: {e}")
265+
raise e
262266

263267
self.qbittorrent_manager.add_torrent(torrent_hash=torrent_file_hash, torrent_file_path=torrent_file_save_path)
264268

0 commit comments

Comments
 (0)