Skip to content

Commit

Permalink
Explicitly set result options when using search endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
MoojMidge committed Dec 13, 2024
1 parent ef55f06 commit 4ca0d01
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
25 changes: 14 additions & 11 deletions resources/lib/youtube_plugin/kodion/abstract_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ def navigate(self, context):
result = handler(provider=self, context=context, re_match=re_match)
if isinstance(result, tuple):
result, new_options = result
options.update(new_options)
if new_options:
options.update(new_options)

if context.get_param('refresh'):
options[self.RESULT_CACHE_TO_DISC] = True
Expand Down Expand Up @@ -356,7 +357,7 @@ def on_search(provider, context, re_match):
localize('content.remove'),
localize('content.remove.check') % query,
):
return False
return False, None

search_history.del_item(query)
ui.refresh_container()
Expand All @@ -366,7 +367,7 @@ def on_search(provider, context, re_match):
time_ms=2500,
audible=False,
)
return True
return True, None

if command == 'rename':
query = to_unicode(params.get('q', ''))
Expand All @@ -377,14 +378,14 @@ def on_search(provider, context, re_match):
search_history.del_item(query)
search_history.add_item(new_query)
ui.refresh_container()
return True
return True, None

if command == 'clear':
if not ui.on_yes_no_input(
localize('search.clear'),
localize('content.clear.check') % localize('search.history')
):
return False
return False, None

search_history.clear()
ui.refresh_container()
Expand All @@ -394,7 +395,7 @@ def on_search(provider, context, re_match):
time_ms=2500,
audible=False,
)
return True
return True, None

if command.startswith('input'):
query = None
Expand All @@ -418,13 +419,15 @@ def on_search(provider, context, re_match):
query = input_query

if not query:
return False
return False, None

context.set_path(PATHS.SEARCH, 'query')
return (
provider.on_search_run(context=context, query=query),
{provider.RESULT_CACHE_TO_DISC: command != 'input_prompt'},
)
result, options = provider.on_search_run(context, query=query)
if not options:
options = {
provider.RESULT_CACHE_TO_DISC: command != 'input_prompt',
}
return result, options

context.set_content(CONTENT.LIST_CONTENT,
category_label=localize('search'))
Expand Down
8 changes: 4 additions & 4 deletions resources/lib/youtube_plugin/youtube/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,11 +876,11 @@ def on_search_run(self, context, query):
if query.startswith(('https://', 'http://')):
return self.on_uri2addon(provider=self, context=context, uri=query)
if context.is_plugin_path(query):
return UriItem(query)
return UriItem(query), None

result = self._search_channel_or_playlist(context, query)
if result: # found a channel or playlist matching search query
return result
return result, None
result = []

context.set_param('q', query)
Expand Down Expand Up @@ -1000,7 +1000,7 @@ def on_search_run(self, context, query):
params=search_params,
)
if not json_data:
return False
return False, None

# Store current search query for Kodi window history navigation
if not params.get('incognito'):
Expand All @@ -1016,7 +1016,7 @@ def on_search_run(self, context, query):
'live': False,
},
))
return result
return result, None

@AbstractProvider.register_path('^/config/(?P<action>[^/]+)/?$')
@staticmethod
Expand Down

0 comments on commit 4ca0d01

Please sign in to comment.