From acfa31ff5991c2a7b6c510c45f2481db461970c7 Mon Sep 17 00:00:00 2001 From: James Taylor Date: Thu, 1 Jul 2021 17:33:12 -0700 Subject: Change search url path to match the YouTube path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #67 Signed-off-by: Jesús --- youtube/opensearch.xml | 6 +++--- youtube/search.py | 16 +++++++--------- youtube/templates/base.html | 4 ++-- youtube/templates/search.html | 2 +- 4 files changed, 13 insertions(+), 15 deletions(-) (limited to 'youtube') diff --git a/youtube/opensearch.xml b/youtube/opensearch.xml index e4348a0..dc15cb6 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/search +http://localhost:$port_number/youtube.com/results diff --git a/youtube/search.py b/youtube/search.py index da8cdab..f9591fe 100644 --- a/youtube/search.py +++ b/youtube/search.py @@ -58,15 +58,13 @@ def get_search_json(query, page, autocorrect, sort, filters): return info +@yt_app.route('/results') @yt_app.route('/search') def get_search_page(): - if len(request.args) == 0: - return flask.render_template('base.html', title="Search") + query = request.args.get('search_query') or request.args.get('query') + if query is None: + return flask.render_template('base.html', title='Search') - if 'query' not in request.args: - abort(400) - - query = request.args.get("query") page = request.args.get("page", "1") autocorrect = int(request.args.get("autocorrect", "1")) sort = int(request.args.get("sort", "0")) @@ -87,12 +85,12 @@ def get_search_page(): corrections = search_info['corrections'] if corrections['type'] == 'did_you_mean': corrected_query_string = request.args.to_dict(flat=False) - corrected_query_string['query'] = [corrections['corrected_query']] - corrections['corrected_query_url'] = util.URL_ORIGIN + '/search?' + urllib.parse.urlencode(corrected_query_string, doseq=True) + corrected_query_string['search_query'] = [corrections['corrected_query']] + corrections['corrected_query_url'] = util.URL_ORIGIN + '/results?' + urllib.parse.urlencode(corrected_query_string, doseq=True) elif corrections['type'] == 'showing_results_for': no_autocorrect_query_string = request.args.to_dict(flat=False) no_autocorrect_query_string['autocorrect'] = ['0'] - no_autocorrect_query_url = util.URL_ORIGIN + '/search?' + urllib.parse.urlencode(no_autocorrect_query_string, doseq=True) + no_autocorrect_query_url = util.URL_ORIGIN + '/results?' + urllib.parse.urlencode(no_autocorrect_query_string, doseq=True) corrections['original_query_url'] = no_autocorrect_query_url return flask.render_template( diff --git a/youtube/templates/base.html b/youtube/templates/base.html index 2278a02..8a0238a 100644 --- a/youtube/templates/base.html +++ b/youtube/templates/base.html @@ -20,8 +20,8 @@ -