From cdf89465cc0d41bb5a404e6bcc05c34690fa04ff Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sat, 27 Oct 2018 02:09:05 -0700 Subject: fix search filters not being applied to next pages in results --- youtube/common.py | 5 +---- youtube/search.py | 14 +------------- 2 files changed, 2 insertions(+), 17 deletions(-) (limited to 'youtube') diff --git a/youtube/common.py b/youtube/common.py index 54ac70f..f534d84 100644 --- a/youtube/common.py +++ b/youtube/common.py @@ -620,13 +620,10 @@ def playlist_item_html(item, template, html_exclude=set()): -def make_query_string(query_string): - return '&'.join(key + '=' + ','.join(values) for key,values in query_string.items()) - def update_query_string(query_string, items): parameters = urllib.parse.parse_qs(query_string) parameters.update(items) - return make_query_string(parameters) + return urllib.parse.urlencode(parameters, doseq=True) page_button_template = Template('''$page''') current_page_button_template = Template('''
$page
''') diff --git a/youtube/search.py b/youtube/search.py index 0ddc84d..6df8bea 100644 --- a/youtube/search.py +++ b/youtube/search.py @@ -10,8 +10,6 @@ from youtube import common, proto with open("yt_search_results_template.html", "r") as file: yt_search_results_template = file.read() -page_button_template = Template('''$page''') -current_page_button_template = Template('''
$page
''') # Sort: 1 # Upload date: 2 @@ -61,16 +59,6 @@ def get_search_json(query, page, autocorrect, sort, filters): return info -def page_buttons_html(page_start, page_end, current_page, query): - result = "" - for page in range(page_start, page_end+1): - if page == current_page: - template = current_page_button_template - else: - template = page_button_template - result += template.substitute(page=page, href=URL_ORIGIN + "/search?query=" + urllib.parse.quote_plus(query) + "&page=" + str(page)) - return result - showing_results_for = Template('''
Showing results for $corrected_query
Search instead for $original_query
@@ -146,7 +134,7 @@ def get_search_page(query_string, parameters=()): search_box_value = html.escape(query), number_of_results = '{:,}'.format(estimated_results), number_of_pages = '{:,}'.format(estimated_pages), - page_buttons = page_buttons_html(page_start, page_end, page, query), + page_buttons = common.page_buttons_html(page, estimated_pages, URL_ORIGIN + "/search", query_string), corrections = corrections ) return result \ No newline at end of file -- cgit v1.2.3