I’m installing a new DVR system for my in-laws.
It consists of a DS218+, an hdhomerun dvb tuner, a tablet and several Chromecasts.
It all works perfectly.
However, I’ve only manually downloaded a copy of the guide data from silicon dust and I need to automate it.
I was hoping I could just shove a wget line into the cron file but wget fails with a 400 error. I can, of course, just right click save from Chrome.
Also, it appears you have to grab the key for the XML data every day, off of discover. JSON or the API on the hdhomerun.
So, I have those two problems to fix but I assume this is actually well trodden ground.
Any ideas?
UPDATE1:
I have Plex Premium, DVR is working perfectly.
My location (UK) is unsupported, so I must provide my own XMLTV.XML file.
This manual process works perfectly but I have to manually update the XMLTV.XML file.
I know it’s not supposed to be automatic, are there existing solutions to this problem?
I do a custom xmltv.xml on my end and automated the process with a combination of a shell script and a python script. In my shell script I call zap2xml.pl to download two different xml files and combine them into one and the from there push it into plex.
first you have to get your plex token, dvr id and plex url. I got mine my using google chrome developer tools (f12) and manually updating the epg using their internal source and teased out the details from the console.
I don’t recall where I found this py script, but it works to update the epg
Interesting, I wonder if this zap2xml script can download the xmltv file off of the hdhomerun?
Combining is interesting, as a 2nd act I was going to look into updating the xmltv file using the DVB-T’s OTA EPG data, get the latest changes for the next 7 days.
And that direct injection script looks great, at the moment Plex periodically imports the xmltv file in the Plex user’s home folder, I was going to just update that file. I’d need to figure out how to disable that periodic file scan to prevent unnecessary load on the NAS.
I’ll poke some of these scripts when I’m up there tomorrow, thanks.
Have you tried using curl instead of wget? Reading through the SiliconDust thread you linked, someone over there developed a short script to query the current DeviceAuth (it changes) and download the XMLTV data. Here’s a link to that post:
zap2xml probably won’t do the hdhomerun, but you might be able to pull it down with wget or curl. it can for sure help with the OTA EPG, that is what I use it for on my setup.
Try this. It’s a modified version of the one I linked above (I did not write the original). It’s been changed to accept two arguments: The IP address of the HDHomeRun (mandatory) and the path/filename to save to (optional, default goes to your home directory) and to suppress progress output from curl:
#!/bin/bash
ip_address=$1
guide_path=$2
if [ -z "$guide_path" ]; then
guide_path=~/xmltv.xml
echo 'No file path provided; using default:' $guide_path
fi
if [ -n "$ip_address" ]; then
echo 'Getting Current Key from HDHomeRun at:' $ip_address
KEY=$(curl -s http://$ip_address/discover.json | jq -r .DeviceAuth)
echo 'Current Key is' $KEY #optional
echo 'Downloading TV Guide Data...'
curl -s --compressed api.hdhomerun.com/api/xmltv?DeviceAuth=$KEY > $guide_path
echo 'Done!'
else
echo 'Usage:' $0 'hdhomerun_ip_address [file_path]'
fi
Thanks, I’ve mostly got that working.
Your bit works, I tried adding in some code from this thread that triggers an update.
Doesn’t work though, so I’ll just run it daily and let Plex do it’s daily import that it already does.
#!/bin/bash
ip_address=a.b.c.d
plex_path=/volume1/homes/plex
guide_path=$plex_path/xmltv.xml
curl_output_path=$plex_path
plex_token=xyz
DVRID=2
plexURL=http://a.b.c.d:32400/web/index.html#
if [ -z "$guide_path" ]; then
guide_path=~/xmltv.xml
echo 'No file path provided; using default:' $guide_path
fi
if [ -n "$ip_address" ]; then
echo 'Getting Current Key from HDHomeRun at:' $ip_address
KEY=$(curl -s http://$ip_address/discover.json | jq -r .DeviceAuth)
echo 'Current Key is' $KEY #optional
echo 'Downloading TV Guide Data...'
curl -s --compressed api.hdhomerun.com/api/xmltv?DeviceAuth=$KEY > $guide_path
echo 'Done!'
refreshEPG=$plexURL/livetv/dvrs/$DVRID/reloadGuide?X-Plex-Token=$plex_token
echo 'Trigger EPG Update using:'
echo $refreshEPG
curl -s $refreshEPG > $curl_output_path/EPGUpdateOutput.html
echo 'Done!'
else
echo 'Usage:' $0 'hdhomerun_ip_address [file_path]'
fi