songchenwen / plexdlnaplayer

There is no built in way to cast Plex music to DLNA speakers. This project will be the bridge.
https://hub.docker.com/r/songchenwen/plexdlnaplayer
GNU General Public License v3.0
34 stars 11 forks source link

Looked like a good idea, but I'm missing some help to get started... #6

Open FrankSausF opened 2 years ago

FrankSausF commented 2 years ago

Hi guys, this one really looked good, and for a short moment, I could see my desired player. But then I stopped the python, and now it's not working anymore. Not at all, not even after reinstallation. Maybe, I'm weak on the concept (and of course on programming, python debugging and ubuntu), but basically experienced in any IT matter, so here's the story:

I'm running plex server on ubuntu 20.04 (server) as a virtual machine on my qnap nas. Works fine for the moment, quick, streamlined, as it should. Plex clients easily access and get the media quickly. Should purely act as a headless server. But I want to stream to DNLA hardware (as most here). So, I cloned the github and added (pip3) all the modules that it stated to miss (try and error, one by one). For JUST ONE TIME, the thing came up, offered my DNLA for registration in the web page, I did so, and for once, the player was visible in my plex environment. Then, I did the mistake to stop the script. The player disappeared. OK, so I figured out that the script should be permanently running when the server will be up. But, doing so, the player did not reappear, the web page ran into internal server error, end of the show. I flipped back the snapshot of the virtual machine to repeat the exercise of installing and getting access to my players successfully before stopping the srcipt. But this does not work. The player was visible once again in the registration screen, plex.tv/link accepted it, but it did not appear as a player in plex. The server page (port 32488) offers "Server error", without saying anything further.

So, here's the questions: 1.) What do I need to do to get a stable installation of the script in ubuntu 20.04 server? Is there a better context to install and run than in my user directory? 2.) Does this script need to be running all the time when the server will be up? 3.) What will happen, if the server as such is being shut down / restarted? Will I need to re-register all my devices manually again?

The deal is: If there will be a solution, I'll be glad to document it in the sense of writing an installation article for less advanced users for wiki. I'm glad to assist for testing.

Cheers!

FrankSausF

P.S.: Docker is out of the question for me. I'm fine with virtual machines. I've tried it, and Docker Station shot the network configuration of my NAS in a way that I really poured some sweat to get basic control of the device again without erasing all users.

garbled1 commented 2 years ago

It works on a VM, here is what I learned:

1) I couldn't get it to work sanely without specifying both CONFIG_PATH and HOST_IP on the commandline. 2) When you go to plex to bind a device, immediately go back to the bind page, and click the check linked box. 3) Once you do that, you should now see a data.json file in the config path. Now when you restart this service, it will remember the bindings, and everything just works. 4) Yes, you need to run this at all times you want to proxy DLNA. 5) Yes, it works fine on a VM, I have only ever tried it on a VM.

My setup was to build a venv for it, in it's own directory somewhere, and then a quick service file. I also created a local user to run it.

[Unit]
Description=PlexDLNAPlayer
Documentation=https://github.com/songchenwen/plexdlnaplayer
After=network-online.target

[Service]
User=plexdlna
Type=simple
Environment=HOST_IP=xxxxxx
Environment=CONFIG_PATH=/home/plexdlna/config
WorkingDirectory=/opt/plexdlnaplayer
ExecStart=/opt/plexdlnaplayer/venv/bin/python3 /opt/plexdlnaplayer/main.py
Restart=always
RestartSec=30

[Install]
WantedBy=multi-user.target
FrankSausF commented 2 years ago

Cheers garbled1,

I'm not gone; I'm still chewing on it...

It does not work out, and I don't yet understand why. I had been trapped to run int from the command prompt before running it as a service. And it seems to recognise all my players, adding them to the settings file it produces. But it is not able to make reliable contact, though registration looks OK in plex.tv. And stopping the script will break the web service at the port given in config ("Error 500"), so I will have to edit config with another port and fire it up again... Probably, I'll have to get deeper into the question of configuration parameters as a service like you did.

I'm still fiddling with the procedure which - discontinued at this time of Christmas leftovers dinner preparations - looks like the follwing: 1.) Install pip for Python 3: sudo apt install python3-pip Check the installation: pip3 -V 2.) Create and use a virtual environment for the Python application: sudo apt install python3-venv sudo python3 -m venv /opt/plexdlna cd /opt/ 3.) Get rid of the sudo stuff, assuming, the currently loggen-on user is member of group www-data: sudo chgrp -c -R www-data /opt/plexdlna sudo chmod g+w plexdlna/ 4.) Clone the github to the directory of the new application: source plexdlna/bin/activate cd plexdlna git clone https://github.com/songchenwen/plexdlnaplayer.git mkdir config cd plexdlnaplayer 4.) Install the required pip modules: sudo pip install -r requirements.txt 5.) Edit the configuration file: nano /opt/plexdlna/plexdlnaplayer/settings/init.py --> Edit line config_path = "/opt/plexdlna/config/" --> Edit line host_ip = "192.68.2.71" 6.) Fire everything up initially: cd /opt/plexdlna/plexdlnaplayer sudo python3 main.py 7.) Quickly register the players and check them as registered.

Result is that I can register my player, they even appear in the web interface from time to time. I can read their status entries coming through the console, so they are talking to the python. But they don't play what they should...