Skip to content

MusicMagic: add configurable host for remote MusicIP instances#1605

Merged
michaelherger merged 4 commits into
LMS-Community:public/9.2from
jonstahl:feature/musicmagic-configurable-host
Jun 29, 2026
Merged

MusicMagic: add configurable host for remote MusicIP instances#1605
michaelherger merged 4 commits into
LMS-Community:public/9.2from
jonstahl:feature/musicmagic-configurable-host

Conversation

@jonstahl

Copy link
Copy Markdown
Contributor

MusicMagic: Add configurable host for remote MusicIP instances

Problem

The MusicMagic plugin hardcodes localhost in all HTTP requests to the MusicIP
Mixer API across three files (Plugin.pm, Importer.pm, Common.pm). This
makes 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:

Can't connect to port 10002 - MusicIP disabled.

even when MusicIP is running and reachable, because all requests go to
localhost inside the LMS process/container rather than to the actual MusicIP
host.

Solution

This change adds a host preference to the MusicMagic plugin, read via
$prefs->get('host'), defaulting to 'localhost' when not set. This is
consistent with how the existing port preference works and is fully backwards
compatible — 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:

host: <hostname-or-ip>

For example, in a Docker environment where MusicIP runs in a container named
musicip:

host: musicip
port: 10002

Files changed

  • Slim/Plugin/MusicMagic/Plugin.pm — adds $MMShost variable, reads from
    prefs in _syncHTTPRequest, replaces all localhost URL references
  • Slim/Plugin/MusicMagic/Importer.pm — adds $MMShost variable, reads from
    prefs in initPlugin and startScan, replaces all localhost URL references
  • Slim/Plugin/MusicMagic/Common.pm — reads host from prefs as a local
    variable in grabFilters, replaces localhost URL reference
  • Slim/Plugin/MusicMagic/Settings.pm — adds host to the list of managed
    preferences 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 localhost when the preference has not been set
  • Slim/Plugin/MusicMagic/strings.txt — adds SETUP_MMSHOST and
    SETUP_MMSHOST_DESC string 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.

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>
@jonstahl
jonstahl force-pushed the feature/musicmagic-configurable-host branch from 02d3141 to 960ef7a Compare June 28, 2026 06:19

@michaelherger michaelherger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
@jonstahl
jonstahl force-pushed the feature/musicmagic-configurable-host branch from 49e5ec7 to 91e71f7 Compare June 29, 2026 15:36
@jonstahl

Copy link
Copy Markdown
Contributor Author

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."

Comment thread Slim/Plugin/MusicMagic/Common.pm Outdated
Comment on lines +80 to +81
my $MMSport = $prefs->get('port');
my $MMShost = $prefs->get('host') || 'localhost';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can do, thanks!

@michaelherger

Copy link
Copy Markdown
Member

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."

Hmm... interesting: I'm using quite a few containers which interact. But maybe not by localhost? What DSM are you using? (I think my 1517+ is reaching the end and is no longer getting updates...)

@jonstahl

jonstahl commented Jun 29, 2026 via email

Copy link
Copy Markdown
Contributor Author

jonstahl and others added 2 commits June 29, 2026 09:28
…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>
@jonstahl

Copy link
Copy Markdown
Contributor Author

Also added a full set of translations. :-)

@michaelherger michaelherger left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's give this a try! Thanks!

@michaelherger
michaelherger merged commit edcf6c7 into LMS-Community:public/9.2 Jun 29, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants