[fix] wikicommons engine: remove HTML tags from result items
BTW: humanize filesize (Bytes) to KB, MB, GB .. Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
This commit is contained in:
		
							parent
							
								
									342d321196
								
							
						
					
					
						commit
						9415845337
					
				@ -7,6 +7,8 @@ import datetime
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
from urllib.parse import urlencode
 | 
					from urllib.parse import urlencode
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from searx.utils import html_to_text, humanize_bytes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# about
 | 
					# about
 | 
				
			||||||
about = {
 | 
					about = {
 | 
				
			||||||
    "website": 'https://commons.wikimedia.org/',
 | 
					    "website": 'https://commons.wikimedia.org/',
 | 
				
			||||||
@ -74,7 +76,7 @@ def response(resp):
 | 
				
			|||||||
        result = {
 | 
					        result = {
 | 
				
			||||||
            'url': imageinfo["descriptionurl"],
 | 
					            'url': imageinfo["descriptionurl"],
 | 
				
			||||||
            'title': title,
 | 
					            'title': title,
 | 
				
			||||||
            'content': item["snippet"],
 | 
					            'content': html_to_text(item["snippet"]),
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if search_type == "images":
 | 
					        if search_type == "images":
 | 
				
			||||||
@ -93,7 +95,7 @@ def response(resp):
 | 
				
			|||||||
        elif search_type == "files":
 | 
					        elif search_type == "files":
 | 
				
			||||||
            result['template'] = 'files.html'
 | 
					            result['template'] = 'files.html'
 | 
				
			||||||
            result['metadata'] = imageinfo['mime']
 | 
					            result['metadata'] = imageinfo['mime']
 | 
				
			||||||
            result['size'] = imageinfo['size']
 | 
					            result['size'] = humanize_bytes(imageinfo['size'])
 | 
				
			||||||
        elif search_type == "audio":
 | 
					        elif search_type == "audio":
 | 
				
			||||||
            result['iframe_src'] = imageinfo['url']
 | 
					            result['iframe_src'] = imageinfo['url']
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user