fix search filters not being applied to next pages in results

This commit is contained in:
James Taylor 2018-10-27 02:09:05 -07:00
parent ac9fbbbf10
commit cdf89465cc
2 changed files with 2 additions and 17 deletions

View File

@ -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('''<a class="page-button" href="$href">$page</a>''')
current_page_button_template = Template('''<div class="page-button">$page</div>''')

View File

@ -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('''<a class="page-button" href="$href">$page</a>''')
current_page_button_template = Template('''<div class="page-button">$page</div>''')
# 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('''
<div>Showing results for <a>$corrected_query</a></div>
<div>Search instead for <a href="$original_query_url">$original_query</a></div>
@ -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