diff --git a/app/filter.py b/app/filter.py index eef967b..e7afaa4 100644 --- a/app/filter.py +++ b/app/filter.py @@ -172,6 +172,7 @@ class Filter: for audio in [_ for _ in self.soup.find_all('audio') if 'src' in _.attrs]: self.update_element_src(audio, 'audio/mpeg') + audio['controls'] = '' for link in self.soup.find_all('a', href=True): self.update_link(link) diff --git a/app/routes.py b/app/routes.py index 3d18c4a..2938ed7 100644 --- a/app/routes.py +++ b/app/routes.py @@ -17,7 +17,7 @@ from app.models.config import Config from app.models.endpoint import Endpoint from app.request import Request, TorError from app.utils.bangs import resolve_bang -from app.utils.misc import get_proxy_host_url +from app.utils.misc import empty_gif, placeholder_img, get_proxy_host_url from app.filter import Filter from app.utils.misc import read_config_bool, get_client_ip, get_request_url, \ check_for_update @@ -470,8 +470,6 @@ def imgres(): @session_required @auth_required def element(): - empty_gif = base64.b64decode( - 'R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==') element_url = src_url = request.args.get('url') if element_url.startswith('gAAAAA'): try: @@ -493,8 +491,11 @@ def element(): response = g.user_request.send(base_url=src_url) # Display an empty gif if the requested element couldn't be retrieved - if response.status_code != 200: - return send_file(io.BytesIO(empty_gif), mimetype='image/gif') + if response.status_code != 200 or len(response.content) == 0: + if 'favicon' in src_url: + return send_file(io.BytesIO(placeholder_img), mimetype='image/png') + else: + return send_file(io.BytesIO(empty_gif), mimetype='image/gif') file_data = response.content tmp_mem = io.BytesIO() diff --git a/app/static/css/search.css b/app/static/css/search.css index 748020f..6c5df2f 100644 --- a/app/static/css/search.css +++ b/app/static/css/search.css @@ -59,8 +59,23 @@ details summary span { } .site-favicon { - float: right; + float: left; width: 25px; + padding-right: 5px; +} + +.sCuL3 { + padding-left: 30px; +} + +#flex_text_audio_icon_chunk { + display: none; +} + +audio { + display: block; + margin-right: auto; + padding-bottom: 5px; } @media (min-width: 801px) { diff --git a/app/utils/misc.py b/app/utils/misc.py index b1e65f0..140e5c4 100644 --- a/app/utils/misc.py +++ b/app/utils/misc.py @@ -1,3 +1,4 @@ +import base64 from bs4 import BeautifulSoup as bsoup from flask import Request import hashlib @@ -6,6 +7,19 @@ import re from requests import exceptions, get from urllib.parse import urlparse +empty_gif = base64.b64decode( + 'R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==') + +placeholder_img = base64.b64decode( + 'iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAABF0lEQVRIS8XWPw9EMBQA8Eok' \ + 'JBKrMFqMBt//GzAYLTZ/VomExPDu6uLiaPteqVynBn0/75W2Vp7nEIYhe6p1XcespmmAd7Is' \ + 'M+4URcGiKPogvMMvmIS2eN9MOMKbKWgf54SYgI4vKkTuQKJKSJErkKzUSkQHUs0lilAg7GMh' \ + 'ISoIA/hYMiKCKIA2soeowCWEMkfHtUmrXLcyGYYBfN9HF8djiaglWzNZlgVs21YisoAUaEXG' \ + 'cQTP86QIFgi7vyLzPIPjOEIEC7ANQv/4aZrAdd0TUtc1i+MYnSsMWjPp+x6CIPgJVlUVS5KE' \ + 'DKig/+wnVzM4pnzaGeHd+ENlWbI0TbVLJBtw2uMfP63wc9d2kDCWxi5Q27bsBerSJ9afJbeL' \ + 'AAAAAElFTkSuQmCC' +) + def gen_file_hash(path: str, static_file: str) -> str: file_contents = open(os.path.join(path, static_file), 'rb').read()