Forums » Tutorial and setups »
EPG Movie Mailer v0.1
Added by Anonymous over 9 years ago
Did you ever realize that a movie was shown on TV just yesterday and missed to record it?
Description:
The "EPG Movie Mailer" was scripted to notify you immediately by mail about movies you always wanted to watch (e.g. IMDB top 250) and that will be soon shown on TV.
UPDATE (07.07.2015):
A Kodi plugin was developed for the EPG Movie Mailer. It is attached as a ZIP file to this post. There is an own post in the kodi.tv forum (http://forum.kodi.tv/showthread.php?tid=231529).
How it works:
The script is given a list of movies you'd like to watch. Then it searches the EPG (Electronic Program Guide) for that movies and mails you the results. Now you are informed about upcoming movies and can record it on time.
Technically it uses the API from the TVheadend server to search the EPG. Further analysis is done in python code. This includes the following features:
- Input movie list is given as a plain text file (each line is one movie)
- Movies are identified in EPG by regular expressions case incensitive (inherent feature of TVheadend API)
- On multiple execution it only mails new results and remembers already mailed movies
- For one movie multiple schedules are summarized
The following screenshot of a mail gives an example output (the movie list included only one search item: "Tatort"):
The layout can be customized as I am not the marketing guy
You still have to filter the mailed results, depending on the movie's name (e.g. "Water" will give quite a lot of results) and the regular expression you define (e.g. "^Water$" will only accept exact that title starting and ending with that word).
I will place that script as a cron job to be executed at least everyday (or alternatively once at startup).
The following output will be displayed on console:
# python client-htsp-epg-movie-mailer.py [*] Creating socket ... [*] Say hello ... [-] Server answers: Servername: HTS Tvheadend Serverversion: 3.4~wheezy HTSP version: 10 [*] Authenticating ... [*] Authentication succeeded [*] Using pysqlite version 2.6.0 [*] Using SQLite version 3.7.13 [*] Connected to SQLite database epgEventsMatched.db [*] Created new SQLite database epgEventsMatched.db [*] Searching for regular expression: Tatort [*] Match(es) found! Tatort: Letzte Tage Tatort: Schutzlos Tatort: Schutzlos Tatort: Borowski und der Engel [...] [*] No backup file yet exists ... creating one [--------------- [-] Title: Der Tatortreiniger [-] Description: Ja, ich will [-] Schedule: 22.07.2015 | 22:00 to - 22:30 on channel 13 [--------------- [-] Title: Der Tatortreiniger [-] Description: Tauschgeschäfte [-] Schedule: 23.07.2015 | 22:00 to - 22:30 on channel 13 [--------------- [-] Title: Tatort [-] Description: Eine Leiche zuviel [-] Schedule: 21.07.2015 | 22:00 to - 23:30 on channel 13 [--------------- [-] Title: Tatort - Brandmal [-] Description: Bei einem Brand in einem Mietshaus im rechtsrheinischen Stadtteil Kalk stirbt eine junge Frau an den Folgen einer Rauchvergiftung. Ersten Ergebnissen zufolge handelt es sich um Brandstiftung mit Todesfolge. Die Bestürzung des Vermieters ist groß, sein Urteil eindeutig: "Das können nur die Zigeuner gewesen sein!" Seitdem im Viertel ein Heim für Sinti und Roma aufgemacht hat, sei es immer wieder zu Konflikten zwischen den Flüchtlingen aus dem früheren Jugoslawien und den Einheimischen gekommen. Eine Anwohnerinitiative fordert die Schließung des Flüchtlingsheims und kämpft gegen das Bleiberecht für "kriminelle Ausländer". [-] Schedule: 02.07.2015 | 20:15 to - 21:40 on channel 28 [-] Schedule: 02.07.2015 | 20:15 to - 21:40 on channel 27 [...] Successfully sent email [*] Disconnected from DB epgEventsMatched.db
UPDATE - 27.06.2015:
Sorry, I missed to attach the referenced files from the HTSP python client library I use from the tvheadend sources. Now these dependencies should be attached in the ZIP file (client-htsp-epg-movie-mailer-release_20150627-v01.zip).
Download:
The file is attached: client-htsp-epg-movie-mailer-release_20150627-v01.py
client-htsp-epg-movie-mailer-release_20150627-v01.py.mail.png (63.3 KB) client-htsp-epg-movie-mailer-release_20150627-v01.py.mail.png | Example mail with a movie list from EPG | ||
client-htsp-epg-movie-mailer-release_20150627-v01.py (13.4 KB) client-htsp-epg-movie-mailer-release_20150627-v01.py | EPG Movie Mailer v0.1 | ||
movie_liste.txt (41 Bytes) movie_liste.txt | Example movie list | ||
client-htsp-epg-movie-mailer-release_20150627-v01.py.mail.png (63.3 KB) client-htsp-epg-movie-mailer-release_20150627-v01.py.mail.png | |||
client-htsp-epg-movie-mailer-release_20150627-v01.py (13.4 KB) client-htsp-epg-movie-mailer-release_20150627-v01.py | |||
movie_liste.txt (15 Bytes) movie_liste.txt | |||
client-htsp-epg-movie-mailer-release_20150627-v01.zip (12.2 KB) client-htsp-epg-movie-mailer-release_20150627-v01.zip | |||
service.epg-movie-mailer_v0.1.0.zip (40.7 KB) service.epg-movie-mailer_v0.1.0.zip |
Replies (2)
RE: EPG Movie Mailer v0.1 - Added by saen acro over 9 years ago
[-] Server answers: Servername: HTS Tvheadend Serverversion: 3.4~wheezy HTSP version: 10
is it support actual versions 4.1.xxx
RE: EPG Movie Mailer v0.1 - Added by Anonymous over 9 years ago
Hello Saen Acro,
Short answer:
I expect it to work also with 4.1.x! I forgot to add the HTSP python client library that is needed. It is now also attached to the post (see ZIP file).
Long answer:
My script uses the HTSP python client library from the tvheadend sources (see [1]). But the actual service calls are from the protocol description on the wiki page to the HTSP protocol (see [2]). In the headline it says "Version 21" of the HTSP protocol.
Therefore I conclude that the script should also work on newer versions, assumed that the protocol description in the wiki is still up to date.
My actual setup is the one shown in the posted console in your post. That is what my server answered when a connection is established. In lack of the current version I haven't tested it yet.
Maybe you could give it a try?
[1] https://github.com/tvheadend/tvheadend/tree/master/lib/py/tvh
[2] https://tvheadend.org/projects/tvheadend/wiki/Htsp