Skip to content

Commit

Permalink
feat/targeted OCP queries
Browse files Browse the repository at this point in the history
allows ovos-media to query individual OCP skills
  • Loading branch information
JarbasAl committed Apr 9, 2024
1 parent 499f8aa commit ba9d485
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ovos_workshop/skills/common_play.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def bind(self, bus):
super().bind(bus)
self.add_event('ovos.common_play.query',
self.__handle_ocp_query)
self.add_event(f'ovos.common_play.query.{self.skill_id}',
self.__handle_ocp_query)
self.add_event('ovos.common_play.featured_tracks.play',
self.__handle_ocp_featured)
self.add_event('ovos.common_play.skills.get',
Expand Down Expand Up @@ -420,15 +422,19 @@ def __handle_stop_search(self, message):
self._stop_event.set()

# @killable_event("ovos.common_play.search.stop", react_to_stop=True)
def __handle_ocp_query(self, message):
def __handle_ocp_query(self, message: Message):
"""Query skill if it can start playback from given phrase."""
self._stop_event.clear()
search_phrase = message.data["phrase"]
self._current_query = search_phrase
media_type = message.data.get("question_type",
MediaType.GENERIC)

if media_type not in self.supported_media:
if message.msg_type == f'ovos.common_play.query.{self.skill_id}':
# make message.response work as usual
message.msg_type = f'ovos.common_play.query'
elif media_type not in self.supported_media:
# skip this skill, it doesn't handle this media type
return

self.bus.emit(message.reply("ovos.common_play.skill.search_start",
Expand Down

0 comments on commit ba9d485

Please sign in to comment.