9 hours ago
(This post was last modified: 9 hours ago by FistRockbone. Edited 1 time in total.)
Ok, here goes. Ever since the issues arose with Schedules Direct I've been mildly (totally) obsessed with finding a working solution to getting a fully populated EPG so that I could continue to use the DVR features and record and series link if I needed to.
The main obstacle I had is that i'm not really any kind of coder and my skillset only goes so far. I tried most of the EPG Grabber scripts and the likes of Threadfin, Dispatcharr and Stream Master and couldn't get anything to do, well, anything. The level of help I got along the way amounted to "Well it's working on my device" as well so I was stuck. I have lifetime passes for Emby and Plex but I wanted to stick with Jellyfin and I was about to give up the ghost until I found this github project from the user "dp247" so full credit for the original code should go to this person.
https://github.com/dp247/Freeview-EPG
It sources EPG data from freely available sources from Sky, Freeview and Freesat and builds an XMLTV file with 48 hours of TV and Radio data every 8 hours. While it worked perfectly, the only problem for me was that it was only 48 hours' worth of data so series linking anything was out.
So I initially forked the project myself and decided to use Google Gemini to help me figure out how to make it better. The first step was to get it to give me 8 days of data instead of 2 which it did. Because the code was rock solid as it was, it worked fine. I pointed my Jellyfin Live TV towards the XMLTV file it generated and finally had a fully populated EPG with program thumbnails and program information. It also meant that Series Linking was back on the table as well.
The one thing I couldn't figure out was why it wouldn't run every 8 hours like the original did so I started wondering if I could host it locally on my Synology NAS. In stepped Google Gemini again and I downloaded the Python code and set it up on my NAS and it ran perfectly so I had far more control over how often I ran it.
The next issue was that a lot of the thumbnails it was returning were actually blank. With a bit of digging, it turned out that the Sky TV API sometimes failed to return a valid image and returned a message instead that said "Image not found, it might be available later". So I started to think of an alternative way of doing it and, again with Gemini's help, came up with a solution where the script now uses TVMaze as it's primary source for images and only falls back to Sky if it doesn't find anything.
It uses Sky, Freeview and Freesat to build the bones of the EPG with regards to the dates, times and schedule and populates it with TVMaze API calls that also prioritises UK shows first. It caches a lot of the requests as well to cut down on multiple API calls and also to improve the execution time. It currently takes around 2 minutes to build an 11mb XMLTV file, although your initial run will probably be longer as it'll need to build the cache.
I've attached the main python script and the channels.json file and here's what you should need to get it up and running.
REQUIREMENTS
Latest version of Python - I have Python 3.8.15 installed
LIBRARIES
You also need the following libraries installed:
Everything else is included as standard Python libraries.
CODE CHANGES
In the main python script, there are 3 places where the pathways are hardcoded so these will need to be changed to however you have this set up. If you edit the script and search for "<LOCATION OF PYTHON SCRIPT>" then you can replace each occurence with the relevant pathway, so something like "/volume1/epgdata/<username>/" or however you want.
This will ensure it can find the "channels.json" file and also have a place to write the cache files and XMLTV file.
With regards to the "channels.json" file, you can also manually edit this to only include the channels and/or radio stations you need if you want to, but this is totally optional as it works either way. Just make sure you remove each channel entry between the "{" and "}" brackets.
SCRIPT EXECUTION
This will also need executing as root, so this is what I use in the Synology Task Scheduler.
/usr/bin/python <LOCATION OF PYTHON SCRIPTS>/main.py >> <LOCATION OF PYTHON SCRIPTS>/cron.log 2>&1
Then you can point your Jellyfin Live TV XML file at the "epg.xml" file that's generated and set the execution intervals and updating intervals as you wish.
The main obstacle I had is that i'm not really any kind of coder and my skillset only goes so far. I tried most of the EPG Grabber scripts and the likes of Threadfin, Dispatcharr and Stream Master and couldn't get anything to do, well, anything. The level of help I got along the way amounted to "Well it's working on my device" as well so I was stuck. I have lifetime passes for Emby and Plex but I wanted to stick with Jellyfin and I was about to give up the ghost until I found this github project from the user "dp247" so full credit for the original code should go to this person.
https://github.com/dp247/Freeview-EPG
It sources EPG data from freely available sources from Sky, Freeview and Freesat and builds an XMLTV file with 48 hours of TV and Radio data every 8 hours. While it worked perfectly, the only problem for me was that it was only 48 hours' worth of data so series linking anything was out.
So I initially forked the project myself and decided to use Google Gemini to help me figure out how to make it better. The first step was to get it to give me 8 days of data instead of 2 which it did. Because the code was rock solid as it was, it worked fine. I pointed my Jellyfin Live TV towards the XMLTV file it generated and finally had a fully populated EPG with program thumbnails and program information. It also meant that Series Linking was back on the table as well.
The one thing I couldn't figure out was why it wouldn't run every 8 hours like the original did so I started wondering if I could host it locally on my Synology NAS. In stepped Google Gemini again and I downloaded the Python code and set it up on my NAS and it ran perfectly so I had far more control over how often I ran it.
The next issue was that a lot of the thumbnails it was returning were actually blank. With a bit of digging, it turned out that the Sky TV API sometimes failed to return a valid image and returned a message instead that said "Image not found, it might be available later". So I started to think of an alternative way of doing it and, again with Gemini's help, came up with a solution where the script now uses TVMaze as it's primary source for images and only falls back to Sky if it doesn't find anything.
It uses Sky, Freeview and Freesat to build the bones of the EPG with regards to the dates, times and schedule and populates it with TVMaze API calls that also prioritises UK shows first. It caches a lot of the requests as well to cut down on multiple API calls and also to improve the execution time. It currently takes around 2 minutes to build an 11mb XMLTV file, although your initial run will probably be longer as it'll need to build the cache.
I've attached the main python script and the channels.json file and here's what you should need to get it up and running.
REQUIREMENTS
Latest version of Python - I have Python 3.8.15 installed
LIBRARIES
You also need the following libraries installed:
- pandas
- pytz
- requests
- lxml
Everything else is included as standard Python libraries.
CODE CHANGES
In the main python script, there are 3 places where the pathways are hardcoded so these will need to be changed to however you have this set up. If you edit the script and search for "<LOCATION OF PYTHON SCRIPT>" then you can replace each occurence with the relevant pathway, so something like "/volume1/epgdata/<username>/" or however you want.
This will ensure it can find the "channels.json" file and also have a place to write the cache files and XMLTV file.
With regards to the "channels.json" file, you can also manually edit this to only include the channels and/or radio stations you need if you want to, but this is totally optional as it works either way. Just make sure you remove each channel entry between the "{" and "}" brackets.
SCRIPT EXECUTION
This will also need executing as root, so this is what I use in the Synology Task Scheduler.
/usr/bin/python <LOCATION OF PYTHON SCRIPTS>/main.py >> <LOCATION OF PYTHON SCRIPTS>/cron.log 2>&1
Then you can point your Jellyfin Live TV XML file at the "epg.xml" file that's generated and set the execution intervals and updating intervals as you wish.
![[Image: Untitled.jpg]](https://i.ibb.co/XfxG87X6/Untitled.jpg)