orenskl / HiFiStreamer

An Audiophile open source streamer based on a Just enough OS Linux distribution and Mopidy
https://www.hifistreamer.org
11 stars 1 forks source link

Please add Plexamp support #50

Open thisisawesome1994 opened 5 months ago

thisisawesome1994 commented 5 months ago

Hi, can you add support for plexamp (linux with webui)? If so, it would be cool, as I have not ever found a distro let alone a receiver that supports streaming services aswell as plexamp... It is made for raspberry pi, but also works for x86... You just need to manually setup the audio backend if using a cli based os (no gui). I got it to work on my n100 intel system, which I have rack mounted. Would be so nice to have it with my other audio component... (Plexamp requires nodejs and some other components and has its own webui on port 32500, but would still like it to manage my own library, and have spotify/tidal/qobuz etc as redundancy).

Awaiting your response,

Joannes Wyckmans

Note: Can you also include a list of currently working and functional plugins for mopidy and planned ones?

orenskl commented 5 months ago

Hi Joannes,

Thanks for your suggestion I added a section in the README that describes the Mopidy plugins. Ofcourse more plugins can be added. One of the plugins I plan to add is Mopidy-Jellyfin since I use it as my media server.

As for Plexamp since it is a full desktop application it will require many packages to be installed. I really try to keep this distribution a bare minimum for an audiophile player, but of course this can be done. Here are my thoughts :

thisisawesome1994 commented 5 months ago

I dont know exactly what you mean with full desktop application. You can use this url: https://plexamp.plex.tv/headless/Plexamp-Linux-headless-v4.10.1.tar.bz2

It is a headless application if you use the linux headless from raspberry pi. It is nodejs, and is working for both x86 as arm64(v8). It works on both out of the box as it compiles through nodejs etc. (architecture independent between x64, arm and arm64 binaries available in the tar)

thisisawesome1994 commented 5 months ago

Licensing issue, maybe.

orenskl commented 5 months ago

Ah the headless version yes it's much more simpler, but I think you would still need node.js on the n100. I am not sure if building node.js from source is easy

thisisawesome1994 commented 5 months ago

You can use apt install on Ubuntu and Debian systems. Some tutorials via google are not good. You can find using Google how to install plexamp headless. You'll need to find a way to put the plex claim token in. Maybe using a webui optional install, that runs a script in the background to install this optional? Like, make the install of plexamp optional, triggered using the webui where you can put the plex claim token?

orenskl commented 5 months ago

Yes, this is a good option

thisisawesome1994 commented 5 months ago

Well, I would love that if you do that. Have not seen anyone do this, when I think it can be done. Thank you very much for reading here. I really appreciate. If you have any questions or need ideas to install we can talk offcourse. I am willing to help if I can.

thisisawesome1994 commented 5 months ago

Btw, how would I be able to add it myself to the image? Can this be done? I am not very familiar with coding, but know some things about python or linux shell-scripts, although very limited. I usually make simple html or python using chatgpt and change it a bit. But that would not work for larger more complex scripts. I might be able to do some bug finding or testing if you explain me what logs and where to find etc? Would love to help with the plex plugin, if you would want to do that? I will try to search for a script or create one from a tutorial that works some time later.

thisisawesome1994 commented 5 months ago

btw, I found this... https://www.maxhaesslein.de/notes/build-your-own-headless-raspberry-pi-audio-player/

Maybe things like this are helpfull.

I have made the following script using chatgpt. But I will have to change it to make it work correctly on ubuntu first. I remember that the correct version of nodejs could be installed with npm. I am trying to find the correct commands online...

#!/bin/bash

# Install Plexamp headless on Ubuntu 24.04

# Update and upgrade system
sudo apt-get update && sudo apt-get upgrade -y

# Install dependencies
sudo apt-get install -y wget curl unzip jq libasound2

# Install Node.js v20
NODE_MAJOR="20"
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

# Load nvm and install Node.js
export NVM_DIR="$HOME/.nvm"
source "$NVM_DIR/nvm.sh"
nvm install 20

# Verify Node.js installation
node -v
npm -v

# Find the path of the node executable
NODE_PATH=$(which node)

# Create Plexamp directory
sudo mkdir -p /opt/plexamp
cd /opt/plexamp

# Download and unzip Plexamp headless
wget https://plexamp.plex.tv/headless/Plexamp-Linux-headless-v4.10.0.tar.bz2 -O plexamp.tar.bz2
sudo tar -xvjf plexamp.tar.bz2

# Prompt user for Plex claim token
read -p "Enter your Plex claim token: " PLEX_CLAIM_TOKEN

# Create Plexamp service file
sudo tee /lib/systemd/system/plexamp.service > /dev/null <<EOF
[Unit]
Description=Plexamp
After=network-online.target
Requires=network-online.target

[Service]
Type=simple
User=$USER
WorkingDirectory=/opt/plexamp
ExecStart=$NODE_PATH /opt/plexamp/js/index.js
Restart=on-failure
Environment="PLEX_CLAIM_TOKEN=$PLEX_CLAIM_TOKEN"

[Install]
WantedBy=multi-user.target
EOF

# Reload systemd manager configuration
sudo systemctl daemon-reload

# Enable and start Plexamp service
sudo systemctl enable plexamp
sudo systemctl start plexamp

# Verify the status of the Plexamp service
sudo systemctl status plexamp

echo "Plexamp Headless installation complete. Please visit http://<your_IP_or_Hostname>:32500 to configure."

Maybe you can enhance the script to make it fit in your image?

This script is not exactly tested, but should be close to working..

thisisawesome1994 commented 5 months ago

I edited the above post a few times, now I wont edit it anymore.. I had to use alsa-utils etc. But I think you already have an audio daemon installed in the os?

orenskl commented 5 months ago

Currently the os is limited to ALSA output directly without any daemon or service running since it is mainly based on mopidy which outputs the sound stream directly to ALSA via gstreamer. Since I am busy elsewhere right now my suggestion is to run HiFiStreamer as is and then SSH into the machine and try to install manually plexamp and see if its working

thisisawesome1994 commented 5 months ago

Sure, I will try that. Plexamp also uses alsa, so that would not be a problem. Probably that part of the script is not accurate, as I am sure it uses alsa since I had to install it to make it work on my n100. How do I ssh into it. Is there a default password for the root user?