NON RUNNING POST ALERT!
Why am I doing this?
A bit of googling showed that the USB tuners I had bought do work under Linux with TVHeadEnd, and that you can use a program called tvhProxy to send this to Plex as if it was a HDHomeRun to watch live TV and have DVR functionality.
The reason for me doing this is that I want to put a TV in the kitchen, and I don't want to drill holes through the wall to put in an aerial, so if I can get live TV through Plex, I can put a chromecast, or fire stick or something on the TV in the kitchen and save me causing a complete mess in the kitchen with a drill..
With that in mind, I needed an idiots guide to follow as myself and Linux have a tempestuous relationship at the best of times. The guide by Kieran above seemed ideal, as it basically did what I needed but he didn't use the Xbox tuners and was tuning in TV in Australia It was a good start though but as you can guess by the fact I'm writing this, it wasn't completely idiot proof enough for me so I needed my own guide.
Pre-Requisites for this guide.
A physical machine, connected to your network, to put it on (VM's don't always play nicely with sharing USB resources, yours may work but I put this on a physical PC as I had a spare lying around).
Plex Server already setup and a Plex Pass subscription on a machine of your choice.
Xbox One USB Digital Tuner
Install Ubuntu Server 18.04.1 from USB.
Stick your boot medium in and boot your PC. Choose to boot from the medium and you will shortly be presented with the following screen.
Choose "Install Ubuntu"
If you have a worrking DHCP server on your network (and a lan cable attached), you'll see the following screen. If not it will say it cannot configure it, either way, just choose "Done" and move on.
If you need a proxy to get out on to the internet, enter it here. I don't so click "Done" when ready.
Choose "Done" on the alternate mirror details (the defaults are fine).
Click "Use An Entire Disk" if, like me, you are using an entire machine for this. If you are not, then choose your preferred option and click "Done" when ready.
Select the Disk. Only one in my machine so press Enter.
Final confirmation. No turning back after this stage. EVERYTHING ON YOUR DRIVE IS ABOUT TO BE LOST FOREVER. Yes, even your windows stuff, everything. So only proceed if you are sure you want to carry on. Select "Continue" if you do and let it do its thing formatting.
Now it will ask for usernames and passwords. Nice and simple, your name: tvheadend, servers name: tvheadend, username: tvhead, password of your choice. If you want to import your ssh identity, here is the place to do it. I do not. Click "Done".
Ignore all this, click "Done".
Watch the installer install all the gubbins and wait.
Once completed, a reboot now will appear. Click "Reboot Now" and let your machine reboot.
When it reboots (and you login), you'll see something similar to the screen below. If you see the installer again, you've let the machine boot from the install medium again, so reboot and remove it. Log in with the user and password we created earlier.
The important info here is the IP address for eno1, which in this case is 192.168.0.180. We will use this to SSH on to the machine using PuTTY and continue the configuration using that.
From another machine, using PuTTY, connect to your IP listed above (in my case, 192.168.0.180).
You will get a warning about an SSH key, this is only because its your first time logging in to the machine via SSH. Its perfectly fine and just click Yes to accept it.
You'll then be faced with this screen. Login using the details we created above, "tvhead" and the password you chose.
Once logged in, we need to set a static IP address. This is essential to allow the server to connect to Plex and to administer it via your web interface going forward.
We do this using netplan on Ubuntu 18.04 (this is new). Firstly we need to edit a new config file for our network adapter. We need to find out some details for this config file and we can get them by using the "ifconfig" command, so type that and press enter and something similar to the following will appear.
The highlighted section on the second line "inet 192.168.0.180" shows we have been allocated 192.168.0.180 by our DHCP server and I would rather give it something more memorable.
Create a new file by using the following command in your PuTTY session.
sudo nano /etc/netplan/01-netcfg.yamlAnd once in the file, paste the following information in to the file via your PuTTY session. The spacing is very important. For every line you can see indenting, you must indent by 2 spaces. Note: For this code example, I have not centred it as the formatting is important.
# For more information, see netplan(5).
To commit the change, and to check you have the syntax correct, type the following.
Install the GPG keys for the Doozer installation method.
We then need to add in the doozer repo to apt-get. Use the following command to do this:
The instructions then tell you to do this:
However, if you do this, it will give an error (as seen above) about some missing dependencies.
For some reason, there is a universal repo missing from Ubuntu which contains some parts of the tvheadend requirements. Not sure why but we need to add it in before we try and install tvheadend. To do this, cut and paste the following command.
once its done, we can now do the command:
It will tell you that it will take up 124 meg of HDD space, and do you want to continue. Heck yes we do, so hit Y and enter and let it start downloading and installing.
The installer then kicks in.
It asks for a username, I just chose admin
Here it tells you that you can access it later using the localhost address and the port 9981.
Click OK and it will continue with the install.
Once its finished, you'll see the screen above. We now need to configure the XBox One tuner by grabbing the latest drivers for tvheadend and also the firmware for the tuner.
Drivers first. We need to compile and build these, and for some reason again the files needed for this are missing in Ubuntu server. So perform the following:
and it will fail with the following message
Cut and paste the highlighted line in your terminal session and install the missing files. Note: I've not included it here as you may already have some of the dependencies I needed, or you may need more etc so just copy whatever it tells you that you need and install those.
Let it finish, and once installed, go back to the media_build folder (you should still be in it to be fair) and again, type:
This time it will show you a warning, its fine just let it do its thing. It takes about 3 minutes on my machine but just go make a brew and come back and it should be done.
It will now tell you to run "make install", well, almost. Because we actually want to run
We now need to install tvhProxy. Thankfully this was a doddle following Kieran's guide so i'll mainly just cut n paste his instructions, because i'm lazy.
The only gotcha I found was that we needed to install the virtualenv system, so i'll just put that in at the appropriate step. No screen grabs here as its really cut n paste friendly from here on.
Back in the PuTTY terminal run the following commands:
Firstly, we need to install PIP.
We then need to add the virtualenv
Then we need to create another user for tvhProxy
Become the user ‘tvh’
Get the files required and setup the environment
Exit out of the tvh user account and go into the home directory of tvh.
We now need to setup the tvhProxy.py script with details from the TVHeadend server.
Find and edit the following lines:
'tvhURL': os.environ.get('TVH_URL') or 'http://test:test@localhost:9981',
'tvhProxyURL': os.environ.get('TVH_PROXY_URL') or 'http://localhost',
needs to be changed to
needs to be changed to
Press CTRL-X, y (enter), (enter) to exit nano.
Note: as before, these are my settings. If you have setup a different IP address then use that in the settings above.
Create a service that automatically starts tvhProxy when the Ubuntu server boots.
Job done. I'd give it a reboot here to make sure all is well.
Set up Plex Server
Nearly done! We are in the home stretch now.
Log into your Plex Server and go to Settings and Live TV & DVR.
The next section will show you how many channels have been scanned. Click continue.
Done, you now have TV in Plex. Congrats!
It will take a wee while for the EPG to populate in Plex so let it finish but once its done you should have a fully functional DVR solution in Plex.
If you want to, you can add additional tuners to the setup, just do the same steps in TVHeadEnd to add them in and Plex should be able to pick them up.
And that ends the guide, I hope someone finds it useful. If it helps one person get this installed and working properly then i'll be a happy bunny.
Did you get it working, leave me a comment below and let me know.