These are the instructions I saved when I set it up awhile ago circa 2018. It is still working well.
Install OSMC and TvHeadend. I am on the October 2018 update with TvHeadend version 4.2.6.
Download the zap2epg zip file from edit4ever’s page on GitHub.
In a terminal window type
sudo wget https://github.com/edit4ever/script.module.zap2epg/releases/download/v2.0.3/script.module.zap2epg-2.0.3.zip
Install the addon. From the KODI interface install the zip file by selecting addons à Install from repository à Install from zip file. Locate the zip file and install the addon.
Copy the tv_grab_zap2xml file from the addon bin folder and place into the usr/bin folder.
In a terminal window type
sudo cp ~/.kodi/addons/script.module.zap2epg/bin/tv_grab_zap2epg /usr/bin
Change permissions on the file by typing
sudo chmod +x /usr/bin/tv_grab_zap2epg
Restart the device or restart tvheadend by executing
sudo service tvheadend restart
In KODI, open the addon and follow to prompts to create your schedules. Make sure to select configure settings and type in your username and password for the TVH server.
Run the addon and get the EPG data if you like. The grabber will run it later on.
On the tvHeadend website. Make sure the user has expert view selected in their profile. Navigate to Configuration Channel / EPG EPG Grabber Modules . Find Internal: XMLTV: tv_grab_zap2epg is a simple grabber for USA-Canada and enable it. Be sure to disable the ATSC and PSIP grabbers.
Run the internal EPG grabbers. In the log window, it should say
xmltv: /usr/bin/tv_grab_zap2epg: grab /usr/bin/tv_grab_zap2epg”
After it has finished running it will give you information about the grab in the log window.
On the website, navigate to EPG Grabber Channels and link the EPG data to the proper channel. (It may have mapped it already for you). It can also be done through the Channels Tags page. It may take a couple minutes for TVH to parse through the data and allow you to link the data to the channels. A restart of the device may also allow this step sooner.
Navigate to EPG Grabber and select when you want the grabber to run via CRON.
EPG data should start to show up in KODI. You can point a new browser to your device:9981\xmltv page to see if the data is there. For example: http://192.168.0.100:9981/xmltv
Go back to the config page for zap2epg and select your options. Change the number of days to a more appropriate value.