Skip to content

Commit

Permalink
update discovery infos
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Sep 16, 2020
1 parent 955a3db commit e45aa9b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
2 changes: 1 addition & 1 deletion music_assistant/constants.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
11 changes: 6 additions & 5 deletions music_assistant/mass.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
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

Expand Down Expand Up @@ -248,13 +248,14 @@ def __handle_exception(loop, context):
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:
Expand Down
12 changes: 9 additions & 3 deletions music_assistant/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
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
Expand Down Expand Up @@ -143,6 +144,7 @@ async def async_setup(self):
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/")
Expand Down Expand Up @@ -217,10 +219,14 @@ def external_url(self):
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")
Expand All @@ -234,7 +240,7 @@ async def async_login(self, request):
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."""
Expand Down

0 comments on commit e45aa9b

Please sign in to comment.