mirror of
				https://github.com/searxng/searxng
				synced 2024-01-01 19:24:07 +01:00 
			
		
		
		
	youtube_noapi uses searx.utils.list_get
This commit is contained in:
		
							parent
							
								
									62cc2a5658
								
							
						
					
					
						commit
						dafedbfc55
					
				
					 1 changed files with 1 additions and 8 deletions
				
			
		|  | @ -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) | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Dalf
						Dalf