chg: Cleanup passing listing key to and from bool in redis

pull/263/head
Raphaël Vinot 2021-09-10 14:20:58 +02:00
parent b59e73258d
commit d1f673f3a7
3 changed files with 7 additions and 12 deletions

View File

@ -62,10 +62,10 @@ class AsyncCapture(AbstractManager):
cookies_pseudofile=to_capture.get('cookies', None),
depth=int(to_capture.get('depth', 1)),
# By default, the captures are on the index, unless the user mark them as un-listed
listing=False if ('listing' in to_capture and to_capture['listing'] in ['False', '0']) else True,
listing=False if ('listing' in to_capture and to_capture['listing'].lower() in ['false', '0', '']) else True,
user_agent=to_capture.get('user_agent', None),
referer=to_capture.get('referer', ''),
proxy=to_capture.get('proxy', ''),
referer=to_capture.get('referer', None),
proxy=to_capture.get('proxy', None),
os=to_capture.get('os', None),
browser=to_capture.get('browser', None),
parent=to_capture.get('parent', None)
@ -83,7 +83,7 @@ class AsyncCapture(AbstractManager):
def _capture(self, url: str, *, perma_uuid: str, cookies_pseudofile: Optional[Union[BufferedIOBase, str]]=None,
depth: int=1, listing: bool=True, user_agent: Optional[str]=None,
referer: str='', proxy: str='', os: Optional[str]=None,
referer: Optional[str]=None, proxy: Optional[str]=None, os: Optional[str]=None,
browser: Optional[str]=None, parent: Optional[str]=None) -> Tuple[bool, str]:
'''Launch a capture'''
url = url.strip()

View File

@ -630,8 +630,7 @@ class Lookyloo():
p = self.redis.pipeline()
for key, value in query.items():
if isinstance(value, bool):
# Yes, empty string because that's False.
query[key] = 1 if value else ''
query[key] = 1 if value else 0
if isinstance(value, list):
query[key] = json.dumps(value)
if priority < -10:

View File

@ -345,12 +345,8 @@ class SubmitCapture(Resource):
if 'url' not in request.args or not request.args.get('url'):
return 'No "url" in the URL params, nothting to capture.', 400
try:
listing = int(request.args['listing'])
except Exception:
listing = 1
to_query = {'url': request.args['url'], 'listing': listing}
to_query = {'url': request.args['url'],
'listing': False if 'listing' in request.args and request.args['listing'] in [0, '0'] else True}
if request.args.get('user_agent'):
to_query['user_agent'] = request.args['user_agent']
if request.args.get('referer'):