|
@@ -11,6 +11,7 @@
|
11
|
11
|
from urllib import quote_plus
|
12
|
12
|
from lxml import html
|
13
|
13
|
from searx.engines.xpath import extract_text
|
|
14
|
+from searx.utils import list_get
|
14
|
15
|
|
15
|
16
|
# engine dependent config
|
16
|
17
|
categories = ['videos', 'music']
|
|
@@ -34,14 +35,6 @@ title_xpath = './/div[@class="yt-lockup-content"]/h3/a'
|
34
|
35
|
content_xpath = './/div[@class="yt-lockup-content"]/div[@class="yt-lockup-description yt-ui-ellipsis yt-ui-ellipsis-2"]'
|
35
|
36
|
|
36
|
37
|
|
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
|
|
-
|
45
|
38
|
# returns extract_text on the first result selected by the xpath or None
|
46
|
39
|
def extract_text_from_dom(result, xpath):
|
47
|
40
|
r = result.xpath(xpath)
|