RPi how to: Adding EPG from the Internet, e.g for IPTV programmes (incl. Languages tag problem)
Added by Pila RPi almost 7 years ago
I could not find a guide how to do it for the Raspberry Pi. I just finished the job. As I document everything for myself, I am giving you my own doc here, hoping it may help others!
When finished, you will have EPG for all the IPTV (or what ever you want) programs, and will be able to record and schedule them normally via TVH EPG. Any program asking TVH for EPG will be given the EPG you see at TVH. So, until everything is working and showing perfectly in TVH, absolutelly no point in checking EPG in another program which is pulling its EPG from TVH! Written for Raspberry Pi LibreElec 7 TvHeadEnd v4.0.9 and Kodi 16.2. but should work on other versions, too.
This is assuming TVH is installed and Kodi is pulling programms from it. If using TVH for e.g. DVB-T, install them first. Then install other programms, e.g. IPTV. Make sure all is working. Then add the EPG.
There are two completely separate tasks.
1) create EPG data and save it to the guide.xml. If you did that on a separate computer (not the one where TVH is), copy the guide.xml to RPi where TVH is.
2) make RPi TVH use this EPG data.
Task 1: use WebGrab+Plus to create and save EPG data to the guide.xml¶
For collecting EPG data, regardless of the country you are in and the programs you watch, I use the WebGrab+Plus. There is version 1.57 as Addon for LE7. Or one can install WebGrab++ in an another (e.g. Win or Linux) computer and make the guide.xml there. Configure WebGrab++ and run it! I also use the Rex to move all additional data to the description (actors, directors, year...). That way my TVH and Kodi are able to show it all. Names of your programs should be the same in the WebGrab++.config.xml (once at the end of the row, if multiples of same names exist, then: twice at end of each row) and the TVH or you will have to connect them manually. If on an external computer, schedule it to run at e.g 4:00 daily. For me, it takes 15-20 minutes to finish.
For me, Rex in Win7 ignores the folder it was configured to save guide.xml and save file to the folder where the Rex configuration is saved. So, prior to continuing, I move this guide.xml to the network folder suitable to be copied to my RPi and rename it to guideRex.xml
If you generated guide.xml on RPi where TVH is, this task is done. Go to task 2.
As I do it at different machines, when finished, I copy the guide.xml (actualy guideRex.xml) to the RPi where TVH is. I use a script at RPi where TVH is (ssh must be fully configured prior to scp or add the pwd to the ssh command). If using Rex, copy the file generated by Rex.
- copy from the network disk:
scp [email protected]:/share/CACHEDEV1_DATA/Public/qWindows7/guide.xml /storage/guide.xml
#or for my Rex generated file:
scp [email protected]:/share/CACHEDEV1_DATA/Public/qWindows7/guideRex.xml /storage/guide.xml - or copy from another RPi
scp [email protected]:/storage/.kodi/userdata/addon_data/service.webgrabplus/guide.xml /storage/guide.xml
In my case, this command is in cron run script (at 5:15 daily) at my RPi where TVH is installed. Obviously, scp needs to be adjusted for others. There are other ways to do this, the point it: get guide.xml to the RPi with TVH!
Before continuing to the task 2, make sure you have produced valid guide.xml and it is present at /storage/guide.xml!
Task 2: Make TVH use the EPG data in the guide.xml¶
How to make TVH use this EPG data? Could not be simpler once you know what nees to be done. At RPi with TVH (for v4.0.9) edit the file (.kodi is hidden so make sure you can see it)
/storage/.kodi/userdata/addon_data/service.multimedia.tvheadend/settings.xml
where you will find:
<setting id="XMLTV_LOCATION_FILE" value="" />
<setting id="XMLTV_TYPE" value="NONE" />
Change them to:
<setting id="XMLTV_TYPE" value="FILE" />
<setting id="XMLTV_LOCATION_FILE" value="/storage/guide.xml" />
This is pointing TVH to the guide.xml copied from either server network disk or from the second RPi to the RPi with TVH. If you run Addon at the same RPi with TVH, this second line should be (I did not try this):
<setting id="XMLTV_LOCATION_FILE" value="/storage/.kodi/userdata/addon_data/service.webgrabplus/guide.xml" />
This same thing can be achieved from the the Kodi which installed this TVH addon: Setup, Addons, find the TVheadEnd (4.0 in my case) and then change first two rows as described above. This is editing the same file as above. I prefer direct manual editing as described above as it is much faster.
Now verify all is working well! From RPi where TVH is, just run the command (ssh, putty...):
/storage/.kodi/addons/service.multimedia.tvheadend/bin/tv_grab_file
If all is working well, you should see the raw EPG data echoed to the screen. OK: all is working! If not, something is wrong. Find it and fix it!!! You can not continue if this is not working!
Reboot the RPi with TvHeadEnd, connect onto it with your browser and select the new internal grabber: "XMLTV: tv_grab": Configuration -> Channel / EPG -> EPG grabber -> Internal Grabber -> Module "XMLTV: tv_grab" and save that. Changing Cron multi-line to: 24 5 * * * is optimal if you followed above.
For all the programs whose names match, at the Channels tab you should see the EPG source column populated with XMLTV ... tags. If not, fix it manually by selecting proper tags.
Done. Except for the fine tuning.
...
Tip: In the future, should you wish to force TVH to reread new guide.xml while you are experimenting, just change the above Internal Grabber Module to Disabled, Save Configuration, change back to "XMLTV: tv_grab" and Save configuration again. Be carefull to click Save configuration each time!
Languages warning:¶
When you pull the EPG data from the Web, it will have some language codes embedded, e.g. "en" for English or "hr" for Croatian and so on. TVH will be deciding what to display based on these tags in concordance with the langauages defined at TVH: Configuration -> General -> Language Settings. I am currently pulling 5 different language codes. English at the first spot messed up my display not showing what I wanted! The correct order will be a personal matter. Change order, Save and check immediatelly TVH EPG tab for changes. Take care you Save changes or the new language order will not be used! It seems that all languages used should be defined here to control how they are displayed. Leaving the list empty does terrible job for me. Important: While experimenting with EPG feeds you may change the langauge for certain feed. Language Settings order may prevent you from viewing updated data! If so, try moving new language up. Which may not be optimal for displaying the other languages, so find the best order for you.
...
Before everyhing is perfectly displayed in TVH, there is no point in checking EPG data in any other programs which are getting their EPG from TVH (e.g. Kodi). To show the new data, each Kodi will need to be told to delete programs (and therefore reread them) or delete (and reread) just the EPG data: Settings, Television: General: -> Delete or EPG data -> Delete.