update discovery infos
authorMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 16 Sep 2020 18:26:49 +0000 (20:26 +0200)
committerMarcel van der Veldt <m.vanderveldt@outlook.com>
Wed, 16 Sep 2020 18:26:49 +0000 (20:26 +0200)
music_assistant/constants.py
music_assistant/mass.py
music_assistant/web.py

index 8459d6e1736fbf13e005d6632cc360d1bc80c9b7..00f9fbdda8e89d93fea7929078e8a3c4fae53c47 100755 (executable)
@@ -1,6 +1,6 @@
 """All constants for Music Assistant."""
 
-__version__ = "0.0.29"
+__version__ = "0.0.30"
 REQUIRED_PYTHON_VER = "3.7"
 
 CONF_USERNAME = "username"
index b7bd00715d4dca486adebd30a6c7fe1841693f70..bebe017ba82e0df79f1041450b69a74c88b6f8e8 100644 (file)
@@ -22,7 +22,7 @@ from music_assistant.metadata import MetaData
 from music_assistant.models.provider import Provider, ProviderType
 from music_assistant.music_manager import MusicManager
 from music_assistant.player_manager import PlayerManager
-from music_assistant.utils import callback, get_hostname, get_ip_pton, is_callback
+from music_assistant.utils import callback, get_ip_pton, is_callback
 from music_assistant.web import Web
 from zeroconf import NonUniqueNameException, ServiceInfo, Zeroconf
 
@@ -248,13 +248,14 @@ class MusicAssistant:
     async def __async_setup_discovery(self):
         """Make this Music Assistant instance discoverable on the network."""
         zeroconf_type = "_music-assistant._tcp.local."
+        discovery_info = self.web.discovery_info
+        name = discovery_info["id"].lower()
         info = ServiceInfo(
             zeroconf_type,
-            name=f"{self.web.internal_url}.{zeroconf_type}",
-            server=f"{get_hostname()}.local.",
+            name=f"{name}.{zeroconf_type}",
             addresses=[get_ip_pton()],
-            port=self.web.http_port,
-            properties=self.web.discovery_info,
+            port=discovery_info["http_port"],
+            properties=discovery_info,
         )
         LOGGER.debug("Starting Zeroconf broadcast...")
         try:
index 765942d4e86148675f7080dfd1210474c50e950b..7bdb162b1071a2e1859434feb1c1edc27a119aa5 100755 (executable)
@@ -19,6 +19,7 @@ from music_assistant.constants import (
     CONF_KEY_PLAYERSETTINGS,
     CONF_KEY_PROVIDERS,
 )
+from music_assistant.constants import __version__ as MASS_VERSION
 from music_assistant.models.media_types import MediaType
 from music_assistant.models.player_queue import QueueOption
 from music_assistant.utils import get_external_ip, get_hostname, get_ip, json_serializer
@@ -143,6 +144,7 @@ class Web:
                 web.get("/jsonrpc.js", self.async_json_rpc),
                 web.post("/jsonrpc.js", self.async_json_rpc),
                 web.get("/ws", self.async_websocket_handler),
+                web.get("/info", self.async_info),
             ]
         )
         webdir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "web/")
@@ -217,10 +219,14 @@ class Web:
     def discovery_info(self):
         """Return (discovery) info about this instance."""
         return {
-            "id": f"musicassistant_{get_hostname()}",
+            "id": f"{get_hostname()}",
             "external_url": self.external_url,
             "internal_url": self.internal_url,
-            "version": 1,
+            "host": self.internal_ip,
+            "http_port": self.http_port,
+            "https_port": self.https_port,
+            "ssl_enabled": self._enable_ssl,
+            "version": MASS_VERSION,
         }
 
     @routes.post("/api/login")
@@ -234,7 +240,7 @@ class Web:
             return web.json_response(token_info, dumps=json_serializer)
         return web.HTTPUnauthorized(body="Invalid username and/or password provided!")
 
-    @routes.get("/info")
+    @routes.get("/api/info")
     async def async_info(self, request):
         # pylint: disable=unused-argument
         """Return (discovery) info about this instance."""