Code Monkey home page Code Monkey logo

tv_grab_zap2epg's Introduction

tv_grab_zap2epg - tvheadend XMLTV Grabber

North America (zap2epg using tvlistings.zap2it.com)

tv_grab_zap2epg will generate an xmltv.xml file for Canada/USA TV lineups by fetching channel list from tvheadend and downloading relevant entries from tvlistings.zap2it.com.

zap2epg was originally designed to be easily setup in Kodi for use as a grabber for tvheadend. This is a fork of the original code from edit4ever Python3 branch of script.module.zap2epg based on my PR edit4ever/script.module.zap2epg#37 (much thanks for your great original work @edit4ever !!!)

It includes the ability to automatically fetch your channel list from TVH to reduce the amount of data downloaded and speed up the grab. It has an option for downloading extra detail information for programs. (Note: this option will generate an extra http request per episode) It also has an option to append the extra detail information to the description (plot) field, which makes displaying this information in the Kodi EPG easier on many skins.

Note that zap2epg is a proof of concept and is for personal experimentation only. It is not meant to be used in a commercial product and its use is your own responsibiility.

tv_grab_zap2epg capabilities

zap2epg TV guide grabber script provides baseline capabilities (ref: http://wiki.xmltv.org/index.php/XmltvCapabilities):

  • --quiet: Suppress all progress information. When --quiet is used, the grabber shall only print error-messages to stderr.
  • --output FILENAME: Redirect the xmltv output to the specified file. Otherwise output goes to stdout along with a copy under epggrab/cache/xmltv.xml.
  • --days X: Supply data for X days, limited to 14.
  • --offset X: Start with data for day today plus X days. The default is 0, today; 1 means start from tomorrow, etc.
  • --config-file FILENAME: The grabber shall read all configuration data from the specified file. Otherwise uses default under epggrab/conf/zap2epg.xml It also provide the following "extra" capabilities:
  • --zip or --postal or --code: Allow can be used to pass US Zip or Canadian Postal code to be used by the grabber.

Configuration options (zap2epg.xml)

  • <setting id="zipcode">92101</setting>: US Zip or Canada postal code
  • <setting id="lineupcode">lineupId</setting>:
  • <setting id="lineup">Local Over the Air Broadcast</setting>:
  • <setting id="device">-</setting>:
  • <setting id="days">1</setting>: Number of TV guide days
  • <setting id="redays">1</setting>:
  • <setting id="slist"></setting>:
  • <setting id="stitle">false</setting>:
  • <setting id="xdetails">true</setting>: Download extra Movie or Serie details
  • <setting id="xdesc">true</setting>: Provide extra details to default TV show description
  • <setting id="epgenre">3</setting>:
  • <setting id="epicon">1</setting>:
  • <setting id="tvhoff">true</setting>: true=fetch channel list from TVH server, false=do not fetch channel list
  • <setting id="usern"></setting>: Username to access TVH server, anonymous if both usern + passw are empty
  • <setting id="passw"></setting>: Password to access TVH server
  • <setting id="tvhurl">127.0.0.1</setting>: IP address to TVH server
  • <setting id="tvhport">9981</setting>: Port of TVH server
  • <setting id="tvhmatch">true</setting>:
  • <setting id="chmatch">true</setting>:

TVheadEnd (TVH) auto-channel fetching

This feature is enabled by default using anonymous access. You must have a * user defined in TVH with minimally:

  • Change parameters: Rights
  • Allowed networks: 127.0.0.1 or 0.0.0.0;::/0

Using the following configuration:

  • <setting id="tvhoff">true</setting>
  • <setting id="usern"></setting>
  • <setting id="passw"></setting>
  • <setting id="tvhurl">127.0.0.1</setting>
  • <setting id="tvhport">9981</setting>
  • <setting id="tvhmatch">true</setting>
  • <setting id="chmatch">true</setting> It can be disabled by setting <setting id="tvhoff">false</setting>. It can also be set to using another user account by filling in the usern and passwd fields.

INSTALLATION: Synology DSM6/DSM7 TVH server:

Already included in the SynoCommunity tvheadend package for DSM6-7 since v4.3.20210612-29

DSM7 file structure:

/var/packages/tvheadend/target/bin
└── tv_grab_zap2epg
/var/packages/tvheadend/var/epggrab
├── cache
│   ├── *.json
│   └── xmltv.xml
├── conf
│   └── zap2epg.xml
└── log 
    └── zap2epg.log

DSM6 file structure:

/var/packages/tvheadend/target/bin
└── tv_grab_zap2epg
/var/packages/tvheadend/target/var/epggrab
├── cache
│   ├── *.json
│   └── xmltv.xml
├── conf
│   └── zap2epg.xml
└── log 
    └── zap2epg.log

Manual Installation

  1. Install tv_grab_zap2epg script addon in /usr/local/bin or /var/packages/tvheadend/target/bin
  2. Install zap2epg.xml configuration file under tvheadend epggrab/conf directory such as ..var/epggrab/conf
  3. Manually adjust zap2epg.xml configuration file as needed or use capabilities (see description below)

Testing

In order to test tv_grab_zap2epg EPG grabber under Synology DSM:

$ sudo su -s /bin/bash sc-tvheadend -c '~/bin/tv_grab_zap2epg --capabilities'
baseline
$ sudo su -s /bin/bash sc-tvheadend -c '~/bin/tv_grab_zap2epg --days 1 --postal J3B1M4 --quiet'
$ ls -la ~sc-tvheadend/var/epggrab/cache/xmltv.xml
-rw-rw-rw- 1 sc-tvheadend tvheadend 16320858 Jun 13 07:43 /var/packages/tvheadend/target/var/epggrab/cache/xmltv.xml

INSTALLATION: Docker tvheadend setup:

Installation is somewhat different where it uses the hts user account to handle the directory structure such as:

/usr/bin
└── tv_grab_zap2epg
/home/hts/epggrab
├── cache
│   ├── *.json
│   └── xmltv.xml
├── conf
│   └── zap2epg.xml
└── log 
    └── zap2epg.log

Manual Installation

Create the directory structure and adjust permissions:

# mkdir -p /home/hts/zap2epg/conf
# mkdir -p /home/hts/zap2epg/log
# mkdir -p /home/hts/zap2epg/cache
# chown -R hts:hts /home/hts/zap2epg
# chmod -R 0755 /home/hts/zap2epg

Copy the configuration and adjust permissions:

# cp zap2epg.xml /home/hts/zap2epg/conf
# chown hts:hts /home/hts/zap2epg/conf/zap2epg.xml
# chmod 644 /home/hts/zap2epg/conf/zap2epg.xml

Copy the script to /usr/bin and adjust permissions:

# tv_grab_zap2epg /usr/local/bin
# chmod 755 /usr/local/bin/tv_grab_zap2epg

tv_grab_zap2epg's People

Contributors

th0ma7 avatar

Stargazers

Sean Clancy avatar Jared Vacanti avatar Ulrich Thumult avatar Daniel Widrick avatar

Watchers

James Cloos avatar Jared Vacanti avatar  avatar

Forkers

successtheman

tv_grab_zap2epg's Issues

Expecting value

I am getting an error when i run the /tv_grab_zap2epg script:

Traceback (most recent call last):
File "", line 794, in mainRun
File "", line 130, in tvhMatchGet
File "/usr/lib/python3.9/site-packages/requests/models.py", line 910, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3.9/json/init.py", line 346, in loads
return _default_decoder.decode(s)
zap2epg.log

File "/usr/lib/python3.9/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

This was working for a few days and then it hit this snag. My guess is that one of the values it gets is empty and causing the error. I have attached the output from the command and also the log file:

zap2epg.log
20220922.log

I went through the code, but my python is rusty. I was thinking i could just check the value first and if it is empty i would skip the record. I tried to disable a few channels that i thought may have bad data (there is a canadian station that i can't get any data for), but nothing i have done will resolve the issue.

Anyway, if you could help that would be great.

Let me know if you need more information or if there is something else i should try.

Thanks,

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.