Skip to content

Commit

Permalink
Only check if the gui is connected once (#96)
Browse files Browse the repository at this point in the history
This commit changes the OCPQuery logic such that it only checks if the
gui is connected once, rather than on every skill response.

Furthermore if `playback_mode` is set to an option where the GUI is not
needed, then bypass the check entirely.

related to #92
  • Loading branch information
Ramblurr authored Aug 21, 2023
1 parent 074a13e commit 1fd9856
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ovos_plugin_common_play/ocp/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def reset(self):
self.searching = False
self.search_start = 0
self.query_timeouts = self.settings.get("min_timeout", 5)
if self.settings.get("playback_mode") in [PlaybackMode.FORCE_AUDIOSERVICE, PlaybackMode.AUDIO_ONLY]:
self.has_gui = False
else:
self.has_gui = is_gui_running() or is_gui_connected(self.bus)

@property
def settings(self) -> dict:
Expand Down Expand Up @@ -179,7 +183,6 @@ def handle_skill_response(self, message):
"enough!")

# populate search playlist
has_gui = is_gui_running() or is_gui_connected(self.bus)
results = message.data.get("results", [])
for idx, res in enumerate(results):
if self.media_type not in [MediaType.ADULT, MediaType.HENTAI]:
Expand Down Expand Up @@ -212,7 +215,7 @@ def handle_skill_response(self, message):
continue

# filter video results if GUI not connected
if not has_gui:
if not self.has_gui:
# force allowed stream types to be played audio only
if res.get("media_type", "") in self.cast2audio:
LOG.debug("unable to use GUI, "
Expand Down

0 comments on commit 1fd9856

Please sign in to comment.