Giter VIP home page Giter VIP logo

horepg's Introduction

horepg

โš ๏ธ The API this project uses had been taken offline. Fortunately a good replacement can be found here: https://github.com/jbogers/ziggogo-epg

This simple script parses EPG data from the service at horizon.tv (which is used by a product sold by a digital cable provider in the Netherlands). The original data is formatted JSON. This script translated that to the XMLTV format and passes that to TVHeadend using the 'external grabber' interface. This interface is a Unix socket which is read by TVHeadend.

The script fetches a channel list from TVHeadend, and tries to match channels found in the Horizon data to channels found in TVHeadend. As long as you keep the channel names as provided on the DVB-C network a match is very likely, and no configuration is required.

EPG data for radio channels is added using oorboekje.nl as source. This is disabled by default, and enabled by passing the '-R' option on the commandline. j

Configuration

The script attempts to fetch a list of channels from TVHeadend using the JSON API, credentials can be passed on the commandline.

The script attempts to switch to the 'hts' user, with its group set to 'video'. This is what is default on my system, so you might want to changes this to reflect your own setup.

The script daemonizes by default, and waits 24 hours before fetching a new batch of data.

Dependencies

The only dependency is the Requests package, required for Basic Authentication for authentication in TVHeadend.

Installation

Use setuptools to install HorEPG:

python setup.py install

Usage

usage: horepgd.py [-h] [-s [PATH]] [-p [PATH]] [-u [USER]] [-g [GROUP]] [-d]
                  [-tvh HOST] [-tvh_username USERNAME]
                  [-tvh_password PASSWORD] [-R]
                  [-o [PATH]]

Fetches EPG data from the Horizon service and passes it to TVHeadend.

optional arguments:
  -h, --help            show this help message and exit
  -s [PATH]             path to TVHeadend XMLTV socket
  -p [PATH]             path to PID file
  -u [USER]             run as USER
  -g [GROUP]            run as GROUP
  -d                    daemonize
  -1                    Run once, then exit
  -nr [DAYS]            Number of days to fetch
  -tvh HOST             the hostname of TVHeadend to fetch channels from
  -tvh_username USERNAME
                        the username used to login into TVHeadend
  -tvh_password PASSWORD
                        the password used to login into TVHeadend
  -R                    fetch EPG data for radio channels
  -o                    path to output XML data instead of pushing to TVHeadend

This would require some privileges to switch to the user and group if daemonizing. The script daemonizes by default, and logging is using syslog().

Improvements

  • It would be nice to stop the whole reconnecting for each channel thingy.
  • Maybe this should be a proper xmltv parser.

horepg's People

Contributors

alexmekkering avatar beralt avatar donderstraal avatar hansworst24 avatar jbogers avatar robm83 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

horepg's Issues

No data available / geen info beschikbaar

Using your (modified) script for a really long time on Windows Media Center without any problem. Thank for that!

But last week I'm getting "No data available" sections in my channel EPG always with the same duration (about 12 hours) from about 12AM to 12PM, but not on all channels.

Is this related to the "fetch in blocks of 6 hours (8 hours is the maximum block size allowed)" modification in your script? Or is this only for using it with TVHeadend (which I'm not)?

Script stops after an internal server error

For some reason the horizon site seems to time out or be unavailable for short periods of time. The script will output a 500 Internal Server Error when retrieving listings, yet the listings appear to be available immediately after when running the script again, so a simple retry of the script would still make sure that the program listings are retrieved.

Added 67 programmes for channel AMC
Traceback (most recent call last):
File "/home/hts/horepg.py", line 209, in
nr = nr + listings.obtain(xmltv, channel_id, start, end)
File "/home/hts/horepg.py", line 171, in obtain
raise Exception('Failed to GET listings url:', response.status, response.reason)
Exception: ('Failed to GET listings url:', 500, 'Internal Server Error')
hts@raspberrypi:~$

Another thing, the deamon will run every 24h after it's completed the initial run, it'd be better if you could specify an exact time at which it should run and then repeat after 24 hours, because now there's no consistency and script requires resources as well which you can't allocate to a specific time slot.

Other than that it works great, cheers.

No module requests

Create Syno package and launched it but it failed on importing module request

root@DS715:/var/packages/HorEPG/scripts# ./start-stop-status start
Starting HorEPG ...
Traceback (most recent call last):
File "/var/packages/HorEPG/target/horepgd.py", line 17, in
from tvheadend import *
File "/volume1/@appstore/HorEPG/tvheadend.py", line 7, in
import requests
ImportError: No module named 'requests'

I also needed to modify start-stop-status script since it couldn't find horepgd.py
Added variable SYNOPKG_PKGNAME="HorEPG"

Grab all UPC/Horizon.tv countries

Hi, I've managed to fetch PL guide using your script. It will be nice to have possibility to grab other countries at once, in case when we have some foreign ones (PL,DE,NL etc).. for example by adding argument on commandline (-l DE,PL,NL..)

error message when executing horepgd

I'm getting following error:

root@tvheadend:/usr/local/bin# python3 /usr/local/bin/horepgd.py -s /home/hts/.hts/tvheadend/epggrab/xmltv.sock -p /run/horepgd.pid -u hts -g video -tvh tvheadend -tvh_username xxxxxxx -tvh_password xxxxxxxxxx
DEBUG:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): tvheadend
DEBUG:requests.packages.urllib3.connectionpool:http://tvheadend:9981 "GET /api/channel/list HTTP/1.1" 200 960
DEBUG:root:Fetching listings for 30 channels
DEBUG:root:Switching hosts
DEBUG:root:Switching hosts
DEBUG:root:Adding 364 programmes for channel Nicktoons
Traceback (most recent call last):
File "/usr/local/bin/horepgd.py", line 4, in
import('pkg_resources').run_script('HorEPG==0.1', 'horepgd.py')
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 739, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 1501, in run_script
exec(script_code, namespace, namespace)
File "/usr/local/lib/python3.5/dist-packages/HorEPG-0.1-py3.5.egg/EGG-INFO/scripts/horepgd.py", line 146, in
File "/usr/local/lib/python3.5/dist-packages/HorEPG-0.1-py3.5.egg/EGG-INFO/scripts/horepgd.py", line 142, in main
File "/usr/local/lib/python3.5/dist-packages/HorEPG-0.1-py3.5.egg/EGG-INFO/scripts/horepgd.py", line 89, in run_import
File "/usr/local/lib/python3.5/dist-packages/HorEPG-0.1-py3.5.egg/horepg/tvheadend.py", line 33, in send
FileNotFoundError: [Errno 2] No such file or directory

No episode numbers

Recently I setup my system again and downloaded the latest version of Horepg. It works well, I run it in cron every morning so I can control at what time it will update the EPG, but I noticed there are no episode numbers for any channel listings.

Is this feature removed? Is it not provided anymore on the Horizon site? Or is the script not functioning properly?

No data retrieved from oorboekje for radio channels.

Since the layout change i'm not getting any data from oorboekje, i double checked code (and argument -R) and reinstalled it multiple times on my Synology NAS without luck.
Syslog doesn't provide me any info that could be useful.

/edit:
Problem seems to be bigger now. After i stopped HorEPG in DSM it won't start anymore.

method convert_time() instance issue

when running app, it fetch tvh channels, but fails to proceed as class is wrongly invoked.

File "/home/ldymek/horepg-master/horepg/xmltvdoc.py", line 169, in addProgramme
element.setAttribute('start', XMLTVDocument.convert_time(int(start)))
TypeError: unbound method convert_time() must be called with XMLTVDocument instance as first argument (got int instance instead)

salt & pepper offline :(

Since today, 17-10-2022, horepgd can't connect any longer to Salt & Pepper :( Does anyone know if there are new URLs available ?

DEBUG:root:Fetching listings for 300 channels
DEBUG:root:Switching hosts due to status code 404 from host web-api-salt.horizon.tv
DEBUG:root:Switching hosts due to status code 404 from host web-api-pepper.horizon.tv
Traceback (most recent call last):
File "/home/hts/horepg/horepgd.py", line 154, in
main()
File "/home/hts/horepg/horepgd.py", line 147, in main
run_import(channels, args.tvhsocket, args.do_radio_epg, args.nr_days, args.output_path)

REQ: Use ending wildcard * to find/match channel names

Let my try to explain my current problem:
I only want to stream SD channels, but some channels are not found/matched

i.e. RTL 7

After some investigation it turns out that the horizon.tv API, only outputs for example the RTL 7 HD channel.
See https://web-api-pepper.horizon.tv/oesp/api/NL/nld/web/channels.com
":{"id":"24443943014","countryCode":"NL","locationId":"24443942973","title":"RTL 7 HD",".........

Would it be possible to find/match the channels, based on channel name PLUS a wildcard * ?
i.e RTL 7 -> RTL 7* (tvheadend channel RTL 7 would then be matched against horizon.tv RTL 7 HD epg data)

NEW Horizon api

Hello,

seems like the api were changed. Now channel id is not numeric, but something like:

lgi-nl-prod-master:65535-NL_000001_019401

I've started to debug it, but without luck now. The code at this point is not working. I've attached current channels listing

channels.zip

Retrieving EPG fails due to 404 error on 'web-api-salt.horizon.tv'

The server web-api-salt.horizon.tv does not work anymore and/or does not support the API used by horepg. The other server, web-api-pepper.horizon.tv, still functions but because the return code the 'salt' server sends (404) is unexpected, horepg crashes.

To fix this, return code 404 should also be used to switch from server, just like code 403 is.

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.