[PLUGIN] Plex Music

I created a music source plugin for Plex.

It pulls the audio files directly using the Plex API from the server.

Right now it just requires you to put in your plex token along with IP and port of your plex server. Plex token for the server is a little bit annoying to get but its one time thing.

Plugin added.

Currently only pulls the Artists, Albums and Playlists

It just uses the Plex UI for playback.

I know we can use DNLA to playback Plex but not playlists. I mainly wanted to have playlists because that is how I use it.

Let me know if this is useful for anyone and have any issues with it if you try it.

1 Like

It pulls artists, albums and playlists

Welcome to the community, @mochan - and what an entrance! This is a seriously impressive first plugin.

I have had a good look through the code and want to share some feedback. The overall quality here is well above what we typically see, so please take the issues below in the spirit they are intended - this is already close to being ready, and addressing these will get it over the line.

What you got right

Before the issues list, I want to call out the things that are genuinely well done here, because there is a lot to like.

The layered architecture (api-client → parser → service → adapter) with clean separation of concerns is textbook good engineering. Each layer is independently testable, and you have actually tested them - eight test files covering parsers, the API client with proper HTTP mocking, the service facade, and the Volumio adapter. That is more test coverage than most plugins in the store have.

The TypeScript is strict-mode with noUncheckedIndexedAccess, proper null handling throughout, separate raw API types versus domain types, and a thoughtful error hierarchy with PlexApiError → PlexAuthError / PlexConnectionError including proper error chaining via cause. The URI encoding scheme for Plex keys (slash to double-underscore) is a practical solution applied consistently. And delegating playback to MPD via consume mode is exactly the right pattern for a Volumio music service.

The development tooling (explore.ts, play.ts, plex-browse.ts) shows a mature workflow. Being able to validate stream URLs independently of Volumio via ffplay is a smart approach.

So - well done. Now for the things that need attention.

Must fix before submission

1. The dist/ directory is missing from the archive. The index.js entry point does require('./dist/index.js') but there is no dist/ folder in the zip. The install.sh only runs npm install --production, which will not compile TypeScript. Without dist/, the plugin will crash immediately on enable. Either include the pre-built dist/ in your release archive, or rethink the build pipeline. Compiling on-device is not practical for ARM targets.

2. The MPD addid command may be wrong. In your _clearAddPlayTrack method you send sendMpdCommand("addid", [track.uri]). Other music service plugins (YouTube Music, Spotify, etc.) use "add" for HTTP stream URLs. The addid command returns a song ID you are discarding, which suggests "add" was the intended command. Please test this against actual Volumio hardware - it may work on some MPD versions and fail on others.

3. Token field should be masked. Your UIConfig.json uses "type": "text" for the token input. Change this to "type": "password" so the Plex token is not displayed in cleartext on the settings page.

Should fix

4. N+1 API calls in explodeUri. When exploding an album or playlist, you first fetch all tracks, then call getPlayableTrack individually for each one. Each of those makes a separate HTTP request to re-fetch metadata you already have. For a 20-track album that is 21 requests when 1 would do. The track objects from getAlbumTracks already contain the streamKey you need - just build the stream URL directly from that using buildStreamUrl.

5. Browse-back from album tracks goes to root. Your browseAlbum method sets prev: { uri: "plex" }, which sends the user back to the Plex root menu instead of back to the albums list or the artist they came from. Compare with browsePlaylist which correctly sets prev to "plex/playlists". At minimum, set it to "plex/albums".

6. No HTTPS support. The api-client hardcodes the http module and stream-resolver hardcodes http:// in URLs. Many Plex servers use HTTPS. If supporting HTTPS is not in scope for v1, please document this clearly - especially since auth tokens are being sent in the clear.

7. Unused modules. PlaybackController, PlaylistManager, and UIStateManager are fully implemented and tested but never actually used - the adapter delegates everything to MPD, which is correct. Either remove these or add a note explaining they are scaffolding for future use. They add review overhead as-is.

Nice to have

8. Large library performance. getAllArtists and getAllAlbums fetch everything across all libraries in one go. For users with thousands of albums this will be slow. Plex supports pagination via X-Plex-Container-Start and X-Plex-Container-Size - worth considering for a future release.

9. Package.json gaps. The author field is empty, there is no LICENSE file despite the ISC declaration, no repository field, and no engines field specifying Node compatibility.

10. Token appears in logs. Your logger calls include full URIs which will contain the Plex token in stream URLs. Consider masking tokens in log output.

11. scripts/ directory. The development scripts have no purpose on a deployed Volumio device - exclude them from the install package.

12. Default host. localhost as the default host only works if Plex runs on the same device as Volumio, which is rare. A blank default with clear guidance would be more user-friendly.

Summary

This is strong work. The architecture is clean, the code is well-typed, the tests are thorough, and the Volumio integration patterns are correct. The critical blocker is just the missing dist/ directory - fix that plus the MPD command and the token masking, and you have a solid v1 ready for the store.

Looking forward to seeing this progress. The Plex user base in this community is not small, and having proper playlist support (which DLNA lacks, as you noted) fills a real gap.

Kind Regards,

One thing I would like to point out:

Most of my plugins that delegate playback to mpd plugin do send addid to MPD instead of add. That way, through addtagid command, I’d be able to add tags like title, artist and album to MPD’s playlist for the added song. This enables mpd plugin to capture events with the correct song info and push state encapsulating that info accordingly. This is important for streams that do not provide metadata at the beginning or at all.

Thank you for the awesome review.

I have a few TODOs left and I will update as I finish them.

  1. TODO
  2. Following the jellyfin plugin, I decided to use the ID to put in the metadata. It was working before because I think it reads it from the file I think. Fixed
  3. Fixed.
  4. Fixed
  5. Fixed
  6. Fixed
  7. TODO
  8. Fixed
  9. Fixed
  10. Fixed
  11. This is not deployed in dist. This is for sanity checking against real plex server rather than mocked unit tests.
  12. Fixed
1 Like

Hi Mochan,

it is amazing too see the growing amount of useful plugins for Volumio 4 and how sophisticated the way plugins are developed increased.

I will setup a Plex server to test as soon as i will find your plugin in the beta store.

Many server options like Jelly and so on, most powerful seems to be LMS as long as there are hiccups with DLNA :wink::wink:

everything with advantages and disadvantages for being setup easily for the one that simply wants to listen to music

LMS seems to be the most powerful but I think Plex could be easier to integrate for the non tech just music lover - let’s see :muscle:

Anyway thank you - those who already are running Plex will love it.

and special thanks to @nerd for supporting

BR Josef

I have fixed the 1 and 7 as well by putting the dist folder and removing unneeded files.

I have also created the pull request on the plugins.

Thank you @nerd @patrickkfkan and @Josh2000 for taking a look.

1 Like

I use Plex because of a few unique features like Plexamp app, smart playlists and others.

It’s so nice now to be able to stream it in Volumio with this plugin.

The pull request has been merged and it is available in beta.

It is available in the beta plugins channel.

If you have any issues, please let me know.

Hi mochan,

Really appreciate the plugin; it’s running flawlessly for me. One thing I’m wondering: is it possible to sort or display albums by Album Title or Composer rather than Artist? My classical library is huge, and with around 2,000 albums, the artist-based view becomes quite chaotic.

Thanks again for the excellent work.

Thank you Steve for trying out the plugin.

Also, thank you for the great idea. I added sorting criteria in albums here

The albums don’t have composer tag on plex. But, the title sorting should work.

I also added sorting for artists.

I used new entries on the list for sorting. I’m not sure if there is a better way to do this in volumio?

I’ll have more a new PR created probably next weekend when I have more of the stuff I’m working on put together. If you’d like to try it out now, you’ll have to build the plugin yourself or I’ll update once I’ve verified everything is good and starting working getting a PR merged.

Thanks, mochan, for all your continued work on this plugin. From your screenshot, it looks like album‑title sorting is working exactly as hoped. As an end user, though, my skills are pretty limited—I wouldn’t know where to begin with building a plugin myself. I’m in total admiration of people like you (and ā€œNERDā€) who can make this stuff happen. I’m more than happy to wait until the updated version appears in the plugin store.