diff --git a/ovos_workshop/skills/common_play.py b/ovos_workshop/skills/common_play.py index 5bc08224..70a9da38 100644 --- a/ovos_workshop/skills/common_play.py +++ b/ovos_workshop/skills/common_play.py @@ -56,12 +56,13 @@ def ... vocab for starting playback is needed. """ - def __init__(self, supported_media=None, skill_icon="", *args, **kwargs): + def __init__(self, supported_media: List[MediaType] = None, + skill_icon: str = "", + skill_voc_filename: str = "", + *args, **kwargs): self.supported_media = supported_media or [MediaType.GENERIC] - skill_name = camel_case_split(self.__class__.__name__) - alt = skill_name.replace(" skill", "").replace(" Skill", "") - self.skill_aliases = [skill_name, alt] - + self.skill_aliases = [] + self.skill_voc_filename = skill_voc_filename self._search_handlers = [] # added via decorators self._featured_handlers = [] # added via decorators self._current_query = None @@ -78,6 +79,18 @@ def __init__(self, supported_media=None, skill_icon="", *args, **kwargs): self.ocp_matchers = {} super().__init__(*args, **kwargs) + def _read_skill_name_voc(self): + """read voc file to allow requesting a skill by name""" + if self.skill_voc_filename: + for lang in self.native_langs: + self.skill_aliases += self.voc_list(self.skill_voc_filename, lang) + if not self.skill_aliases: + skill_name = camel_case_split(self.__class__.__name__) + alt = skill_name.replace(" skill", "").replace(" Skill", "") + self.skill_aliases = [skill_name, alt] + # deduplicate and sort by str len + self.skill_aliases = sorted(list(set(self.skill_aliases)), reverse=True) + @property def ocp_cache_dir(self): """path to cached .csv file with ocp entities data @@ -142,6 +155,7 @@ def __handle_ocp_skills_get(self, message=None): it will search netflix instead of spotify """ message = message or Message("") + # TODO - aliases per lang self.bus.emit( message.reply('ovos.common_play.announce', {"skill_id": self.skill_id, @@ -337,11 +351,14 @@ def _register_decorated(self): super()._register_decorated() + # needs to be after super() because it needs self.config_core + self._read_skill_name_voc() # volunteer info to OCP self.bus.emit( Message('ovos.common_play.announce', {"skill_id": self.skill_id, "skill_name": self.skill_aliases[0], + "aliases": self.skill_aliases, "thumbnail": self.skill_icon, "media_types": self.supported_media, "featured_tracks": len(self._featured_handlers) >= 1}))