fix search (#374)
This commit is contained in:
parent
a1e466273d
commit
6ea74e39fb
3 changed files with 9 additions and 6 deletions
|
|
@ -80,16 +80,19 @@ class TestYTMusic(unittest.TestCase):
|
|||
for q in queries:
|
||||
with self.subTest():
|
||||
results = self.yt_brand.search(q)
|
||||
self.assertListEqual(['resultType' in r for r in results], [True] * len(results))
|
||||
self.assertGreater(len(results), 10)
|
||||
results = self.yt.search(q)
|
||||
self.assertGreater(len(results), 10)
|
||||
results = self.yt_auth.search('Martin Stig Andersen - Deteriation', ignore_spelling=True)
|
||||
self.assertGreater(len(results), 0)
|
||||
results = self.yt_auth.search(query, filter='songs')
|
||||
self.assertListEqual([r['resultType'] for r in results], ['song'] * len(results))
|
||||
self.assertGreater(len(results), 10)
|
||||
results = self.yt_auth.search(query, filter='videos')
|
||||
self.assertGreater(len(results), 10)
|
||||
results = self.yt_auth.search(query, filter='albums', limit=40)
|
||||
self.assertListEqual([r['resultType'] for r in results], ['album'] * len(results))
|
||||
self.assertGreater(len(results), 20)
|
||||
results = self.yt_auth.search('project-2', filter='artists', ignore_spelling=True)
|
||||
self.assertGreater(len(results), 0)
|
||||
|
|
|
|||
|
|
@ -198,9 +198,9 @@ class SearchMixin:
|
|||
else:
|
||||
continue
|
||||
|
||||
search_result_types = self.parser.get_search_result_types()
|
||||
search_results.extend(
|
||||
parse_search_results(results, self.parser.get_search_result_types(), type,
|
||||
category))
|
||||
parse_search_results(results, search_result_types, type, category))
|
||||
|
||||
if filter: # if filter is set, there are continuations
|
||||
|
||||
|
|
@ -208,7 +208,7 @@ class SearchMixin:
|
|||
return self._send_request(endpoint, body, additionalParams)
|
||||
|
||||
def parse_func(contents):
|
||||
return parse_search_results(contents, type, category)
|
||||
return parse_search_results(contents, search_result_types, type, category)
|
||||
|
||||
search_results.extend(
|
||||
get_continuations(res['musicShelfRenderer'], 'musicShelfContinuation',
|
||||
|
|
|
|||
|
|
@ -46,8 +46,8 @@ def parse_top_result(data, search_result_types):
|
|||
def parse_search_result(data, search_result_types, result_type, category):
|
||||
default_offset = (not result_type) * 2
|
||||
search_result = {'category': category}
|
||||
if video_type := nav(data, PLAY_BUTTON + ['playNavigationEndpoint'] + NAVIGATION_VIDEO_TYPE,
|
||||
True):
|
||||
video_type = nav(data, PLAY_BUTTON + ['playNavigationEndpoint'] + NAVIGATION_VIDEO_TYPE, True)
|
||||
if not result_type and video_type:
|
||||
result_type = 'song' if video_type == 'MUSIC_VIDEO_TYPE_ATV' else 'video'
|
||||
|
||||
result_type = get_search_result_type(get_item_text(data, 1),
|
||||
|
|
@ -185,7 +185,7 @@ def get_search_params(filter, scope, ignore_spelling):
|
|||
param1 = filtered_param1
|
||||
param2 = _get_param2(filter)
|
||||
if not ignore_spelling:
|
||||
param3 = 'AWoKEAMQCRAEEAoQBQ%3D%3D'
|
||||
param3 = 'AWoMEA4QChADEAQQCRAF'
|
||||
else:
|
||||
param3 = 'AUICCAFqDBAOEAoQAxAEEAkQBQ%3D%3D'
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue