11#!/usr/bin/python3
22import argparse
3+ from pathlib import Path
34
45from library import usage
56from library .mediafiles import torrents_start
@@ -76,7 +77,7 @@ def qbt_get_tracker(qbt_client, torrent):
7677
7778
7879def filter_torrents_by_activity (args , torrents ):
79- if ( args .downloading and args .uploading ) :
80+ if args .downloading and args .uploading :
8081 torrents = [t for t in torrents if t .downloaded_session > 0 and t .uploaded_session > 0 ]
8182 else :
8283 if args .active :
@@ -223,6 +224,8 @@ def gen_row(t):
223224 "last_activity" : strings .relative_datetime (t .last_activity ),
224225 "size" : strings .file_size (t .total_size ),
225226 "comment" : t .comment ,
227+ "download_path" : t .download_path ,
228+ "save_path" : t .save_path ,
226229 "content_path" : t .content_path ,
227230 }
228231
@@ -279,6 +282,8 @@ def gen_row(t):
279282 "size" : strings .file_size (t .total_size ),
280283 "remaining" : strings .file_size (t .amount_left ),
281284 "comment" : t .comment ,
285+ "download_path" : t .download_path ,
286+ "save_path" : t .save_path ,
282287 "content_path" : t .content_path ,
283288 }
284289
@@ -297,6 +302,38 @@ def gen_row(t):
297302 elif args .delete_rows :
298303 print ("Deleting from qBit" , len (torrents ))
299304 qbt_client .torrents_delete (delete_files = False , torrent_hashes = torrent_hashes )
300- elif args .force_start is not None :
305+
306+ if args .force_start is not None :
301307 print ("Force-starting" , len (torrents ))
302308 qbt_client .torrents_set_force_start (args .force_start , torrent_hashes = torrent_hashes )
309+
310+ if args .temp_drive and Path (args .temp_drive ).is_absolute ():
311+ temp_prefix = Path (args .temp_drive )
312+ else :
313+ temp_prefix = Path (args .download_drive )
314+ temp_prefix /= args .temp_prefix
315+ download_prefix = Path (args .download_drive ) / args .download_prefix
316+
317+ if "download_drive" not in args .defaults or "download_prefix" not in args .defaults :
318+ print ("Setting save path" , len (torrents ))
319+ for t in torrents :
320+ download_path = download_prefix
321+ if args .tracker_dirnames :
322+ domain = qbt_get_tracker (qbt_client , t )
323+ if domain :
324+ download_path /= domain
325+
326+ print (t .save_path , "==>" , download_path )
327+ qbt_client .torrents_set_save_path (download_path , torrent_hashes = torrent_hashes )
328+
329+ if "temp_drive" not in args .defaults or "temp_prefix" not in args .defaults :
330+ print ("Setting temp path" , len (torrents ))
331+ for t in torrents :
332+ temp_path = temp_prefix
333+ if args .tracker_dirnames :
334+ domain = qbt_get_tracker (qbt_client , t )
335+ if domain :
336+ temp_path /= domain
337+
338+ print (t .download_path , "==>" , temp_path )
339+ qbt_client .torrents_set_download_path (temp_path , torrent_hashes = torrent_hashes )
0 commit comments