Tvheadend EPG guide from hdhomerun

  • Hello,

    I was looking to have the EPG guide provided by hdhomerun into tvheadend, including the channel icons. So I ended up creating a python script to do it. As it may be of interest to some of you, I decided to share it on this forum.

    Basically, the script generate a XMLTV compliant file which can then be read by the internal XMLTV grabber. It is the same kind of file generated by WebGrab+Plus.

    The xml file is generated from the Silicon Dust API linked to your hdhomerun device. It means that you need a hdhomerun device to use the script.

    The main steps to make it work are:

    1. Download hdhomerun.py.txt and rename it to hdhomerun.py. Let's say you download it to /storage/.config (or \\<LIBREELEC_IP>\Configfiles if using SMB).
    2. Connect to your libreelec by ssh and run :python /storage/.config/hdhomerun.py. This will generate a hdhomerun.xml file.
      (start the script in a cron to update the guide content on a regular basis)
    3. In KODI, go configure Tvheanend Server 4.2 addon
      1. Set XMLTV source type to FILE
      2. Set XMLTV File location to the location of the downloaded script (eg /storage/.config hdhomerun.xml)
    4. In Tvheadend web interface (eg http://<LIBREELEC_IP>:9981/)
      1. Config / General / Image Cache : mark it enabled (to cache the channel icons locally)
      2. Config / Channel/EPG / EPG Grabber : ensure "Update channel icon" is checked
      3. Config / Channel/EPG / EPG Grabber Modules :
        1. make sure Internal XMLTV is enabled.
        2. (You can also set "Channel numbers" to Only digits to automatically map EPG to the channels according to their numbers. In my case it is not working and I really don't understand why, even after reviewing the source code of xmltv module of tvheadend)
        3. click "Re-run Internal EPG Grabbers" and ensure it completes (journalctl -u service.tvheadend42.service -f might be useful)
      4. Config / Channel/EPG / EPG Grabber Channels : Ensure that your channels are correctly mapped (as auto mapping on the channel number doesn't seem to work)
      5. Config / Channel/EPG / EPG Grabber Modules : click "Re-run Internal EPG Grabbers" one last time (first time is for channel mapping, now this is for EPG content)
    5. In KODI, force refresh of the guide content and channel icons
      1. Settings / PVR & Live TV : Clear data

    That's it, you should now have icons and guide coming from hdhomerun!

  • Hi jefflessard.

    Thanks a lot for that info. I was able to have my EPG loaded with data from my HDHomeRun. I'm not that so verse on cron / linux / etc. Can you guide me on creating the cron for updating/creating that file nightly?

  • Works great!! Thank you very much. I am going to try and recode the xml to conform to DTD in the hopes that the Episode numbers will import. Thanks again

  • Hi all,

    I'm trying to run this script and getting the following errors:

    Code
    LibreELEC:~/.kodi/userdata # python hdhomerun.py
    Traceback (most recent call last):
      File "hdhomerun.py", line 121, in <module>
        main()
      File "hdhomerun.py", line 110, in main
        data = loadGuideFromWeb()
      File "hdhomerun.py", line 15, in loadGuideFromWeb
        discover_url = json.loads(urllib.urlopen("http://my.hdhomerun.com/discover").read())[0]["DiscoverURL"]
    IndexError: list index out of range
    LibreELEC:~/.kodi/userdata #

    Any help would be greatly appreciated.

  • I've refactored the script and popped it into github:

    GitHub - brilthor/hdhomerun-xmltv: Fetch and parse HDHomerun EPG data for XMLTV consumers
    Fetch and parse HDHomerun EPG data for XMLTV consumers - brilthor/hdhomerun-xmltv
    github.com


    gregeeh you're likely seeing the difference between guide data and what the channel sets going out OTA. If you read the code the channels aren't getting swapped around, of course you're welcome to look at the payloads yourself to confirm