MusicMagic: add configurable host for remote MusicIP instances#1605
Conversation
Replace all hardcoded localhost references in Plugin.pm, Importer.pm, and Common.pm with a $MMShost variable read from prefs (defaulting to 'localhost'), and expose a Host field in the Settings UI alongside the existing Port field. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Jon Stahl <jonstahl@gmail.com>
02d3141 to
960ef7a
Compare
michaelherger
left a comment
There was a problem hiding this comment.
You'll have to implement some basic path mapping algorithm. Or at least clearly document the fact that in order for this to work the user MUST make sure the paths to the music files must be absolutely identical between LMS and MIP.
And make sure you add textual content in DE, FR, NL, too. Should be easy using those LLMs nowadays 😉.
…r remote host Document that file paths must be identical on both LMS and MusicIP hosts, and that Docker users should use matching volume mount paths. Add DE, FR, and NL translations for the new SETUP_MMSHOST strings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Jon Stahl <jonstahl@gmail.com>
49e5ec7 to
91e71f7
Compare
|
Thanks! Translations included and documentation about path mapping. I don't think it's necessary to introduce path mapping on the LMS side because Docker handles this just fine through mount paths. FWIW, I've been running musicip in a separate VM this way for years, and was only forced to "write" this patch because it seems that synology made some changes to their networking such that both LMS and MIP containers now no longer see eachother on "localhost." |
| my $MMSport = $prefs->get('port'); | ||
| my $MMShost = $prefs->get('host') || 'localhost'; |
There was a problem hiding this comment.
One more thing... we now have this (or similar) construction in several places, where we always have to make sure we fallback to localhost if needed etc. Please create a new helper getBaseUrl() or similar in Common.pm which would do this and return the full http://<hostname>:<port>/api as a result. Use this wherever you need the URL instead of constructing it locally. Thanks!
Hmm... interesting: I'm using quite a few containers which interact. But maybe not by |
|
I'm using a (now fairly old) DS918+, which has been running the LMS
community image and the ptoulouse/musicip image for many years. They lost
communication a few months ago, and I didn't have motivation to look into
it now.
I *think* the issue I ran into may be a function of the fact that I was
using the default Docker bridge network, which the Docker docs (
https://docs.docker.com/engine/network/drivers/bridge/) state is
non-preferred. However, it worked just fine for years... until it didn't. I
tried adding a custom bridge, but that was not accessible via "localhost"
(possibly I didn't do it right) so I wound up with this patch to let me
specify the actual name of the image.
IOW, this may be an "overkill" solution but it does provide considerable
flexibility.
|
…seUrl() Add getBaseUrl() to Common.pm which handles the host/localhost fallback and port, returning the full http://<host>:<port>/api base URL. Replace all inline URL constructions across Common.pm, Importer.pm, and Plugin.pm with calls to this helper. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Jon Stahl <jonstahl@gmail.com>
Add CS, DA, ES, FI, HE, HU, IT, NO, PL, PT, RU, SV, ZH_CN translations for the new SETUP_MMSHOST and SETUP_MMSHOST_DESC strings. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Jon Stahl <jonstahl@gmail.com>
|
Also added a full set of translations. :-) |
michaelherger
left a comment
There was a problem hiding this comment.
Let's give this a try! Thanks!
MusicMagic: Add configurable host for remote MusicIP instances
Problem
The MusicMagic plugin hardcodes
localhostin all HTTP requests to the MusicIPMixer API across three files (
Plugin.pm,Importer.pm,Common.pm). Thismakes it impossible to use MusicIP when it is running on a different host than
LMS — a common scenario when both are running in separate Docker containers,
VMs, or separate machines.
Users in this situation see:
even when MusicIP is running and reachable, because all requests go to
localhostinside the LMS process/container rather than to the actual MusicIPhost.
Solution
This change adds a
hostpreference to the MusicMagic plugin, read via$prefs->get('host'), defaulting to'localhost'when not set. This isconsistent with how the existing
portpreference works and is fully backwardscompatible — existing installations with MusicIP on the same host require no
configuration changes.
The host can be configured via the MusicMagic settings page in the LMS web
interface (a new MusicIP Host field, added alongside the existing port
field). It can also be set directly in
<config dir>/prefs/plugin/musicip.prefs:For example, in a Docker environment where MusicIP runs in a container named
musicip:Files changed
Slim/Plugin/MusicMagic/Plugin.pm— adds$MMShostvariable, reads fromprefs in
_syncHTTPRequest, replaces alllocalhostURL referencesSlim/Plugin/MusicMagic/Importer.pm— adds$MMShostvariable, reads fromprefs in
initPluginandstartScan, replaces alllocalhostURL referencesSlim/Plugin/MusicMagic/Common.pm— readshostfrom prefs as a localvariable in
grabFilters, replaceslocalhostURL referenceSlim/Plugin/MusicMagic/Settings.pm— addshostto the list of managedpreferences so the settings page reads and writes it
Slim/Plugin/MusicMagic/HTML/EN/plugins/MusicMagic/settings/musicmagic.html— adds a MusicIP Host input field above the existing port field; defaults
to
localhostwhen the preference has not been setSlim/Plugin/MusicMagic/strings.txt— addsSETUP_MMSHOSTandSETUP_MMSHOST_DESCstring keys (EN only; translations welcome)Testing
Tested on LMS v9.1.1 with MusicIP Mixer 1.8, both running in separate Docker
containers on a Synology NAS connected via a custom Docker bridge network.
MusicIP import scan completes successfully and song context menu options appear
as expected.