on master help sign in
youtube_noapi uses searx.utils.list_get
commitdafedbfc55773bac65838d1a63765ecb78bbc7ab authorDalf <alex@al-f.net> dateThu 4 Jun 2015, 18:34 (11 years ago) parent62cc2a5
1 file changed+1−8
searx/engines/youtube_noapi.py+1−8
searx/engines/youtube_noapi.py+1−8
@@ -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)