ehough/docker-kodi

Add support for PVR clients

atetzner opened this issue · 18 comments

At the moment, you can not use PVR backends like e.g. MythtTV to watch live TV or TV recordings as the PVR client add-ons are not available in kodi.

Please also install the kodi-pvr-* packages to add support for PVR backends. (In my case, I am interested in kodi-pvr-mythtv).

See also: https://kodi.wiki/view/MythTV_PVR

Thanks for this suggestion! You probably already saw that this feature is noted in the "Future Work" section of README. But now that you've filed this issue, I'm motivated to get it done. I'll start work on it this weekend and post my updates here.

I think it might be as simple as installing kodi-pvr-* ..

Isn't it possible to install kodi addons afterwards from within kodi?
If that is possible without root permissions, one could run x11docker ... kodi with option --home (or --homedir) to store addons and configuration.

Generally speaking, yes. But I think this is not the case for PVR clients - but I don't know for what reason.

As you can see from the link I posted in the first comment, the PVR client addons "should be pre-installed but disabled". Unfortunately, they aren't pre-installed in ehough/docker-kodi image. I couldn't find a possibility to download the clients in Kodi. When you read further on, you will read in "Getting the latest version", that the PVR addon can only be installed from an Ubuntu PPA or compiling it yourself from source - not from a normal Kodi repository.

I did a quick test with this Dockerfile:

FROM erichough/kodi
RUN apt-get update
RUN apt-get install -y kodi-pvr-mythtv

(apt-get install -y kodi-pvr-* fails with some dependency issues).

The addon appears. I am not familar with it; does it need some receiver hardware?
Maybe a hardware device file in /dev must be shared with container. Maybe it is enough to set x11docker option --hostnet.

I think, this will do the trick - I will test it later on.

For MythTV, you need a TCP/IP connection to the backend service, so no special device is required.

For MythTV, you need a TCP/IP connection to the backend service, so no special device is required.

That sounds good! Is there a way to predict the TCP port? --hostnet should do the trick, but degrades container isolation. It is better to only provide this one port to kodi container.
With some luck no additional setup is needed at all and it runs with regular internet connection.

The default port to the MythTV backend is 6543, but it can be changed in the settings.

I am not familiar with other PVR software so maybe there are other requirements or other ports that need to be opened.

The default port to the MythTV backend is 6543,

It should work to add "-p 6543" or "-p 6543:6543" to x11docker command after --

Taking the example from README.md:

$ x11docker --xorg                                \
            --vt 7                                \
            --pulseaudio                          \
            --wm none                             \                
            --gpu                                 \
            --homedir /host/path/to/kodi/home     \
            -- "-v /host/path/to/media:/media:ro" \
               "-p 6543:6543 "                    \
            erichough/kodi

Isn't it possible to install kodi addons afterwards from within kodi?

Generally speaking, yes. But I think this is not the case for PVR clients - but I don't know for what reason.

Kodi PVR add-ons are "special" in that they must be installed via APT (for now, anyway).

apt-get install -y kodi-pvr-* fails with some dependency issues

I've filed a corresponding bug here, in case anyone wants to follow along.

I tested @mviereck's suggestion and they were almost perfect:

The suggested Dockerfile with just apt-get install -y kodi-pvr-mythtv works like a charm and the PVR addon is available in Kodi.

Just the x11docker commandline wasn't right - probably a misunderstanding: Kodi needs to connect as a client to a server on the docker host. So you need to connect to the docker host. I used the following command, to create an /etc/hosts entry in the docker container called "docker-host" with the IP-adress of the host:

"--add-host=docker-host:$(ip -4 addr show scope global dev eth0 | grep inet | awk '{print $2}' | cut -d / -f 1)"

After that you can setup the MythTV kodi addon using the hostname "docker-host" to connect to the MythTV backend.

@ehough : Instead of just asking you to add PVR support, I wanted to help and do the modifications myself - just to see, you already did it...

I built a container from your changed Dockerfile and it worked with my MythTV backend.

Thanks alot for resolving this issue so fast :)

@themagican
Could you test your network connection with:

"--add-host=docker-host:$(ip -4 addr show docker0 | grep inet | awk '{ print $2 }' | cut -d/ -f1)"

Most important point of this variant is to use more general interface docker0 than special eth0.

For clarification: It is enough to use --add-host without providing a TCP port with -p?

@mviereck : I can confirm, that the commandline argument you posted works.

For completeness: The following commandline works for me with MythTV (no -p necessary, as you see)

x11docker --hostdisplay --pulseaudio --wm none --gpu --homedir /home/usr/kodi-home -- "-v /home/usr/media:/media:rw" "--add-host=docker-host:$(ip -4 addr show docker0 | grep inet | awk '{ print $2 }' | cut -d/ -f1)" erichough/kodi:pvr2

I found a problem with the image: The timezone is wrong ...

If I use the current latest from docker hub, the timezone is correct (for me at the moment 22:36 with timezone Europe/Berlin). When I use the newly built image, the time in kodi is 20:36. If I exec into the running container and execute date the time is correct with 22:36 - so it must be some kodi addon that breaks the timezone settings :(

(I am unavailable for the next days and can not test .... sorry)

I found a problem with the image: The timezone is wrong ...

Strange. x11docker shares host time with -v /etc/localtime:/etc/localtime:ro and that seems to work in general. No sure what kodi addons may change here.

Another cause may be the switch from base ubuntu:xenial to ubuntu:bionic. Maybe Ubuntu changed something. Though, a test with

docker run -v /etc/localtime:/etc/localtime:ro ubuntu:bionic date

shows me the same time as on host (in Germany).

I can confirm, that the commandline argument you posted works.

Thanks! I am still thinking about a solution that uses default values without the need to change addon settings. I see localhost IP 127.0.0.1 and two ports: 6543 and 6544 in addon configuration. Maybe both of them must be published to container:

-p 6543:6543/tcp -p 6544:6544/tcp

I don't really understand the --expose option, but maybe it is needed, too:

--expose 6543 --expose 6544

Just the x11docker commandline wasn't right - probably a misunderstanding: Kodi needs to connect as a client to a server on the docker host.

With correct port configuration kodi should access them as if 127.0.0.1 would be the host. Though, I am not familar with network setups at all.

The Timezone in the container is generally correct - when exec-ing into the running container, date will give you the correct time. It is a Timezone issue inside Kodi. I read about another add-on that broke the Timezone in Kodi.

I am not familiar with docker command line arguments in detail, but I think the -p argument binds a host port to the container. So when you connect from another machine to the host port given to -p your request will end in the container. Therefore "-p 6543:6543" does not work, as it tries to bind the port 6543 to the container, but the port has already been bound by MythTV.

What we need is a connection from the container to the host. For this, you only need a hostname or IP of the host - no other special settings are needed.

I still believe it is possible to share the TCP port directly. This could work without --add-host:

-p 6543:6543/tcp -p 6544:6544/tcp --expose 6543 --expose 6544

What we need is a connection from the container to the host. For this, you only need a hostname or IP of the host - no other special settings are needed.

The special setting still to do for the --add-host solution is in the mythtv addon, one has to replace 127.0.0.1 with dockerhost. Personally I prefer default setups that already work.

It is possible to set dockerhost entry for mythtv in Dockerfile. The idea is to provide config files in /etc/skel that are copied to HOME on startup if HOME is empty:

RUN mkdir -p /etc/skel/.kodi/userdata/addon_data/pvr.mythtv
RUN echo '<settings>\n\
    <setting id="host" value="dockerhost" />\n\
</settings>\n\
' > /etc/skel/.kodi/userdata/addon_data/pvr.mythtv/settings.xml

# startscript to copy dotfiles from /etc/skel
RUN echo '#! /bin/sh\n\
[ -n "$HOME" ] && [ ! -e "$HOME/.kodi" ] && cp -R /etc/skel/. $HOME/ \n\
exec /usr/local/bin/entrypoint.sh $*\n\
' > /usr/local/bin/start && chmod +x /usr/local/bin/start 

ENTRYPOINT ["/usr/local/bin/start"]

This may have to be done for many kodi addons. Therefore I would prefer a TCP solution.
Now it's up to Eric what he prefers :-).

The updated image (with the PVR packages pre-installed) are now up on Docker Hub, so you can docker pull erichough/kodi to use it. @mviereck and @themagican, thanks very much to both of you for your support in getting this done!

Regarding the MythTV TCP connection, after thinking about it over the past few days it's my opinion that there's no elegant "universal" solution. The problem is that we don't know where the user is running MythTV; it could be on the Docker host, in another container, or somewhere else on the local network. One way or another, the user will need to configure the add-on to tell it where MythTV is listening. For that reason, I think trying to handle this problem is out of the scope of this project (at least for now). Please let me know if you feel otherwise, and keep the feedback coming!