diff options
Diffstat (limited to 'youtube')
-rw-r--r-- | youtube/opensearch.xml | 6 | ||||
-rw-r--r-- | youtube/search.py | 16 | ||||
-rw-r--r-- | youtube/templates/base.html | 4 | ||||
-rw-r--r-- | youtube/templates/search.html | 2 |
4 files changed, 13 insertions, 15 deletions
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 @@ <InputEncoding>UTF-8</InputEncoding> <Image width="16" height="16">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==</Image> -<Url type="text/html" method="GET" template="http://localhost:$port_number/youtube.com/search"> - <Param name="query" value="{searchTerms}"/> +<Url type="text/html" method="GET" template="http://localhost:$port_number/youtube.com/results"> + <Param name="search_query" value="{searchTerms}"/> </Url> -<SearchForm>http://localhost:$port_number/youtube.com/search</SearchForm> +<SearchForm>http://localhost:$port_number/youtube.com/results</SearchForm> </SearchPlugin> 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 @@ <nav class="home"> <a href="/youtube.com" id="home-link">YT Local</a> </nav> - <form class="form" id="site-search" action="/youtube.com/search"> - <input type="search" name="query" class="search-box" value="{{ search_box_value }}" + <form class="form" id="site-search" action="/youtube.com/results"> + <input type="search" name="search_query" class="search-box" value="{{ search_box_value }}" {{ "autofocus" if request.path == "/" else "" }} placeholder="Type to search..."> <button type="submit" value="Search" class="search-button">Search</button> <!-- options --> diff --git a/youtube/templates/search.html b/youtube/templates/search.html index 4238d70..7f8ad26 100644 --- a/youtube/templates/search.html +++ b/youtube/templates/search.html @@ -28,7 +28,7 @@ <!-- /video item --> <footer class="pagination-container"> <nav class="pagination-list"> - {{ common_elements.page_buttons(estimated_pages, '/https://www.youtube.com/search', parameters_dictionary) }} + {{ common_elements.page_buttons(estimated_pages, '/https://www.youtube.com/results', parameters_dictionary) }} </nav> </footer> {% endblock main %} |