From 06315e3e0207f2ba7cbeb01134824b149095d8a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs?= Date: Sat, 14 Aug 2021 18:36:17 -0500 Subject: [opensearch]: improve --- settings.py | 14 ++++++++++++++ youtube/opensearch.xml | 4 ++-- youtube/search.py | 8 +++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/settings.py b/settings.py index 751551b..a7dd398 100644 --- a/settings.py +++ b/settings.py @@ -8,6 +8,20 @@ import flask from flask import request SETTINGS_INFO = collections.OrderedDict([ + ('app_public', { + 'type': bool, + 'default': False, + 'comment': '''Set app public mode, disabled by default''', + 'hidden': True, + 'category': 'network', + }), + ('app_url', { + 'type': str, + 'default': 'http://localhost', + 'comment': '''Set URL of app 'http://localhost' by default''', + 'hidden': True, + 'category': 'network', + }), ('route_tor', { 'type': int, 'default': 0, diff --git a/youtube/opensearch.xml b/youtube/opensearch.xml index dc15cb6..09d1cb7 100644 --- a/youtube/opensearch.xml +++ b/youtube/opensearch.xml @@ -4,8 +4,8 @@ UTF-8 data:image/x-icon;base64,AAABAAEAEBAAAAEACAAlAgAAFgAAAIlQTkcNChoKAAAADUlIRFIAAAAQAAAAEAgGAAAAH/P/YQAAAexJREFUOI2lkzFPmlEUhp/73fshtCUCRtvQkJoKMrDQJvoHnBzUhc3EH0DUQf+As6tujo4M6mTiIDp0kGiMTRojTRNSW6o12iD4YYXv3g7Qr4O0ScM7npz7vOe+J0fk83lDF7K6eQygwkdHhI+P0bYNxmBXq5RmZui5vGQgn0f7fKi7O4oLC1gPD48BP9JpnpRKJFZXcQMB3m1u4vr9NHp76d/bo39/n4/z84ROThBa4/r91OJxMKb9BSn5mskAIOt1eq6uEFpjVyrEcjk+T0+TXlzkbTZLuFDAur9/nIFRipuREQCe7+zgBgK8mZvj/fIylVTKa/6UzXKbSnnuHkA0GnwbH/cA0a0takND3IyOEiwWAXBiMYTWjzLwtvB9bAyAwMUF8ZUVPiwtYTWbHqA6PIxoNv8OMLbN3eBga9TZWYQxaKX+AJJJhOv+AyAlT0slAG6TSX5n8+zszJugkzxA4PzcK9YSCQCk42DXaq1aGwqgfT5ebG9jpMQyUjKwu8vrtbWWqxC83NjAd31NsO2uleJnX58HCJ6eEjk8BGNQAA+RCOXJScpTU2AMwnUxlkXk4ACA+2iUSKGArNeRjkMsl6M8MYHQGtHpmIxSvFpfRzoORinQGqvZBCEwQoAxfMlkaIRCnQH/o66v8Re19MavaDNLfgAAAABJRU5ErkJggg== - + -http://localhost:$port_number/youtube.com/results +$main_url/youtube.com/results diff --git a/youtube/search.py b/youtube/search.py index 33e9251..7057747 100644 --- a/youtube/search.py +++ b/youtube/search.py @@ -108,5 +108,11 @@ def get_search_page(): @yt_app.route('/opensearch.xml') def get_search_engine_xml(): with open(os.path.join(settings.program_directory, 'youtube/opensearch.xml'), 'rb') as f: - content = f.read().replace(b'$port_number', str(settings.port_number).encode()) + if settings.app_public: + main_url = '%s' % settings.app_url + else: + main_url = '%s:%s' % (settings.app_url, settings.port_number) + content = f.read().replace( + b'$main_url', str(main_url).encode() + ) return flask.Response(content, mimetype='application/xml') -- cgit v1.2.3