From 06ee868acf5cee242b2fe4f5b555bc3d0a62f16b Mon Sep 17 00:00:00 2001 From: ediw8311xht Date: Thu, 25 Apr 2024 14:16:34 -0400 Subject: [PATCH] added onlyfile option for deluge-console --- deluge/ui/console/cmdline/commands/info.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/deluge/ui/console/cmdline/commands/info.py b/deluge/ui/console/cmdline/commands/info.py index 7ea9a6773e..07e7145cef 100644 --- a/deluge/ui/console/cmdline/commands/info.py +++ b/deluge/ui/console/cmdline/commands/info.py @@ -106,6 +106,14 @@ def add_arguments(self, parser): dest='detailed', help=_('Show more detailed information including files and peers.'), ) + parser.add_argument( + '-f', + '--onlyfiles', + action='store_true', + default=False, + dest='onlyfiles', + help=_('Output only files used by torrent'), + ) parser.add_argument( '-s', '--state', @@ -179,7 +187,7 @@ def on_torrents_status(status): key=lambda x: x[1].get(sort_key), reverse=sort_reverse, ): - self.show_info(key, status[key], options.verbose, options.detailed) + self.show_info(key, status[key], options.verbose, options.detailed, options.onlyfiles) def on_torrents_status_fail(reason): self.console.write('{!error!}Error getting torrent info: %s' % reason) @@ -316,7 +324,7 @@ def show_peer_info(self, torrent_id, status): self.console.write(s[:-1]) - def show_info(self, torrent_id, status, verbose=False, detailed=False): + def show_info(self, torrent_id, status, verbose=False, detailed=False, onlyfiles=False): """ Writes out the torrents information to the screen. @@ -331,7 +339,10 @@ def show_info(self, torrent_id, status, verbose=False, detailed=False): sep = ' ' - if verbose or detailed: + if onlyfiles: + for index, torrent_file in enumerate(status['files']): + self.console.write(status['download_location'] + "/" + torrent_file['path']) + elif verbose or detailed: self.console.write('{!info!}Name: {!input!}%s' % (status['name'])) self.console.write('{!info!}ID: {!input!}%s' % (torrent_id)) s = '{{!info!}}State: {}{}'.format(