aboutsummaryrefslogtreecommitdiffstats
path: root/youtube
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2018-10-27 02:09:05 -0700
committerJames Taylor <user234683@users.noreply.github.com>2018-10-27 02:09:05 -0700
commitcdf89465cc0d41bb5a404e6bcc05c34690fa04ff (patch)
tree1823c4a0180480721d41347be4142af81f32e74a /youtube
parentac9fbbbf10f3a74bbc0b212a03b5375d5667bca8 (diff)
downloadyt-local-cdf89465cc0d41bb5a404e6bcc05c34690fa04ff.tar.lz
yt-local-cdf89465cc0d41bb5a404e6bcc05c34690fa04ff.tar.xz
yt-local-cdf89465cc0d41bb5a404e6bcc05c34690fa04ff.zip
fix search filters not being applied to next pages in results
Diffstat (limited to 'youtube')
-rw-r--r--youtube/common.py5
-rw-r--r--youtube/search.py14
2 files changed, 2 insertions, 17 deletions
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('''<a class="page-button" href="$href">$page</a>''')
current_page_button_template = Template('''<div class="page-button">$page</div>''')
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('''<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 \ No newline at end of file