diff options
author | James Taylor <user234683@users.noreply.github.com> | 2021-07-01 17:33:12 -0700 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2021-07-01 21:04:33 -0500 |
commit | acfa31ff5991c2a7b6c510c45f2481db461970c7 (patch) | |
tree | 043c743278b2149eaef3d788427998dbda5cd3c5 /youtube/search.py | |
parent | 4a9c1422e74e017056d0578bc1ae67e4ebd5ea01 (diff) | |
download | yt-local-acfa31ff5991c2a7b6c510c45f2481db461970c7.tar.lz yt-local-acfa31ff5991c2a7b6c510c45f2481db461970c7.tar.xz yt-local-acfa31ff5991c2a7b6c510c45f2481db461970c7.zip |
Change search url path to match the YouTube path
Fixes #67
Signed-off-by: Jesús <heckyel@hyperbola.info>
Diffstat (limited to 'youtube/search.py')
-rw-r--r-- | youtube/search.py | 16 |
1 files changed, 7 insertions, 9 deletions
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( |