Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v7.1.0+beta.3 #902

Merged
merged 10 commits into from
Sep 18, 2024
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.youtube" name="YouTube" version="7.1.0+beta.2" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.1.0+beta.3" provider-name="anxdpanic, bromix, MoojMidge">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.requests" version="2.27.1"/>
Expand Down
13 changes: 13 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## v7.1.0+beta.3
### Fixed
- Fix various timing and sync issues with script, service, plugin and Kodi settings

### Changed
- Move IP location lookup to script and add to settings dialog
- Move language and region selection to script and add to settings dialog

### New
- Add hide_next_page query parameter to hide plugin Next page item #896
- Add new input_prompt command for search endpoint to bypass Kodi window caching
- plugin://plugin.video.youtube/kodion/search/input_prompt

## v7.1.0+beta.2
### Fixed
- Fix possible regression causing 6s delay on first play
Expand Down
45 changes: 25 additions & 20 deletions resources/lib/youtube_plugin/kodion/abstract_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __init__(self):
self.register_path(r''.join((
'^',
'(', PATHS.SEARCH, '|', PATHS.EXTERNAL_SEARCH, ')',
'/(?P<command>input|query|list|remove|clear|rename)?/?$'
'/(?P<command>input|input_prompt|query|list|remove|clear|rename)?/?$'
)), self.on_search)

self.register_path(r''.join((
Expand Down Expand Up @@ -117,18 +117,19 @@ def wrapper(method):
return wrapper

def run_wizard(self, context):
settings = context.get_settings()
ui = context.get_ui()

context.send_notification(CHECK_SETTINGS, 'defer')
context.wakeup(
CHECK_SETTINGS,
timeout=5,
payload={'state': 'defer'},
)

wizard_steps = self.get_wizard_steps()

step = 0
steps = len(wizard_steps)

try:
if wizard_steps and ui.on_yes_no_input(
if wizard_steps and context.get_ui().on_yes_no_input(
context.localize('setup_wizard'),
(context.localize('setup_wizard.prompt')
% context.localize('setup_wizard.prompt.settings'))
Expand All @@ -142,8 +143,13 @@ def run_wizard(self, context):
else:
step += 1
finally:
settings = context.get_settings(refresh=True)
settings.setup_wizard_enabled(False)
context.send_notification(CHECK_SETTINGS, 'process')
context.wakeup(
CHECK_SETTINGS,
timeout=5,
payload={'state': 'process'},
)

@staticmethod
def get_wizard_steps():
Expand All @@ -166,9 +172,9 @@ def navigate(self, context):
result, new_options = result
options.update(new_options)

refresh = context.get_param('refresh')
if refresh is not None:
options[self.RESULT_UPDATE_LISTING] = bool(refresh)
if context.get_param('refresh'):
options[self.RESULT_CACHE_TO_DISC] = False
options[self.RESULT_UPDATE_LISTING] = True

return result, options

Expand Down Expand Up @@ -249,16 +255,12 @@ def reroute(self, context, path=None, params=None, uri=None):
if not path:
return False

do_refresh = 'refresh' in params

if path == current_path and params == current_params:
if not do_refresh:
return False
params['refresh'] += 1

if do_refresh:
if 'refresh' in params:
container = context.get_infolabel('System.CurrentControlId')
position = context.get_infolabel('Container.CurrentItem')
params['refresh'] += 1
elif path == current_path and params == current_params:
return False
else:
container = None
position = None
Expand Down Expand Up @@ -341,7 +343,7 @@ def on_search(provider, context, re_match):
ui.refresh_container()
return True

if command == 'input':
if command.startswith('input'):
query = None
# came from page 1 of search query by '..'/back
# user doesn't want to input on this path
Expand All @@ -366,7 +368,10 @@ def on_search(provider, context, re_match):
return False

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

context.set_content(CONTENT.LIST_CONTENT)
result = []
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/youtube_plugin/kodion/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# Flags
ABORT_FLAG = 'abort_requested'
BUSY_FLAG = 'busy'
WAIT_FLAG = 'builtin_running'
WAIT_END_FLAG = 'builtin_completed'

# ListItem Properties
CHANNEL_ID = 'channel_id'
Expand Down Expand Up @@ -97,7 +97,7 @@
# Flags
'ABORT_FLAG',
'BUSY_FLAG',
'WAIT_FLAG',
'WAIT_END_FLAG',

# ListItem properties
'CHANNEL_ID',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class AbstractContext(object):
'enable',
'hide_folders',
'hide_live',
'hide_next_page',
'hide_playlists',
'hide_search',
'incognito',
Expand Down Expand Up @@ -449,8 +450,7 @@ def log_info(self, text):
def clone(self, new_path=None, new_params=None):
raise NotImplementedError()

@staticmethod
def execute(command):
def execute(self, command, wait=False, wait_for=None):
raise NotImplementedError()

@staticmethod
Expand Down
23 changes: 15 additions & 8 deletions resources/lib/youtube_plugin/kodion/context/xbmc/xbmc_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,14 +582,19 @@ def clone(self, new_path=None, new_params=None):
return new_context

def execute(self, command, wait=False, wait_for=None):
if not wait_for:
xbmc.executebuiltin(command, wait)
return

ui = self.get_ui()
ui.clear_property(wait_for)
pop_property = ui.pop_property
waitForAbort = xbmc.Monitor().waitForAbort

xbmc.executebuiltin(command, wait)
if wait_for:
ui = self.get_ui()
monitor = xbmc.Monitor()
while not monitor.abortRequested():
monitor.waitForAbort(1)
if not ui.get_property(wait_for):
break

while not pop_property(wait_for) and not waitForAbort(1):
pass

@staticmethod
def sleep(timeout=None):
Expand Down Expand Up @@ -751,8 +756,10 @@ def tear_down(self):
except AttributeError:
pass

def wakeup(self, target, timeout=None):
def wakeup(self, target, timeout=None, payload=None):
data = {'target': target, 'response_required': bool(timeout)}
if payload:
data.update(payload)
self.send_notification(WAKEUP, data)
if not timeout:
return
Expand Down
19 changes: 9 additions & 10 deletions resources/lib/youtube_plugin/kodion/monitors/service_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,7 @@ def onNotification(self, sender, method, data):
if sender != ADDON_ID:
return
group, separator, event = method.partition('.')
if event == CHECK_SETTINGS:
if data:
data = json.loads(data)
if data == 'defer':
self._settings_state = data
elif data == 'process':
self._settings_state = data
self.onSettingsChanged()
self._settings_state = None
elif event == WAKEUP:
if event == WAKEUP:
if not isinstance(data, dict):
data = json.loads(data)
if not data:
Expand All @@ -110,6 +101,14 @@ def onNotification(self, sender, method, data):
self.start_httpd()
if self.httpd_sleep_allowed:
self.httpd_sleep_allowed = None
elif target == CHECK_SETTINGS:
state = data.get('state')
if state == 'defer':
self._settings_state = state
elif state == 'process':
self._settings_state = state
self.onSettingsChanged()
self._settings_state = None
if data.get('response_required'):
self.set_property(WAKEUP, target)
elif event == REFRESH_CONTAINER:
Expand Down
Loading
Loading