@@ -31,6 +31,9 @@ def parse_config_file(text):
3131 config .add_section ('LocalDB' )
3232 config .set ('LocalDB' , 'enabled' , 'false' )
3333 config .set ('LocalDB' , 'path' , expanduser ('~/downloads/pirate-get/db' ))
34+
35+ config .add_section ('Search' )
36+ config .set ('Search' , 'total-results' , 50 )
3437
3538 config .add_section ('Misc' )
3639 # TODO: try to use configparser.BasicInterpolation
@@ -146,6 +149,9 @@ def parse_args(args_in):
146149 default = 1 , type = int ,
147150 help = 'the number of pages to fetch. '
148151 '(only used with --recent)' )
152+ parser .add_argument ('-r' , '--total-results' ,
153+ type = int ,
154+ help = 'maximum number of results to show' )
149155 parser .add_argument ('-L' , '--local' , dest = 'database' ,
150156 help = 'a csv file containing the Pirate Bay database '
151157 'downloaded from '
@@ -234,6 +240,10 @@ def combine_configs(config, args):
234240 if not args .timeout :
235241 args .timeout = int (config .get ('Misc' , 'timeout' ))
236242
243+ config_total_results = int (config .get ('Search' , 'total-results' ))
244+ if not args .total_results and config_total_results :
245+ args .total_results = config_total_results
246+
237247 args .transmission_command = ['transmission-remote' ]
238248 if args .endpoint :
239249 args .transmission_command .append (args .endpoint )
@@ -389,6 +399,9 @@ def pirate_main(args):
389399 print (json .dumps (results ))
390400 return
391401 else :
402+ # Results are sorted on the request, so it's safe to remove results here.
403+ if args .total_results :
404+ results = results [0 :args .total_results ]
392405 printer .search_results (results , local = args .source == 'local_tpb' )
393406
394407 # number of results to pick
0 commit comments