XMLTV guide data

Want to write your own code to work with a HDHomeRun or work with the HDHomeRun DVR? We are happy to help with concepts, APIs, best practices.
Post Reply
Ekstir
Posts: 2
Joined: Tue Feb 11, 2020 11:49 pm

Re: XMLTV guide data

Post by Ekstir »

nickk wrote: Thu Nov 28, 2019 10:13 am We are testing a new service providing 14-day XMLTV format guide data to customers who are paying for the HDHomeRun guide.

API: https://api.hdhomerun.com/api/xmltv?DeviceAuth=xxx

DeviceAuth comes from the HDHomeRun unit - for coding you get it from discover but for testing the easiest is to get it from
http://<ip of hdhomerun>/discover.json
If you have more than one HDHomeRun unit pull the DeviceAuth from each and concatenate them together.

The API will return the set of all channels across HDHomeRun units. For example if you have a HDHomeRun unit for cable and a HDHomeRun unit for antenna the API will return 14-day guide for all cable and antenna channels combined.

The API works in all supported countries.

Nick
Is this service also available in EUR?

nickk
Silicondust
Posts: 20163
Joined: Tue Jan 13, 2004 9:39 am
x 376

Re: XMLTV guide data

Post by nickk »

Ekstir wrote: Wed Feb 12, 2020 2:02 am Is this service also available in EUR?
We don't have all EU countries but it is available for the EU countries our app has guide data for.

Nick

Ekstir
Posts: 2
Joined: Tue Feb 11, 2020 11:49 pm

Re: XMLTV guide data

Post by Ekstir »

The Netherlands?

Online
signcarver
Expert
Posts: 11083
Joined: Wed Jan 24, 2007 1:04 am
Device ID: 10A05954 10802091 131B34B7 13231F92 1070A18E 1073ED6F 15300C36
x 39

Re: XMLTV guide data

Post by signcarver »

Launch the hdhomerun app... the guide data is the same, just delivered differently, so if you get guide data there, have a modern tuner, and you subscribe to the dvr service, the xml version of the guide is available.

jasonl
Silicondust
Posts: 16810
Joined: Sun Oct 28, 2007 9:23 pm
x 60

Re: XMLTV guide data

Post by jasonl »

Guide data is available for some Dutch channels but not many: NPO1, 2, and 3 , RTL4, NET5, RTL5, SBS 6, RTL7, RTL8, Eurosport, Eurosport 2, National Geographic, Discovery, and Veronica/Disney XD.

chuckles67
Posts: 98
Joined: Tue Dec 10, 2013 8:38 am
x 1

Re: XMLTV guide data

Post by chuckles67 »

gr33k wrote: Sat Feb 08, 2020 12:08 pm Ok...so I got it running, but I realized the key is not static...it seems to change after a while (I don't know how long but at least every day if not sooner you will have a newer key). So I had to modify the script to be able to obtain the key first, and then pass it as a variable to the script each time to successfully download the TVGuide data :?

Well - that appears to be easy enough. You need to have an app called jq (https://stedolan.github.io/jq/) installed though. You should be able to apt install jq or yum install jq for an easy install. With that...here we have:

Code: Select all

#!/bin/bash
echo 'Getting Current Key from HDHomeRun...'
KEY=$(curl http://192.168.10.143/discover.json | jq -r .DeviceAuth)
echo 'Current Key is' $KEY #optional
echo 'Downloading TV Guide Data...'
curl --compressed api.hdhomerun.com/api/xmltv?DeviceAuth=$KEY > xmltvlist.xml
echo 'Done!'
Now of course you have to replace 192.168.10.143 with the IP of YOUR HDHomeRun...but that's about it :mrgreen:
Thank you! This was really helpful. I tried this bash script on Mac OS X and, after giving execute permissions using chmod +x <name>, the bash script works fine from terminal :)

On Mac OS X when I tried to run this script using crontab the generated .xml file was empty. The fix for me was to add a PATH= statement to the script like this. On my system jq is in /usr/local/bin, so perhaps that is why an explicit path is needed. I still need to test this through a KEY change.

Code: Select all

#!/bin/bash
PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin  # Fix for crontab.
echo 'Getting Current Key from HDHomeRun...'
KEY=$(curl http://192.168.50.19/discover.json | jq -r .DeviceAuth)
echo 'Current Key is' $KEY #optional
echo 'Downloading TV Guide Data...'
curl --compressed api.hdhomerun.com/api/xmltv?DeviceAuth=$KEY > ~/Downloads/xmltvlist.xml
echo 'Done!'

chuckles67
Posts: 98
Joined: Tue Dec 10, 2013 8:38 am
x 1

Re: XMLTV guide data

Post by chuckles67 »

Is it possible to add one extra line for the episode-num system comforming to "xmltv_ns" ?

Example given this:

Code: Select all

<episode-num system="onscreen">S24E76</episode-num>
include one extra line:

Code: Select all

<episode-num system="onscreen">S24E76</episode-num>
<episode-num system="xmltv_ns">23.75.0</episode-num>
See reference: https://github.com/XMLTV/xmltv/blob/master/xmltv.dtd

Thanks.

UPDATE: I've written (or rather hacked :)) a python file to convert the .xml file into a version that includes episode-num "xmltv_ns" lines.

I also added a line to help indicate a show is a repeat. If a show does not contain this "new" line:

Code: Select all

<programme>
     ...
     <new />
     ...
</programme>
then add this line:

Code: Select all

<programme>
     ...
     <previously-shown />
 </programme>

stevedparry
Posts: 1
Joined: Mon May 25, 2020 1:43 pm

Re: XMLTV guide data

Post by stevedparry »

I've just subscribed but im still getting "not subscribed"

NedS
Silicondust
Posts: 3151
Joined: Mon Dec 10, 2018 12:38 pm
x 173

Re: XMLTV guide data

Post by NedS »

stevedparry wrote: Mon May 25, 2020 1:45 pm I've just subscribed but im still getting "not subscribed"
It sounds like you're the same Steve that filed a support ticket, where we sent you the activation link, but if not, please open a support ticket and I can look into it: https://www.silicondust.com/support/trouble-ticket/

Brak
Posts: 2
Joined: Fri Jul 31, 2020 12:29 pm
x 1

Re: XMLTV guide data

Post by Brak »

gr33k wrote: Sat Feb 08, 2020 12:08 pm Ok...so I got it running, but I realized the key is not static...it seems to change after a while (I don't know how long but at least every day if not sooner you will have a newer key). So I had to modify the script to be able to obtain the key first, and then pass it as a variable to the script each time to successfully download the TVGuide data :?

Well - that appears to be easy enough. You need to have an app called jq (https://stedolan.github.io/jq/) installed though. You should be able to apt install jq or yum install jq for an easy install. With that...here we have:

Code: Select all

#!/bin/bash
echo 'Getting Current Key from HDHomeRun...'
KEY=$(curl http://192.168.10.143/discover.json | jq -r .DeviceAuth)
echo 'Current Key is' $KEY #optional
echo 'Downloading TV Guide Data...'
curl --compressed api.hdhomerun.com/api/xmltv?DeviceAuth=$KEY > xmltvlist.xml
echo 'Done!'
Now of course you have to replace 192.168.10.143 with the IP of YOUR HDHomeRun...but that's about it :mrgreen:
I didn't want to install jq so I just adapted the script to use awk instead. It's marginally more brittle, since it just string-parses out the needed key, but that's all we really need. Should work out of the box on any system with awk and curl, which is most, heh.

Code: Select all

#!/bin/bash
echo 'Getting Current Key from HDHomeRun...'
KEY=$(curl http://192.168.1.126/discover.json | sed -E 's/.*"DeviceAuth"\s*:\s*"([^"]+)".*/\1/g')
echo 'Current Key is' $KEY #optional
echo 'Downloading TV Guide Data...'
curl --compressed api.hdhomerun.com/api/xmltv?DeviceAuth=$KEY > xmltvlist.xml
echo 'Done!'

Brak
Posts: 2
Joined: Fri Jul 31, 2020 12:29 pm
x 1

Re: XMLTV guide data

Post by Brak »

nickk wrote: Thu Nov 28, 2019 10:13 am We are testing a new service providing 14-day XMLTV format guide data to customers who are paying for the HDHomeRun guide.

API: https://api.hdhomerun.com/api/xmltv?DeviceAuth=xxx

DeviceAuth comes from the HDHomeRun unit - for coding you get it from discover but for testing the easiest is to get it from
http://<ip of hdhomerun>/discover.json
If you have more than one HDHomeRun unit pull the DeviceAuth from each and concatenate them together.

The API will return the set of all channels across HDHomeRun units. For example if you have a HDHomeRun unit for cable and a HDHomeRun unit for antenna the API will return 14-day guide for all cable and antenna channels combined.

The API works in all supported countries.

Nick
Hey Nick,

So I'm curious about something, which maybe you can answer. This service is run off of your servers, which means as guide data is fetched by whatever service people need to write, they pulling 20+ MB from you. It's fast, don't get me wrong, but have you guys (SiliconDust) considered adding a "job", occurring on some frequency, to run from the actual HDHomeRun device, and caching this data locally? This way, we wouldn't need to write scripts to fetch the DeviceAuth or a special cron to pull it, or a place to store the resulting data. We could instead just refer to a local IP/URL, just like the /recorded_files.json or /lineup.xml files/URLs on our local devices, rather than hitting your server.

As an additional question, I'm attempting to get this data to mesh well with NextPVR. I'm able to pull both the channel lineup and this API's guide data, via my earlier posted updated script, but for some reason, NextPVR doesn't seem to be able to mate the two together, I assume due to some mismatch in channel display-name or a misaligned unique identifier. Is there some way to tell the API that I'd like a certain "display-name" as the channel identifier or something that I'm missing? I'm relatively new to the TV/PVR/XMLTV/Guide stuff, so any advice you can offer would be appreciated. Overall I've been pretty pleased with the capabilities of the device, but I've gone down this route due to various reasons that can be reserved for a future conversation.

nickk
Silicondust
Posts: 20163
Joined: Tue Jan 13, 2004 9:39 am
x 376

Re: XMLTV guide data

Post by nickk »

Usually a DVR would pull guide data once a day (random time) and use it locally.

If you are pulling data more often please let me know a bit more about the approach.

Nick

emveepee
Posts: 155
Joined: Sun Nov 16, 2014 3:35 pm
x 4

Re: XMLTV guide data

Post by emveepee »

Brak wrote: Fri Jul 31, 2020 3:38 pmAs an additional question, I'm attempting to get this data to mesh well with NextPVR. I'm able to pull both the channel lineup and this API's guide data, via my earlier posted updated script, but for some reason, NextPVR doesn't seem to be able to mate the two together
@Brak I had a look at someone's XMLTV from this API, and discussed it with @sub the developer and currently NextPVR doesn't support multiple display-name markup from this source. He has added support for the next release. You might be able to fake it in the meantime by modifying the second line

<tv source-info-url="https://www.hdhomerun.com/" source-info-name="HDHomeRun" generator-info-name="mc2xml">

You only need to do this manual edit for the Auto Map daily runs will work fine

@nickk after looking at the source XMLTV as a general comment for SiliconDust I think the TMS long name should be included, some cable names can be pretty cryptic.

Martin

disp00
Posts: 5
Joined: Tue Feb 25, 2020 7:34 pm

Re: XMLTV guide data

Post by disp00 »

Brak wrote: Fri Jul 31, 2020 12:36 pm
gr33k wrote: Sat Feb 08, 2020 12:08 pm Ok...so I got it running, but I realized the key is not static...it seems to change after a while (I don't know how long but at least every day if not sooner you will have a newer key). So I had to modify the script to be able to obtain the key first, and then pass it as a variable to the script each time to successfully download the TVGuide data :?

Well - that appears to be easy enough. You need to have an app called jq (https://stedolan.github.io/jq/) installed though. You should be able to apt install jq or yum install jq for an easy install. With that...here we have:

Code: Select all

#!/bin/bash
echo 'Getting Current Key from HDHomeRun...'
KEY=$(curl http://192.168.10.143/discover.json | jq -r .DeviceAuth)
echo 'Current Key is' $KEY #optional
echo 'Downloading TV Guide Data...'
curl --compressed api.hdhomerun.com/api/xmltv?DeviceAuth=$KEY > xmltvlist.xml
echo 'Done!'
Now of course you have to replace 192.168.10.143 with the IP of YOUR HDHomeRun...but that's about it :mrgreen:
I didn't want to install jq so I just adapted the script to use awk instead. It's marginally more brittle, since it just string-parses out the needed key, but that's all we really need. Should work out of the box on any system with awk and curl, which is most, heh.

Code: Select all

#!/bin/bash
echo 'Getting Current Key from HDHomeRun...'
KEY=$(curl http://192.168.1.126/discover.json | sed -E 's/.*"DeviceAuth"\s*:\s*"([^"]+)".*/\1/g')
echo 'Current Key is' $KEY #optional
echo 'Downloading TV Guide Data...'
curl --compressed api.hdhomerun.com/api/xmltv?DeviceAuth=$KEY > xmltvlist.xml
echo 'Done!'
Thanks to OP for exposing the API and thanks to Brak for the quick script. I was using zap2xml to fetch TV listings from Zap2It but this is much nicer.

nickk
Silicondust
Posts: 20163
Joined: Tue Jan 13, 2004 9:39 am
x 376

Re: XMLTV guide data

Post by nickk »

BTW - if you only have one device you can use:
http://hdhomerun.local/discover.json

Post Reply