How to assign EPG to IPTV streams

tommycahir

Registered
check out suls script as it has automated the majority of my below guides once your provider has an epg url available to use.
https://www.suls.co.uk/enigma2-iptv-bouquets-with-epg/


So I have put together a whole bunch of guides recently on how to assign epg to IPTV streams, update files etc, so thought it might be worthwhile revisiting the topic and summarising it with reference to the latest guides etc

# I do not take responsibility for any lost data or damage to your system or device, This is done at your own risk! #

Points of Note
  • This solution assume you will extract the epg data on your own device or will have access to an online epg data source.
  • This solution has been tested with epgimport only and is not tested in anyway with crossepg.
  • Thanks to the guys over on Rytec support forum on openpli site who answered some queries on epgimport processing and handling. They were the key to this being possible.
Prerequisites:
  • IPTV channels: These should be imported into your Enigma2 box and in a single bouquet
  • epgimport plugin: this is the main engine that does heavy lifting once you have configuration completed, available to download from plugins feed.
  • FTP client: a good commonly used one is filezilla but there are loads out there that will do the job.
    - Filezilla basic user guide
    - Youtube guide on using Filezilla
  • XML editor: I personally use PsPad but others recommend Notepad++
  • Enigma2 Box IP Address: To find your IP Address go to Menu-> Setup-> Network-> Device Setup-> Lan Setup (WLan option if that is used)-> Adapter settings
    - Note that if you have DHCP set to Yes then your IP Address may change periodically, if you want a static IP address then you need to change the settings here.
  • Enigma2 Box userID and password: This varies from box to box and image to image so google is your friend here.
  • E-Channelizer: You will need some form of editor to update the Stream reference and E-Channelizer is very simple and intuitive to use, it can be downloaded from http://echannelizer.com/. This can also be used to load your IPTV to the Enigma2 box.
Assigning UK epg to your IPTV streams
This is a very easy process but at the moment very manual and will need to be done via E-Channelizer. If you are going to
  • Open E-Channelizer and read the data from the STB,
  • Open the IPTV bouquet and all channels should appear in the middle column
  • Right-click on the stream, and select Edit. Alternatively, double-click it to edit.
  • In the Edit Stream dialog, select Service as EPG and picon source (if using picon).
  • Then select the DVB service from the available services (grouped by satellites).
  • Click OK to save changes and close.
Alternatively, you can drag the DVB service from the Left hand side menu and drop it into the stream while pressing CTRL.
  • - The selected service's reference will be assigned to the stream, but starting with 4097 instead of 1.
  • - This method is NOT supported by all images, so make sure your image is compatible.

High Level Overview to Assigning non UK epg

  • Access to the epg data
    if you don't have a suitable epg data source available on a server then you will need to extract the data on your box (US epg only possible this way), The following guide shows How to automate extraction of US EPG data on your Enigma2 Device
    If you have a server epg available you need to include this in the sources.xml file

  • Update the stream references to be unique
    You need to update all the stream references to be unique, I have created a python file which will do this automatically for you, follow the instructions in How to automatically update your IPTV bouquet with a unique stream reference
    If you are assigning UK epg then you need to do that after you have run the above python script otherwise you will lose all your assignments and they will need to be redone.

  • Create a template custom.channels.xml
    This assumes you have already run the streamrefupdate.py file as per above guide, You will need to run another python script which will create a new file called custom.channels.xml in your /etc/epgimport/ folder, the guide on running the script is @ How to automatically create your custom.channels.xml from IPTV bouquet
  • map channel ID from epg data source to custom.channels.xml
    Download and open the custom.channels.xml file as created earlier and replace the placeholder text with the channel ID from the epg data source on the line matching the channel you want the epg data assigned to. some examples in the below screenshots.

  • Create custom.sources.xml
    This file ties all the others together and is the main reference file for the epgimport plugin, all files mentioned above need to be correctly referenced in this file otherwise the data will not be imported and the epg assigned to the IPTV stream. Note that file names are very case sensitive.
    The below is the basic complete custom.sources.xml file copy it and save into a file called custom.sources.xml
    Code:
    <sources> 
      <source type="gen_xmltv" channels="/etc/epgimport/custom.channels.xml">
       <description>US TV Guide EPG</description>   
        <url>/etc/epgimport/NAME OF EPG DATA FILE</url> 
      </source>
    </sources>
- The source file should point to the file with the channel ID mapping created in previous step - The description can be anything you want - The url can be either the local path as per above or a web URL to the epg data source​
  • Transfer the file to your device
    Open an FTP connection to your enigma 2 box
    Transfer the files you have created above to the box, they must go in /etc/epgimport

  • Configuring EPGImport Plugin
    Open EPGImport on your box and now you should see a new source named as you have in the custom.sources.xml, Select the entry and hit the green button to save.

    I would recommend that you clear the epg before importing it as this will ensure you get the freshest copy of the data and that if there was any incorrect assignments in the past that they are wiped immediately.

    Now you need to run a manual import by hitting the yellow button, this should show a large number of events being imported for each selected option and will take a couple of minutes.
    This import should be scheduled for daily update if source files are updated daily.
    If the epg doesn’t immediately appear restart your device and rerun the epgimport again as it seems there is some delay in the assigning of epg at times using epgimport.
If you make a mess of your epg while doing this you can easily clear it by setting "Clearing Current EPG before Import" to Yes then running a manual scan with the IPTV source deselected to return to normal service.

Change Log
10/February/17 - updated images and formatting/links
29/November - Initial version created on original forum
 
Last edited:

tommycahir

Registered
How to automate extraction of US EPG data on your Enigma2 Device

The below guide shows how to automate the extraction of the zap2it EPG data on your own Enigma2 box. It's assumed you have some experience using linux command line when following the below steps.

Notes of Caution:
  • The more channels you are extracting the longer this will take especially on the 1st run (10-15 channels takes ~ 1 minute) and the older and slower your box/CPU will also have an impact on the speed of the script running. The 2nd and subsequent runs will be quicker as they will use the cache folder 1st before fetching new data.
  • As this file can be quite large (I've seen <250MB size files) so should really be approached with caution and the output should be compressed as per my shell script below using gzip and you should remove the unused files,
    if you are still caught for space after compressing the output you can also remove the cache directory (update shell script to do it) but this will slow down the fetching of data from zap2it.
  • To prevent long running scripts and excessive usage of the storage space it is recommended to set-up some favourites on the zap2it site and only extract the channels you need epg data for.
# I do not take responsibility for any lost data or damage to your system or device, This is done at your own risk! #

General Prerequisites:
  • Enigma2 Box IP Address: To find your IP Address go to Menu-> Setup-> Network-> Device Setup-> Lan Setup (WLan option if that is used)-> Adapter settings
    - Note that if you have DHCP set to Yes then your IP Address may change periodically, if you want a static IP address then you need to change the settings here.
  • Enigma2 Box userID and password: This varies from box to box and image to image so google is your friend here.
  • FTP client: a good commonly used one is filezilla but there are loads out there that will do the job.
    - Filezilla basic user guide
    - Youtube guide on using Filezilla
  • File editor: I personally use PsPad but others recommend Notepad++
  • SSH client: You will need to connect to the device to test your script and change permissions, I personally use Putty available from http://www.putty.org/
  • Zap2it account: Register your free zap2it.com TV Listings account,
    - Input zip/postal code (10111 directtv sat seems to have the most channels)
    - Click Set Preferences:
    - Manage Favorite Channels
    ---> Select your favorite channels from the "Available Channels" and put them in the "My Favorite Channels" list
    - Additional Settings
    ---> Checkmark [] "Show six hour grid"
    ---> Checkmark [] "Show only my favourite channels in the grid"
    - Click "Save"
Installing Dependencies and configuring the python script
  • Connect to your enigma2 box using SSH
  • Run the following command
    opkg install python-mechanize
  • Download the zap2xml.py and .zap2xmlrc files from the following github repository.
    - https://github.com/edit4ever/script.module.zap2xml
  • Open the .zap2xmlrc in your xml editor and input your zap2it email and password in the 1st 2 lines inplace of the placeholder lines.
  • Connect to your enigma2 box using FTP and transfer both of these files to /etc/epgimport/
Setting up the xmltv.sh script
  • Now connect to your Enigma2 device and FTP these 2 files (GREPpattern.txt and xmltv.sh) to /etc/epgimport/
  • You now need to make the script file executable so SSH on to your enigma2 device
    Change directory to where you placed these files (cd /etc/epgimport/) and execute the below command
    chmod 755 xmltv.sh
  • You can test if the scripts works now by running
    ./xmltv.sh
  • If this works correctly you should now see some new files and folders in the same directory
    - cache
    - xmltv.xml
    - outputxml.xml
  • if it doesn't work correctly try running each of the lines from the .sh script independently to see what errors are produced.
    - Remember you need to also have zap2xml.py and .zap2xmlrc in the same directory
Setting up cron to run the job on a scheduled basis
Now that you have the script running correctly you need to set it up so that it is executed on a regular period so that you have the most up to date epg data available on linux boxes this is done via the cron manager, you can see existing cron jobs by running crontab -l on the command line.
The important thing to learn about cron is that it executes the job under whatever profile you set it up under. You can read more on cron @ https://help.ubuntu.com/community/CronHowto and more on the VI editor used to update cron @ http://www.astrohandbook.com/ch20/vi_guide.html
  • On the command line run the below command to open the crontab
    crontab -e
  • Once this opens press i to switch to INSERT mode (seen at bottom of the screen)
  • Add the following command to the crontab, this can be done by hitting cntrl +v or retyping.
    - This will run the scripts to extract and clean the epg data @ 3:30am every day and the output will be stored in the same location as your script from earlier (/etc/epgimport/).
    30 03 * * * cd /etc/epgimport/ && ./xmltv.sh
  • Now hit ESC followed by :wq and this will exit the crontab editor and save the entry. (q=quit w=write)
  • To check if the new entry to the cron was successful then run the below and you should see the same detail as you entered
    crontab -l
  • If the following day you want to check if cron script has run SSH into your box and run
    grep "xmltv.sh" /var/log/messages
  • The results, if any, will display and looking at the output, you will see the date and time the cron job has run. This is followed by the server name, cron ID, the username, and the command that ran. At the end of the command, you will see the name of the script.
Finally
Remember to update the URL tag in your custom sources.xml file to point to this new epg data source.

Change Log
31/October - Updated shell script to handle non UTF8 characters
18/October - updated xmltv.sh to fix gzip error
18/October - fixed typo on replacing server with enigma2 device multiple times (hazards of copy paste)
17/October - fixed typo on xmltv.xml section
17/October - Initial version created
 
Last edited:

tommycahir

Registered
How to automatically update your IPTV bouquet with a unique stream reference

I created a short python script that will update the stream reference to be unique automatically, it is assumed in the guide below you have some linux command line knowledge to run it. It will update the 4th digit in the stream reference to be a unique value and create a backup of your original bouquet file with a .bak extension.

# I do not take responsibility for any lost data or damage to your system or device, This is done at your own risk! #

Note If you use this script after you have assigned an epg based upon access to current satellites (eg using echanneliser) then you will end up overwriting/modifying the bouquet and breaking the already assigned epg data

Prerequisites:
  • Enigma2 Box IP Address: To find your IP Address go to Menu-> Setup-> Network-> Device Setup-> Lan Setup (WLan option if that is used)-> Adapter settings
    - Note that if you have DHCP set to Yes then your IP Address may change periodically, if you want a static IP address then you need to change the settings here.
  • Enigma2 Box userID and password: This varies from box to box and image to image so google is your friend here.
  • IPTV channels: These should be imported into your Enigma2 box and be in a single bouquet
  • FTP client: a good commonly used one is filezilla but there are loads out there that will do the job.
    - Filezilla basic user guide
    - Youtube guide on using Filezilla
  • SSH client: You will need to connect to the server to test your script and change permissions, I personally use Putty available from http://www.putty.org/
Using the Script
  • Connect to your Enigma2 device and FTP the below file streamrefupdate.py to a suitable location eg /home/root/
    streamrefupdate.zip
  • Open an SSH session to you enigma2 device
  • Change directory to the folder where you placed the file eg type
    cd /home/root/
  • now run the python script against your IPTV bouquet file
    - Remember to change the placeholder "Your-IPTV-Bouquet-name-here.tv" to your IPTV bouquet name
    python streamrefupdate.py /etc/enigma2/Your-IPTV-Bouquet-name-here.tv
  • This will update the bouquet and create a backup of the original with .bak extension which can be restored if there is an issue.
Change Log
26/October - added note to header
18/October - Initial version created
 
Last edited by a moderator:

tommycahir

Registered
How to automatically create your custom.channels.xml from IPTV bouquet
The below python script will create the custom.channels.xml file that is used to create a mapping between your epg data and the unique IPTV stream reference . It's assumed in the guide below you have some linux command line knowledge to run it.

# I do not take responsibility for any lost data or damage to your system or device, This is done at your own risk! #

Prerequisites:
  • Enigma2 Box IP Address: To find your IP Address go to Menu-> Setup-> Network-> Device Setup-> Lan Setup (WLan option if that is used)-> Adapter settings
    - Note that if you have DHCP set to Yes then your IP Address may change periodically, if you want a static IP address then you need to change the settings here.
  • Enigma2 Box userID and password: This varies from box to box and image to image so google is your friend here.
  • IPTV channels: These should be imported into your Enigma2 box and be in a single bouquet
  • FTP client: a good commonly used one is filezilla but there are loads out there that will do the job.
    - Filezilla basic user guide
    - Youtube guide on using Filezilla
  • SSH client: You will need to connect to the server to test your script and change permissions, I personally use Putty available from http://www.putty.org/
Using the Script
  • Connect to your Enigma2 device and FTP the below file channelscreator.py to a suitable location eg /etc/epgimport/
    channelscreator.zip
  • Open an SSH session to you enigma2 device
  • Change directory to the folder where you placed the file egtype
    cd /etc/epgimport/
  • now run the python script against your IPTV bouquet file
    - Remember to change the placeholder "Your-IPTV-Bouquet-name-here.tv" to your IPTV bouquet nam
    python channelscreator.py /etc/enigma2/Your-IPTV-Bouquet-name-here.tv
  • This will create as new file called custom.channels.xml which you need to update with the channel ID from you EPG data source
  • Updating custom.channels.xml is as simple as replacing the word placeholder with the channel ID from you epg source xmltv file
  • You should delete any entries that are able to get epg data from an assigned service ref using tools such as echanneliser
Change Log
26/October - Script updated
26/October - Initial version created
 

tommycahir

Registered
Troubleshooting Tips

If you get zero events assigned to the epg
1) Double check that the files exist and you have named them exactly(remember that the names are case sensitive) as per the sources.xml file
2) Double check that the update has happened open the bouquet in echanneliser or a txt editor and double check that the stream reference has been updated to have the 4th digit of the reference being updated from 1 upwards at each line. Examples from m3u and enigma bouquet inputs below:


3) Cross check that the stream reference numbers above match the ones in custom.channels.xml
a.If these do not match you need to update the custom.channels.xml to correct the information


4) Double check that you have selected the correct entries in EPGImport and clicked the green button on your remote to save them.

If the epg doesn’t immediately appear, it seems there is some delay in the assigning of channels at times (no idea why)
1)restart your device.
2)rerun the epgimport again.
 

timknowlden

Registered
Really appreciate this guide and I am going to give this a go at the weekend.. (currently using wooshbuild so will have to move from crossepg to epgimport) I have two boxes to do. A quick question though you say this should all be in one bouquet.. once all complete have you tried to then drag some channels into a separate bouquet. Ie..an iptv sports bouquet can be separate to movies.

Sent from my SM-G935F using Tapatalk
 

tommycahir

Registered
Really appreciate this guide and I am going to give this a go at the weekend.. (currently using wooshbuild so will have to move from crossepg to epgimport) I have two boxes to do. A quick question though you say this should all be in one bouquet.. once all complete have you tried to then drag some channels into a separate bouquet. Ie..an iptv sports bouquet can be separate to movies.

Sent from my SM-G935F using Tapatalk
Yes you can copy and paste the stream to another bouquet after assignment of the EPG and the EPG will remain intact and assigned. if your not going to be updating the bouquet with a new m3u and stream reference frequently then you could cut or move the stream to another bouquet..
 

timknowlden

Registered
Ah cool, was not aware this would keep streams up to date with newer m3u links.

Sent from my SM-G935F using Tapatalk
 

tommycahir

Registered
Ah cool, was not aware this would keep streams up to date with newer m3u links.

Sent from my SM-G935F using Tapatalk
This alone will not keep streams up to date you would need to runa cronjob to redownload the m3u daily(not hard ill add another guide later in the week to show how to do that), then one to run the python script to set streamreference to be unique and assume that the m3u order hasn't changed or that new streams have not been added otherwise you will end up redoing the channels.xml daily..

What this does is update the epg data daily for any streams assigned a unique reference and mapped in the channels.xml.
 

timknowlden

Registered
Well I failed miserably so have gone back to my previous backup! I set up a zap2it account and followed instructions just chose nbcsn and cbs sport as favourites and assigned an ID to those. Used your scripts and when importing epg it had 0 events..

Will start again from fresh another day!

Sent from my SM-G935F using Tapatalk
 

gb160

Registered
Hi first off many thanks for this, well laid out and simple to follow.

for some reason though I'm not getting any epg info for my IPTV streams, and I can't work out why :(

Ive used the script to give every channel a unique reference in my IPtV bouquet, then used the script to create the custom.channels.xml

Now because the channels I'm trying to find are already in the rytek UK source that's provided, I highlight that source in epgimporter plugin, then select manual import...it all seems to be working, takes a few minutes and says importing x amount, a very large number.
However after it's finished there's still no epg, rebooted the box, imported again, but nothing :(

I've tried this three or four times now and still nothing, I'm probably doing something wrong but can't see an error after retracing the steps.

Not sure if related, but I also have crossepg on my box, which deals with the epg for the current satellite channels, not sure if this could be causing a conflict ?
I'm stumped tbh, any assistance is greatly appreciated.
 

cybertoad11

Registered
Hi first off many thanks for this, well laid out and simple to follow.

for some reason though I'm not getting any epg info for my IPTV streams, and I can't work out why :(

Ive used the script to give every channel a unique reference in my IPtV bouquet, then used the script to create the custom.channels.xml

Now because the channels I'm trying to find are already in the rytek UK source that's provided, I highlight that source in epgimporter plugin, then select manual import...it all seems to be working, takes a few minutes and says importing x amount, a very large number.
However after it's finished there's still no epg, rebooted the box, imported again, but nothing :(

I've tried this three or four times now and still nothing, I'm probably doing something wrong but can't see an error after retracing the steps.

Not sure if related, but I also have crossepg on my box, which deals with the epg for the current satellite channels, not sure if this could be causing a conflict ?
I'm stumped tbh, any assistance is greatly appreciated.
I'll be giving this a go on Thursday, I too use crossepg so i'll see if it works for me or not and report back.
 

cybertoad11

Registered
Hi I tried for a few hours today for a single channel ( BT Sport 1) as a test, but couldn't get it working. I also removed crossepg as I thought it might be conflicting with epg-import. I added my new EPG source (named EPG) into epg-import, ran a scan but 0 events were returned.
See my attached configuration below, hopefully someone can spot something wrong.
Thanks

My E-channelizer

echannelizer.png


My EPG Source
http://iptv-epg.com/ba4-jvva6m.xml.gz
BT Sport Channel ID in EPG Source is <channel id="BTSport1.uk">

my custom.channels.xml file
<channels>
<channel id="BTSport1.uk">1:0:19:1:968:2:11A0000:0:0:0:http%3a//example.m3u8</channel> <!-- BT Sports 1 HD -->
</channels>

My custom.sources.xml file
<sources>
<source type="gen_xmltv" channels="/etc/epgimport/custom.channels.xml">
<description>EPG</description>
<url>http://iptv-epg.com/ba4-jvva6m.xml.gz</url>
</source>
</sources>
 

scoob197

TK Veteran
tommycahir is your man for this method
I just use Echannelizer to assign sly epg for the uk channels
but i also run xc plugin which shows a short epg for us/ca channels and is easier to navigate for VOD
 
Last edited:

cybertoad11

Registered
tommycahir is your man for this method
I just use Echannelizer to assign sly epg for the uk channels
but i also run xc plugin which shows a short epg for us/ca channels and is easier to navigate for VOD
I tried that also bit didn't work. When you select 28.2 satellite in Echannelizer, which BT Sport do you select as there are multiple or doesn't it matter?

Sent from my ONEPLUS A3003 using Tapatalk
 

scoob197

TK Veteran
In theory it shouldn't really matter, 1 will be SD, 1 will be HD, the others are probably pub channels etc. I always go for the second one (no logic but it seems to work for me)
once that's done just write back to your box
reboot

Something else I make sure of is that the channel name is the same ie sky1 not sky one or uk:skyone, caps dont seem to matter. This may not effect EPG I cant remember but it definitely affected my picons lol.
 
Last edited:

gb160

Registered
Hi I tried for a few hours today for a single channel ( BT Sport 1) as a test, but couldn't get it working. I also removed crossepg as I thought it might be conflicting with epg-import. I added my new EPG source (named EPG) into epg-import, ran a scan but 0 events were returned.
See my attached configuration below, hopefully someone can spot something wrong.
Thanks

My E-channelizer

View attachment 22443


My EPG Source
http://iptv-epg.com/ba4-jvva6m.xml.gz
BT Sport Channel ID in EPG Source is <channel id="BTSport1.uk">

my custom.channels.xml file
<channels>
<channel id="BTSport1.uk">1:0:19:1:968:2:11A0000:0:0:0:http%3a//example.m3u8</channel> <!-- BT Sports 1 HD -->
</channels>

My custom.sources.xml file
<sources>
<source type="gen_xmltv" channels="/etc/epgimport/custom.channels.xml">
<description>EPG</description>
<url>http://iptv-epg.com/ba4-jvva6m.xml.gz</url>
</source>
</sources>
I got it working in the end, my problem was with the custom source I was using...in the end I used one from the included rytec list and it worked as expected.
I'm still not sure what the problem was with the source, I double checked it countless times, had the correct channel ID , but for some reason it wouldn't work.
When I changed the source I was using....BINGO!

I recommend trying this if you can't see what the problem is.
Also worth noting I couldn't get any of the .dat sources to work either, only the xmltv ones would work.
 

cybertoad11

Registered
tommycahir is your man for this method
I just use Echannelizer to assign sly epg for the uk channels
but i also run xc plugin which shows a short epg for us/ca channels and is easier to navigate for VOD
All sorted now, i did as you suggested. Appreciate your help.

Sent from my ONEPLUS A3003 using Tapatalk
 
Top