logo

searx

My custom branche(s) on searx, a meta-search engine git clone https://hacktivis.me/git/searx.git
commit: dafedbfc55773bac65838d1a63765ecb78bbc7ab
parent 62cc2a5658c9f2cfe75c0af0e5db125d2c6f8e38
Author: Dalf <alex@al-f.net>
Date:   Thu,  4 Jun 2015 18:34:44 +0200

youtube_noapi uses searx.utils.list_get

Diffstat:

Msearx/engines/youtube_noapi.py9+--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/searx/engines/youtube_noapi.py b/searx/engines/youtube_noapi.py @@ -11,6 +11,7 @@ from urllib import quote_plus from lxml import html from searx.engines.xpath import extract_text +from searx.utils import list_get # engine dependent config categories = ['videos', 'music'] @@ -34,14 +35,6 @@ title_xpath = './/div[@class="yt-lockup-content"]/h3/a' content_xpath = './/div[@class="yt-lockup-content"]/div[@class="yt-lockup-description yt-ui-ellipsis yt-ui-ellipsis-2"]' -# get element in list or default value -def list_get(a_list, index, default=None): - if len(a_list) > index: - return a_list[index] - else: - return default - - # returns extract_text on the first result selected by the xpath or None def extract_text_from_dom(result, xpath): r = result.xpath(xpath)