Let a custom limit be specified as parameter

master
Sven Slootweg 11 years ago
parent 0644f18201
commit e85eeb3bb2

@ -18,7 +18,9 @@ main.py.
## Usage ## Usage
You can use nzbspider with either a release list or a configuration You can use nzbspider with either a release list or a configuration
file. Using `--iplist` you can specify a newline-delimited file that file.
Using `--iplist` you can specify a newline-delimited file that
contains all the available IPs on your machine. nzbspider will randomly contains all the available IPs on your machine. nzbspider will randomly
pick one for every search query. If not specified, the OS default is pick one for every search query. If not specified, the OS default is
used. used.
@ -68,6 +70,9 @@ Note that these searches are run against your own database, not directly
against the NZB indexing sites! You'll still need a list of valid against the NZB indexing sites! You'll still need a list of valid
release names pre-filled in your database. release names pre-filled in your database.
Using `--limit` you can override the default limit of matched results.
The default is the 250 newest results.
## Notes ## Notes
The script will assume that all releasenames in your database are safe The script will assume that all releasenames in your database are safe

@ -9,6 +9,7 @@ parser.add_argument("--config", dest="config", action="store", help="Use a confi
parser.add_argument("--list", dest="list", action="store", help="Use a newline-delimited list of releases as source") parser.add_argument("--list", dest="list", action="store", help="Use a newline-delimited list of releases as source")
parser.add_argument("--target", dest="target", action="store", help="Where to save the NZBs (only needed in list mode)") parser.add_argument("--target", dest="target", action="store", help="Where to save the NZBs (only needed in list mode)")
parser.add_argument("--iplist", dest="iplist", action="store", help="Bind every request to a random IP from a newline-delimited list") parser.add_argument("--iplist", dest="iplist", action="store", help="Bind every request to a random IP from a newline-delimited list")
parser.add_argument("--limit", dest="limit", action="store", help="How many records to select in configuration file mode, at most (default: 250)", default=250)
args = parser.parse_args() args = parser.parse_args()
if args.config is not None: if args.config is not None:
@ -64,10 +65,12 @@ if mode == "config":
fields.append("`section` LIKE ?") fields.append("`section` LIKE ?")
values.append("%" + section + "%") values.append("%" + section + "%")
values.append(args.limit)
if len(fields) == 0: if len(fields) == 0:
db_query = "SELECT `release` FROM %s WHERE `time` < (UNIX_TIMESTAMP(NOW()) - 86400) ORDER BY `time` DESC LIMIT 250" % conf['db']['table'] db_query = "SELECT `release` FROM %s WHERE `time` < (UNIX_TIMESTAMP(NOW()) - 86400) ORDER BY `time` DESC LIMIT ?" % conf['db']['table']
else: else:
db_query = "SELECT `release` FROM %s WHERE %s AND `time` < (UNIX_TIMESTAMP(NOW()) - 86400) ORDER BY `time` DESC LIMIT 250" % (conf['db']['table'], " AND ".join(fields)) db_query = "SELECT `release` FROM %s WHERE %s AND `time` < (UNIX_TIMESTAMP(NOW()) - 86400) ORDER BY `time` DESC LIMIT ?" % (conf['db']['table'], " AND ".join(fields))
c.execute(db_query, values) c.execute(db_query, values)

Loading…
Cancel
Save