From 6d7a38a912d1a0d84e96bc023f9d71b576deed7e Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Tue, 28 Dec 2021 14:33:05 +0100 Subject: [PATCH] [pylint] Bing (Videos) engine Fix remarks from pylint and remove obsolete try/except block Signed-off-by: Markus Heiser --- searx/engines/bing_videos.py | 38 +++++++++++++++++------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/searx/engines/bing_videos.py b/searx/engines/bing_videos.py index 7f8820546..184f564df 100644 --- a/searx/engines/bing_videos.py +++ b/searx/engines/bing_videos.py @@ -1,12 +1,14 @@ # SPDX-License-Identifier: AGPL-3.0-or-later -""" - Bing (Videos) +# lint: pylint +"""Bing (Videos) + """ from json import loads -from lxml import html from urllib.parse import urlencode +from lxml import html + from searx.utils import match_language from searx.engines.bing import language_aliases @@ -82,22 +84,18 @@ def response(resp): dom = html.fromstring(resp.text) for result in dom.xpath('//div[@class="dg_u"]'): - try: - metadata = loads(result.xpath('.//div[@class="vrhdata"]/@vrhm')[0]) - info = ' - '.join(result.xpath('.//div[@class="mc_vtvc_meta_block"]//span/text()')).strip() - content = '{0} - {1}'.format(metadata['du'], info) - thumbnail = '{0}th?id={1}'.format(base_url, metadata['thid']) - results.append( - { - 'url': metadata['murl'], - 'thumbnail': thumbnail, - 'title': metadata.get('vt', ''), - 'content': content, - 'template': 'videos.html', - } - ) - - except: - continue + metadata = loads(result.xpath('.//div[@class="vrhdata"]/@vrhm')[0]) + info = ' - '.join(result.xpath('.//div[@class="mc_vtvc_meta_block"]//span/text()')).strip() + content = '{0} - {1}'.format(metadata['du'], info) + thumbnail = '{0}th?id={1}'.format(base_url, metadata['thid']) + results.append( + { + 'url': metadata['murl'], + 'thumbnail': thumbnail, + 'title': metadata.get('vt', ''), + 'content': content, + 'template': 'videos.html', + } + ) return results