@@ -11,6 +11,7 @@
1111from urllib import quote_plus
1212from lxml import html
1313from searx.engines.xpath import extract_text
14+from searx.utils import list_get
1415
1516# engine dependent config
1617categories = ['videos', 'music']
@@ -34,14 +35,6 @@ title_xpath = './/div[@class="yt-lockup-content"]/h3/a'
3435content_xpath = './/div[@class="yt-lockup-content"]/div[@class="yt-lockup-description yt-ui-ellipsis yt-ui-ellipsis-2"]'
3536
3637
37−# get element in list or default value
38−def list_get(a_list, index, default=None):
39− if len(a_list) > index:
40− return a_list[index]
41− else:
42− return default
43−
44−
4538# returns extract_text on the first result selected by the xpath or None
4639def extract_text_from_dom(result, xpath):
4740 r = result.xpath(xpath)