From 85e3d65f2af8559d841ebc8c1e8a1e85f27e6292 Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Thu, 26 Jan 2023 23:27:58 +0100 Subject: [PATCH] Show url when failed --- commands/pygg.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/commands/pygg.py b/commands/pygg.py index b523a68..35c6c55 100755 --- a/commands/pygg.py +++ b/commands/pygg.py @@ -126,7 +126,15 @@ def search_ygg(query, multi, full): if multi: ygg_params["option_langue:multiple[]"] = "4" - req = session.get(f"https://{YGG_DOMAIN}/engine/search", params=ygg_params) + try: + req = session.get(f"https://{YGG_DOMAIN}/engine/search", params=ygg_params) + except requests.RequestException as e: + print( + f"Request failed. {e}\n" + f"https://{YGG_DOMAIN}/engine/search?{urllib.parse.urlencode(ygg_params)}" + ) + return + html = bs4.BeautifulSoup( req.text, "html.parser",