diff options
| author | Markus Heiser <markus.heiser@darmarit.de> | 2022-02-07 21:59:21 +0100 |
|---|---|---|
| committer | Markus Heiser <markus.heiser@darmarit.de> | 2022-02-13 14:20:47 +0100 |
| commit | 98cab4cf754752e8a615b7b6c2685021592889a7 (patch) | |
| tree | 8aac9568766473950db0747cd6a12e1b098384e5 /searx/engines | |
| parent | b9a2e8b387212d35cc83da50a07ee8fa47d2a56e (diff) | |
[mod] result_templates/default.html replace embedded HTML by data_src audio_src
Embedded HTML breaks SearXNG architecture. To modularize, HTML is generated in
the templates (oscar & simple) and result parameter 'embedded' is replaced by
'data_src' (and 'audio_src'), an URL for embedded content (<iframe>).
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/engines')
| -rw-r--r-- | searx/engines/bandcamp.py | 12 | ||||
| -rw-r--r-- | searx/engines/deezer.py | 14 | ||||
| -rw-r--r-- | searx/engines/freesound.py | 6 | ||||
| -rw-r--r-- | searx/engines/mixcloud.py | 16 | ||||
| -rw-r--r-- | searx/engines/soundcloud.py | 9 | ||||
| -rw-r--r-- | searx/engines/spotify.py | 15 |
6 files changed, 27 insertions, 45 deletions
diff --git a/searx/engines/bandcamp.py b/searx/engines/bandcamp.py index ba951a393..bc3ecaf96 100644 --- a/searx/engines/bandcamp.py +++ b/searx/engines/bandcamp.py @@ -4,7 +4,7 @@ Bandcamp (Music) @website https://bandcamp.com/ @provide-api no @results HTML -@parse url, title, content, publishedDate, embedded, thumbnail +@parse url, title, content, publishedDate, data_src, thumbnail """ from urllib.parse import urlencode, urlparse, parse_qs @@ -27,10 +27,7 @@ paging = True base_url = "https://bandcamp.com/" search_string = search_string = 'search?{query}&page={page}' -embedded_url = '''<iframe width="100%" height="166" - scrolling="no" frameborder="no" - data-src="https://bandcamp.com/EmbeddedPlayer/{type}={result_id}/size=large/bgcol=ffffff/linkcol=0687f5/tracklist=false/artwork=small/transparent=true/" -></iframe>''' +data_src = "https://bandcamp.com/EmbeddedPlayer/{type}={result_id}/size=large/bgcol=ffffff/linkcol=0687f5/tracklist=false/artwork=small/transparent=true/" def request(query, params): @@ -74,8 +71,9 @@ def response(resp): if thumbnail: new_result['thumbnail'] = thumbnail[0] if "album" in result.classes: - new_result["embedded"] = embedded_url.format(type='album', result_id=result_id) + new_result["data_src"] = data_src.format(type='album', result_id=result_id) elif "track" in result.classes: - new_result["embedded"] = embedded_url.format(type='track', result_id=result_id) + new_result["data_src"] = data_src.format(type='track', result_id=result_id) + results.append(new_result) return results diff --git a/searx/engines/deezer.py b/searx/engines/deezer.py index 220ac599d..6e884b498 100644 --- a/searx/engines/deezer.py +++ b/searx/engines/deezer.py @@ -23,13 +23,7 @@ paging = True # search-url url = 'https://api.deezer.com/' search_url = url + 'search?{query}&index={offset}' - -embedded_url = ( - '<iframe scrolling="no" frameborder="0" allowTransparency="true" ' - + 'data-src="https://www.deezer.com/plugins/player?type=tracks&id={audioid}" ' - + 'width="540" height="80"></iframe>' -) - +data_src = "https://www.deezer.com/plugins/player?type=tracks&id={audioid}" # do search-request def request(query, params): @@ -57,10 +51,10 @@ def response(resp): content = '{} - {} - {}'.format(result['artist']['name'], result['album']['title'], result['title']) - embedded = embedded_url.format(audioid=result['id']) - # append result - results.append({'url': url, 'title': title, 'embedded': embedded, 'content': content}) + results.append( + {'url': url, 'title': title, 'data_src': data_src.format(audioid=result['id']), 'content': content} + ) # return results return results diff --git a/searx/engines/freesound.py b/searx/engines/freesound.py index 121a6a5b0..ea6666621 100644 --- a/searx/engines/freesound.py +++ b/searx/engines/freesound.py @@ -29,9 +29,6 @@ search_url = ( url + "search/text/?query={query}&page={page}&fields=name,url,download,created,description,type&token={api_key}" ) -embedded_url = '<audio controls><source src="{uri}" type="audio/{ftype}"></audio>' - - # search request def request(query, params): params["url"] = search_url.format( @@ -52,7 +49,6 @@ def response(resp): content = result["description"][:128] publishedDate = datetime.fromisoformat(result["created"]) uri = result["download"] - embedded = embedded_url.format(uri=uri, ftype=result["type"]) # append result results.append( @@ -60,7 +56,7 @@ def response(resp): "url": result["url"], "title": title, "publishedDate": publishedDate, - "embedded": embedded, + "audio_src": uri, "content": content, } ) diff --git a/searx/engines/mixcloud.py b/searx/engines/mixcloud.py index f5e0f55fc..41d39b753 100644 --- a/searx/engines/mixcloud.py +++ b/searx/engines/mixcloud.py @@ -24,12 +24,7 @@ paging = True # search-url url = 'https://api.mixcloud.com/' search_url = url + 'search/?{query}&type=cloudcast&limit=10&offset={offset}' - -embedded_url = ( - '<iframe scrolling="no" frameborder="0" allowTransparency="true" ' - + 'data-src="https://www.mixcloud.com/widget/iframe/?feed={url}" width="300" height="300"></iframe>' -) - +data_src = "https://www.mixcloud.com/widget/iframe/?feed={url}" # do search-request def request(query, params): @@ -51,12 +46,17 @@ def response(resp): title = result['name'] url = result['url'] content = result['user']['name'] - embedded = embedded_url.format(url=url) publishedDate = parser.parse(result['created_time']) # append result results.append( - {'url': url, 'title': title, 'embedded': embedded, 'publishedDate': publishedDate, 'content': content} + { + 'url': url, + 'title': title, + 'data_src': data_src.format(url=url), + 'publishedDate': publishedDate, + 'content': content, + } ) # return results diff --git a/searx/engines/soundcloud.py b/searx/engines/soundcloud.py index 004164e37..918b56448 100644 --- a/searx/engines/soundcloud.py +++ b/searx/engines/soundcloud.py @@ -37,12 +37,6 @@ search_url = ( '&client_id={client_id}' ) # noqa -embedded_url = ( - '<iframe width="100%" height="166" ' - + 'scrolling="no" frameborder="no" ' - + 'data-src="https://w.soundcloud.com/player/?url={uri}"></iframe>' -) - cid_re = re.compile(r'client_id:"([^"]*)"', re.I | re.U) guest_client_id = '' @@ -97,7 +91,6 @@ def response(resp): content = result['description'] or '' publishedDate = parser.parse(result['last_modified']) uri = quote_plus(result['uri']) - embedded = embedded_url.format(uri=uri) # append result results.append( @@ -105,7 +98,7 @@ def response(resp): 'url': result['permalink_url'], 'title': title, 'publishedDate': publishedDate, - 'embedded': embedded, + 'data_src': "https://w.soundcloud.com/player/?url=" + uri, 'content': content, } ) diff --git a/searx/engines/spotify.py b/searx/engines/spotify.py index 15517e3eb..c287a3469 100644 --- a/searx/engines/spotify.py +++ b/searx/engines/spotify.py @@ -29,10 +29,6 @@ api_client_secret = None url = 'https://api.spotify.com/' search_url = url + 'v1/search?{query}&type=track&offset={offset}' -embedded_url = '<iframe data-src="https://embed.spotify.com/?uri=spotify:track:{audioid}"\ - width="300" height="80" frameborder="0" allowtransparency="true"></iframe>' - - # do search-request def request(query, params): offset = (params['pageno'] - 1) * 20 @@ -66,10 +62,15 @@ def response(resp): url = result['external_urls']['spotify'] content = '{} - {} - {}'.format(result['artists'][0]['name'], result['album']['name'], result['name']) - embedded = embedded_url.format(audioid=result['id']) - # append result - results.append({'url': url, 'title': title, 'embedded': embedded, 'content': content}) + results.append( + { + 'url': url, + 'title': title, + 'data_src': "https://embed.spotify.com/?uri=spotify:track:" + result['id'], + 'content': content, + } + ) # return results return results |