Przeglądaj źródła

youtube_noapi uses searx.utils.list_get

Dalf 10 lat temu
rodzic
commit
dafedbfc55
1 zmienionych plików z 1 dodań i 8 usunięć
  1. 1
    8
      searx/engines/youtube_noapi.py

+ 1
- 8
searx/engines/youtube_noapi.py Wyświetl plik

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