-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathtv_grab_nl.py
executable file
·13507 lines (10851 loc) · 602 KB
/
tv_grab_nl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
# Python 3 compatibility
from __future__ import unicode_literals
# from __future__ import print_function
description_text = """
SYNOPSIS
tv_grab_nl_py is a python script that trawls tvgids.nl for TV
programming information and outputs it in XMLTV-formatted output (see
http://membled.com/work/apps/xmltv). Users of MythTV
(http://www.mythtv.org) will appreciate the output generated by this
grabber, because it fills the category fields, i.e. colors in the EPG,
and has logos for most channels automagically available. Check the
website below for screenshots. The newest version of this script can be
found here:
https://github.com/tvgrabbers/tvgrabnlpy/
USAGE
Check the web site above and/or run script with --help and start from there
REQUIREMENTS
* Python 2.6 or 2.7
* Connection with the Internet
QUESTIONS
Questions (and patches) are welcome at:
http://www.pwdebruin.net/mailman/listinfo/tv_grab_nl_py_pwdebruin.net
https://github.com/tvgrabbers/tvgrabnlpy/issues
https://groups.google.com/forum/#!forum/tvgrabnlpy
UPGRADE NOTES
If you were using tv_grab_nl from the XMLTV bundle then enable the
compat flag or use the --compat command-line option. Otherwise, the
xmltvid's are wrong and you will not see any new data in MythTV.
HISTORY
tv_grab_nl_py used to be called tv_grab_nl_pdb, created by Paul de Bruin
and first released on 2003/07/09. At the same time the code base switched
from using CVS to SVN at Google Code, and as a result the version numbering
scheme has changed. The lastest official release of tv_grab_nl_pdb is 0.48.
The first official release of tv_grab_nl_py is 6. In 2012, The codebase
moved to Git, and the version number was changed once more. The latest
subversion release of tv_grab_nl_py is r109. The first Git release of
tv_grab_nl_py is 2012-03-11 12:03.
As of december 2014/ januari 2015 Version 2.0.0:
Upgrading argument processing from getopt to argparse.
Also adding some options and adding to help text.
Fixing a small bug preventing multiple word details like 'jaar van
premiere' from being proccessed.
Adding genre/subgenre translation table and file (tv_grab_nl_py.set).
Automatically adding new genre/subgenre combinations on every scan.
Still looking into the way MythTV handles this.
This contains also other translation tables which mostly get updated on
every scan and gets created with defaults if not existing.
Adding titlesplit exception list to tv_grab_nl_py.set. Especially for
spin-off series like 'NCIS: Los Angeles'.
Adding optional default options file and creation. (tv_grab_nl_py.opt)
Adding optional proccessing of HD attribute.
Adding session log function (to the configname with .log added)
the last log is saved to .old (like with .conf, .opt and .set files)
Adding rtl.nl lookup for the 7 RTL channels. This adds season/episode info
and lookup further than 4 days in the future, defaulting to 14 days.
Genre info is missing. Timing and description from rtl.nl is used over
tvgids.nl
Adding teveblad.be lookup, mainly for belgium channels. This adds
season/episode info and lookup up to 7 days. Dutch channels only
have prime-time info and the commercial channels are missing.
Genre info is basic. Timing for the Belgium channels is used over
tvgids.nl
Adding tvgids.tv lookup. This adds lookup up to 14 days with decent genre
info.
Merged tv_grab_nl_py.opt into tv_grab_nl_py.conf and added several
translation tables to tv_grab_nl_py.set.
Moving html proccessing from pure regex filtering to ElementTree
Reorganised code to be more generic to make adding new sources easer
and as preparation for a configuration module. Also put the different
sources in parallel threads.
Working on more intelligent description proccessing.
Working in ever more intelligent source merging.
Working on a configuration module.
Possibly adding ttvdb.com and tmdb3.com lookup for missing descriptions
and season/episode info
Possibly adding more optional (foreign) sources (atlas?)
CONTRIBUTORS
Main author: Paul de Bruin (paul at pwdebruin dot net)
Current maintainer: Freek Dijkstra (software at macfreek dot nl)
Currently 'december 2014' the latest version of '2012-03-27' adapted by:
Hika van den Hoven hikavdh at gmail dot com, but also active on the
mythtv list: mythtv-users at mythtv dot org
Michel van der Laan made available his extensive collection of
high-quality logos that is used by this script.
Several other people have provided feedback and patches:
Huub Bouma, Michael Heus, Udo van den Heuvel, Han Holl, Hugo van der Kooij,
Roy van der Kuil, Ian Mcdonald, Dennis van Onselen, Remco Rotteveel, Paul
Sijben, Willem Vermin, Michel Veerman, Sietse Visser, Mark Wormgoor.
LICENSE
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""
# Modules we need
import re, sys, codecs, locale, argparse
import time, datetime, random, io, json, shutil
import os, os.path, pickle, smtplib, httplib
import traceback, socket, sqlite3, difflib
try:
import urllib.request as urllib
except ImportError:
import urllib2 as urllib
try:
from html.entities import name2codepoint
except ImportError:
from htmlentitydefs import name2codepoint
from copy import deepcopy
from threading import Thread, Lock, Event, active_count, Semaphore
from threading import enumerate as enumthreads
from xml.sax import saxutils
from xml.etree import cElementTree as ET
from Queue import Queue, Empty
from email.mime.text import MIMEText
try:
unichr(42)
except NameError:
unichr = chr # Python 3
# check Python version
if sys.version_info[:3] < (2,7,9):
sys.stderr.write("tv_grab_nl_py requires Pyton 2.7.9 or higher\n")
sys.exit(2)
if sys.version_info[:2] >= (3,0):
sys.stderr.write("tv_grab_nl_py does not yet support Pyton 3 or higher.\nExpect errors while we proceed\n")
locale.setlocale(locale.LC_ALL, '')
# XXX: fix to prevent crashes in Snow Leopard [Robert Klep]
if sys.platform == 'darwin' and sys.version_info[:3] == (2, 6, 1):
try:
urllib.urlopen('http://localhost.localdomain')
except:
pass
class AmsterdamTimeZone(datetime.tzinfo):
"""Timezone information for Amsterdam"""
def __init__(self):
# calculate for the current year:
year = datetime.date.today().year
d = datetime.datetime(year, 4, 1, 2, 0) # Starts last Sunday in March 02:00:00
self.dston = d - datetime.timedelta(days=d.weekday() + 1)
d = datetime.datetime(year, 11, 1, 2, 0) # Ends last Sunday in October 02:00:00
self.dstoff = d - datetime.timedelta(days=d.weekday() + 1)
def tzname(self, dt):
return unicode('CET_CEST')
def utcoffset(self, dt):
return datetime.timedelta(hours=1) + self.dst(dt)
def dst(self, dt):
if self.dston <= dt.replace(tzinfo=None) < self.dstoff:
return datetime.timedelta(hours=1)
else:
return datetime.timedelta(0)
# end AmsterdamTimeZone
class UTCTimeZone(datetime.tzinfo):
"""UTC Timezone"""
def tzname(self, dt):
return unicode('UTC')
def utcoffset(self, dt):
return datetime.timedelta(0)
def dst(self, dt):
return datetime.timedelta(0)
# end UTCTimeZone
CET_CEST = AmsterdamTimeZone()
UTC = UTCTimeZone()
config = None
class Logging(Thread):
"""The tread that manages all logging.
The function below puts them in a queue that is sampled.
So logging can start after the queue is opend when this class is called below"""
def __init__(self):
Thread.__init__(self, name = 'logging')
self.quit = False
self.log_level = 175
self.quiet = False
self.graphic_frontend = False
self.log_queue = Queue()
self.log_output = None
self.log_string = []
self.all_at_details = False
try:
codecs.lookup(locale.getpreferredencoding())
self.local_encoding = locale.getpreferredencoding()
except LookupError:
if os.name == 'nt':
self.local_encoding = 'windows-1252'
else:
self.local_encoding = 'utf-8'
def run(self):
self.log_output = config.log_output
lastcheck = datetime.datetime.now()
checkinterfall = 60
while True:
try:
if self.quit and self.log_queue.empty():
if config.opt_dict['mail_log']:
config.send_mail(self.log_string, config.opt_dict['mail_log_address'])
return(0)
if (datetime.datetime.now() - lastcheck).total_seconds() > checkinterfall:
lastcheck = datetime.datetime.now()
self.check_thread_sanity()
try:
message = self.log_queue.get(True, 5)
except Empty:
continue
if message == None:
continue
if isinstance(message, (str, unicode)):
if message == 'Closing down\n':
self.quit=True
self.writelog(message)
continue
elif isinstance(message, (list ,tuple)):
llevel = message[1] if len(message) > 1 else 1
ltarget = message[2] if len(message) > 2 else 3
if message[0] == None:
continue
if message[0] == 'Closing down\n':
self.quit = True
if isinstance(message[0], (str, unicode)):
self.writelog(message[0], llevel, ltarget)
continue
elif isinstance(message[0], (list, tuple)):
for m in message[0]:
if isinstance(m, (str, unicode)):
self.writelog(m, llevel, ltarget)
continue
self.writelog('Unrecognized log-message: %s of type %s\n' % (message, type(message)))
except:
traceback.print_exc()
pass
def check_thread_sanity(self):
idle_timeout = 180
chan_count = {}
for t in range(-1, 5):
chan_count[t] = 0
for t in enumthreads():
if t.name[:8] == 'channel-':
state = t.state
chan_count[-1] += 1
chan_count[state] += 1
if state in (0, 3):
continue
elif state == 1:
# Waiting for a basepage
s = t.source
if not isinstance(s, int):
continue
sc = xml_output.channelsource[s]
if sc.is_alive() and sc.state < 2:
continue
t.source_data[s].set()
elif state == 2:
# Waiting for a child channel
s = t.source
if not s in config.channels.keys():
continue
sc = config.channels[s]
if sc.is_alive() and sc.state < 3:
continue
sc.child_data.set()
if not self.all_at_details and chan_count[-1] == chan_count[4]:
# All channels are at least waiting for details
self.all_at_details = True
if self.all_at_details:
for t in enumthreads():
if t.name[:7] == 'source-':
waittime = None
if isinstance(t.lastrequest, datetime.datetime):
waittime = (datetime.datetime.now() - t.lastrequest).total_seconds()
if waittime == None or waittime < idle_timeout:
break
else:
# All sources are waiting more then idle_timeout
# So we tell all channels nothing more is coming
for t in enumthreads():
if t.name[:8] == 'channel-':
t.detail_data.set()
def writelog(self, message, log_level = 1, log_target = 3):
def now():
return datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S %Z') + ': '
try:
if message == None:
return
# If config is not yet available
if (config == None) and (log_target & 1):
sys.stderr.write(('Error writing to log. Not (yet) available?\n').encode(self.local_encoding, 'replace'))
sys.stderr.write(message.encode(self.local_encoding, 'replace'))
return
# Log to the Frontend. To set-up later.
if self.graphic_frontend:
pass
# Log to the screen
elif log_level == 0 or ((not self.quiet) and (log_level & self.log_level) and (log_target & 1)):
sys.stderr.write(message.encode(self.local_encoding, 'replace'))
# Log to the log-file
if (log_level == 0 or ((log_level & self.log_level) and (log_target & 2))) and self.log_output != None:
if '\n' in message:
message = re.split('\n', message)
for i in range(len(message)):
if message[i] != '':
self.log_output.write(now() + message[i] + '\n')
if config.opt_dict['mail_log']:
self.log_string.append(now() + message[i] + '\n')
else:
self.log_output.write(now() + message + '\n')
if config.opt_dict['mail_log']:
self.log_string.append(now() + message + '\n')
self.log_output.flush()
except:
sys.stderr.write((now() + 'An error ocured while logging!\n').encode(self.local_encoding, 'replace'))
traceback.print_exc()
# end Logging
logging = Logging()
def log(message, log_level = 1, log_target = 3):
# If logging not (jet) available, make sure important messages go to the screen
if (logging.log_output == None) and (log_level < 2) and (log_target & 1):
if isinstance(message, (str, unicode)):
sys.stderr.write(message.encode(logging.local_encoding, 'replace'))
elif isinstance(message, (list ,tuple)):
for m in message:
sys.stderr.write(m.encode(logging.local_encoding, 'replace'))
if log_target & 2:
logging.log_queue.put([message, log_level, 2])
else:
logging.log_queue.put([message, log_level, log_target])
# end log()
class Configure:
"""This class holds all configuration details and manages file IO"""
def __init__(self):
"""
DEFAULT OPTIONS - Edit if you know what you are doing
"""
# Version info as returned by the version function
self.name ='tv_grab_nl_py'
self.major = 2
self.minor = 2
self.patch = 21
self.patchdate = u'20170317'
self.alfa = False
self.beta = False
self.cache_return = Queue()
self.channels = {}
self.chan_count = 0
self.opt_dict = {}
# This must alway stay off. It can be turned on by a graphic frontend
# When this runs as a module
self.opt_dict['graphic_frontend'] = False
# Used for creating extra debugging output to beter the code
self.write_info_files = False
# This handles what goes to the log and screen
# 0 Nothing (use quiet mode to turns of screen output, but keep a log)
# 1 include Errors and Warnings
# 2 include page fetches
# 4 include summaries
# 8 include detail fetches and ttvdb lookups to the screen
# 16 include detail fetches and ttvdb lookups to the log
# 32 include matchlogging (see below)
# 64 Title renames
# 128 ttvdb.com lookup failures
self.opt_dict['log_level'] = 175
# The log filehandler, gets set later
self.log_output = None
# What match results go to the log/screen (needs code 32 above)
# 0 = Log Nothing (just the overview)
# 1 = log not matched programs
# 2 = log left over programs
# 4 = Log matches
# 8 = Added from Groupslots
self.opt_dict['match_log_level'] = 11
# A selection of user agents we will impersonate, in an attempt to be less
# conspicuous to the tvgids.nl police.
self.user_agents = [ 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9',
'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.19) Gecko/20081216 Ubuntu/8.04 (hardy) Firefox/2.0.0.19',
'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.75.14 (KHTML, like Gecko) Version/7.0.3 Safari/7046A194A',
'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 7.0; InfoPath.3; .NET CLR 3.1.40767; Trident/6.0; en-IN)',
'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0',
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.1 Safari/537.36',
'Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0']
# default encoding iso-8859-1 is general and iso-8859-15 is with euro support
self.httpencoding = 'iso-8859-15'
#~ self.httpencoding = 'utf-8'
self.file_encoding = 'utf-8'
# seed the random generator
random.seed(time.time())
# default configuration file locations
self.hpath = ''
if 'HOME' in os.environ:
self.hpath = os.environ['HOME']
elif 'HOMEPATH' in os.environ:
self.hpath = os.environ['HOMEPATH']
# extra test for windows users
if os.name == 'nt' and 'USERPROFILE' in os.environ:
self.hpath = os.environ['USERPROFILE']
self.xmltv_dir = u'%s/.xmltv' % self.hpath
self.config_file = u'%s/tv_grab_nl_py.conf' % self.xmltv_dir
self.log_file = u'%s/tv_grab_nl_py.log' % self.xmltv_dir
self.settings_file = u'%s/tv_grab_nl_py.set' % self.xmltv_dir
# cache the detail information.
self.program_cache_file = u'%s/program_cache' % self.xmltv_dir
self.clean_cache = True
self.clear_cache = False
# where the output goes. None means to the screen (stdout)
self.opt_dict['output_file'] = None
# some variables for mailing the log
self.opt_dict['mail_log'] = False
self.opt_dict['mailserver'] = 'localhost'
self.opt_dict['mailport'] = 25
self.opt_dict['mail_log_address'] = 'postmaster'
self.opt_dict['mail_info_address'] = None
# how many seconds to wait before we timeout on a
# url fetch, 10 seconds seems reasonable
# and the maximum of simultaneous fetches that can occure
self.opt_dict['global_timeout'] = 10
self.opt_dict['max_simultaneous_fetches'] = 5
# Wait a random number of seconds between each page fetch.
# We want to be nice and not hammer tvgids.nl (these are the
# friendly people that provide our data...).
# Also, it appears tvgids.nl throttles its output.
# So there, there is not point in lowering these numbers, if you
# are in a hurry, use the (default) fast mode.
self.nice_time = [1, 2]
# Experimental strategy for clumping overlapping programming, all programs that overlap more
# than max_overlap minutes, but less than the length of the shortest program are clumped
# together. Highly experimental and disabled for now.
self.do_clump = False
# First fill the dict with some defaults
# no output
self.opt_dict['quiet'] = False
# Fetch data in fast mode, i.e. do NOT grab all the detail information,
# fast means fast, because as it then does not have to fetch a web page for each program
self.opt_dict['fast'] = False
# The day to start grabbing 0 means now
self.opt_dict['offset'] = 0
# the total number of days to fetch
# the first four come from tvgids.nl the rest from tvgids.tv
self.opt_dict['days'] = 14
# None means all in slow-mode and none in fast-mode
# Setting it to a value sets 'fast' always to False (i.e. to slow-mode)
self.opt_dict['slowdays'] = None
self.opt_dict['disable_source'] = []
self.opt_dict['disable_detail_source'] = []
self.opt_dict['disable_ttvdb'] = False
self.ttvdb_disabled_groups = (6, 8, 11, 12, 13, 17)
# enable this option if you were using tv_grab_nl, it adjusts the generated
# xmltvid's so that everything works.
self.opt_dict['compat'] = False
self.opt_dict['legacy_xmltvids'] = False
# Maximum length in minutes of gaps/overlaps between programs to correct
self.opt_dict['max_overlap'] = 10
# Strategy to use for correcting overlapping prgramming:
# 'average' = use average of stop and start of next program
# 'stop' = keep stop time of current program and adjust start time of next program accordingly
# 'start' = keep start time of next program and adjust stop of current program accordingly
# 'none' = do not use any strategy and see what happens
self.opt_dict['overlap_strategy'] = 'average'
# insert url of channel logo into the xml data, this will be picked up by mythfilldatabase
self.opt_dict['logos'] = True
# Maximum number of characters to use for program description.
# Different values may work better in different versions of MythTV.
self.opt_dict['desc_length'] = 475
# enable this option if you do not want the tvgids categories being translated into
# MythTV-categories (genres)
self.opt_dict['cattrans'] = True
# mark programs with the HD 1080i tag in the output
# leave off if you only record analog SD
self.opt_dict['mark_hd'] = False
# don't convert all the program date/times to UTC (GMT) timezone.
# by default the current timezone is Europe/Amsterdam. This works fine
# if you are located in the Amsterdam timezone, but not if you live abroad
# in another timezone. If you want to use the UTC timestamp in combination
# with mythtv, be sure to set the timezone in mythtv to 'auto'
# (TimeOffset in Settings table)
self.opt_dict['use_utc'] = False
# Whether to use the split double episodes regularily seen on teveblad.be
self.opt_dict['use_split_episodes'] = True
# After configure, place the active channels in a separate group on top of the list
self.opt_dict['group_active_channels'] = False
# Whether to always update Channel- names, groups and prime_sources settings from the sourcematching.json data
self.opt_dict['always_use_json'] = True
self.weekdagen = ('zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag')
self.monthnames = ('dummy', 'januari', 'februari', 'maart', 'april', 'mei', 'juni',
'juli', 'augustus', 'september', 'oktober', 'november', 'december')
# The values for the Kijkwijzer
# Possible styles are
# long, short, single and none
self.opt_dict['kijkwijzerstijl'] = 'short'
self.kijkwijzer = {'1': {'code': 'AL','text': 'Voor alle leeftijden',
'icon':'http://tvgidsassets.nl/img/kijkwijzer/al_transp.png'},
'2': {'code': '6+','text': 'Afgeraden voor kinderen jonger dan 6 jaar',
'icon':'http://tvgidsassets.nl/img/kijkwijzer/6_transp.png'},
'9': {'code': '9+','text': 'Afgeraden voor kinderen jonger dan 9 jaar',
'icon':'http://tvgidsassets.nl/img/kijkwijzer/9_transp.png'},
'3': {'code': '12+','text': 'Afgeraden voor kinderen jonger dan 12 jaar',
'icon':'http://tvgidsassets.nl/img/kijkwijzer/12_transp.png'},
'4': {'code': '16+','text': 'Niet voor personen tot 16 jaar',
'icon':'http://tvgidsassets.nl/img/kijkwijzer/16_transp.png'},
'g': {'code': 'Geweld','text': 'Geweld',
'icon':'http://tvgidsassets.nl/img/kijkwijzer/geweld_transp.png'},
'a': {'code': 'Angst','text': 'Angst',
'icon':'http://tvgidsassets.nl/img/kijkwijzer/angst_transp.png'},
's': {'code': 'Seks','text': 'Seks',
'icon':'http://tvgidsassets.nl/img/kijkwijzer/seks_transp.png'},
't': {'code': 'Grof','text': 'Grof taalgebruik',
'icon':'http://tvgidsassets.nl/img/kijkwijzer/grof_transp.png'},
'h': {'code': 'Drugs','text': 'drugs- en/of alcoholmisbruik',
'icon':'http://tvgidsassets.nl/img/kijkwijzer/drugs_transp.png'},
'd': {'code': 'Discriminatie','text': 'Discriminatie',
'icon':'http://tvgidsassets.nl/img/kijkwijzer/discriminatie_transp.png'}}
self.tvkijkwijzer = {'AL':'1',
'6':'2',
'9':'9',
'12':'3',
'16':'4',
'angst':'a',
'geweld':'g',
'seks':'s',
'taal':'t'}
self.vrtkijkwijzer = {'6+':'2',
'9+':'9',
'12+':'3',
'16+':'4'}
# Create a role translation dictionary for the xmltv credits part
# The keys are the roles used by tvgids.nl (lowercase please)
self.roletrans = {"regisseur" : "director",
"regie" : "director",
"met" : "actor",
"acteurs" : "actor",
"acteursnamen_rolverdeling": "actor",
"gastacteur" : "guest",
"scenario" : "writer",
"scenario schrijver" : "writer",
"componist" : "composer",
"presentatie" : "presenter",
"presentator" : "presenter",
"verslaggever" : "reporter",
"commentaar" : "commentator",
"adapter" : "adapter",
"producer" : "producer",
"editor" : "editor"}
# A list of countries with their 2 digit version:
self.coutrytrans = {}
# List of titles not to split with title_split().
# these are mainly spin-off series like NCIS: Los Angeles
self.notitlesplit = []
# Parts to remove from a title
self.groupnameremove = ['kro detectives', 'detectives', 'premiére']
# Titles to rename
self.titlerename = {'navy ncis': 'NCIS',
'inspector banks': 'DCI Banks'}
self.chan_opt = {}
self.chan_opt['bool'] = ['fast', 'compat', 'logos', 'cattrans', 'mark_hd', 'add_hd_id',
'append_tvgidstv', 'disable_ttvdb', 'use_split_episodes', 'legacy_xmltvids']
self.chan_opt['string'] = ['xmltvid_alias']
self.chan_opt['int'] = ['slowdays', 'max_overlap', 'desc_length']
self.chan_opt['all'] = ['prime_source', 'prefered_description', 'overlap_strategy']
self.chan_opt['all'].extend(self.chan_opt['bool'])
self.chan_opt['all'].extend(self.chan_opt['string'])
self.chan_opt['all'].extend(self.chan_opt['int'])
# Create a category translation dictionary
# Look in mythtv/themes/blue/ui.xml for all category names
# The keys are the categories used by tvgids.nl (lowercase please)
# See the file ~/.xmltv/tv_grab_nl_py.set created after the first run and edit there!
self.cattrans = { (u'', u'') : u'Unknown',
(u'amusement', u'') : u'Talk',
(u'amusement', u'quiz') : u'Game',
(u'amusement', u'spelshow') : u'Game',
(u'amusement', u'muziekshow') : u'Art/Music',
(u'amusement', u'muziekprogramma') : u'Art/Music',
(u'amusement', u'dansprogramma') : u'Art/Music',
(u'amusement', u'cabaret') : u'Art/Music',
(u'amusement', u'variete') : u'Art/Music',
(u'amusement', u'sketches') : u'Art/Music',
(u'amusement', u'stand-up comedy') : u'Art/Music',
(u'amusement', u'stand-up comedy, sketches'): u'Art/Music',
(u'amusement', u'erotisch programma') : u'Adult',
(u'amusement', u'komedie') : u'Comedy',
(u'amusement', u'klusprogramma') : u'Home/How-to',
(u'amusement', u'hobbyprogramma') : u'Home/How-to',
(u'amusement', u'lifestyleprogramma') : u'Home/How-to',
(u'amusement', u'modeprogramma') : u'Home/How-to',
(u'amusement', u'kookprogramma') : u'Cooking',
(u'amusement', u'realityserie') : u'Reality',
(u'documentaire', u'') : u'Documentary',
(u'educatief', u'') : u'Educational',
(u'film', u'') : u'Film',
(u'korte film', u'') : u'Film',
(u'info', u'') : u'News',
(u'info', u'business') : u'Bus./financial',
(u'info', u'documentary') : u'Documentary',
(u'info', u'science') : u'Science/Nature',
(u'informatief, amusement', u'') : u'Educational',
(u'informatief, amusement', u'kookprogramma'): u'Cooking',
(u'informatief, kunst en cultuur', u''): u'Arts/Culture',
(u'informatief, wetenschap', u'') : u'Science/Nature',
(u'informatief', u'') : u'Educational',
(u'informatief', u'wetenschappelijk programma'): u'Science/Nature',
(u'informatief', u'techniek') : u'Science/Nature',
(u'informatief', u'documentaire') : u'Documentary',
(u'informatief', u'gezondheid') : u'Health',
(u'informatief', u'fitnessprogramma') : u'Health',
(u'informatief', u'gymnastiekprogramma'): u'Health',
(u'informatief', u'medisch programma'): u'Health',
(u'informatief', u'medisch praatprogramma'): u'Health',
(u'informatief', u'docusoap') : u'Reality',
(u'informatief', u'realityprogramma') : u'Reality',
(u'informatief', u'realityserie') : u'Reality',
(u'informatief', u'praatprogramma') : u'Talk',
(u'informatief', u'jeugdprogramma') : u'Children',
(u'jeugd', u'') : u'Children',
(u'kunst/cultuur', u'') : u'Arts/Culture',
(u'kunst en cultuur', u'') : u'Arts/Culture',
(u'magazine', u'') : u'Talk',
(u'muziek', u'') : u'Art/Music',
(u'natuur', u'') : u'Science/Nature',
(u'nieuws/actualiteiten', u'') : u'News',
(u'news', u'') : u'News',
(u'religieus', u'') : u'Religion',
(u'serie/soap', u'') : u'Drama',
(u'serie/soap', u'jeugdserie') : u'Children',
(u'serie/soap', u'animatieserie') : u'Children',
(u'serie/soap', u'tekenfilmserie') : u'Children',
(u'serie/soap', u'soap') : u'Soap',
(u'serie/soap', u'comedyserie') : u'Comedy',
(u'serie/soap', u'komedieserie') : u'Comedy',
(u'serie/soap', u'detectiveserie') : u'Crime/Mystery',
(u'serie/soap', u'misdaadserie') : u'Crime/Mystery',
(u'serie/soap', u'fantasyserie') : u'Sci-fi/Fantasy',
(u'serie/soap', u'sciencefictionserie'): u'Sci-fi/Fantasy',
(u'serie/soap', u'actieserie') : u'Action',
(u'sport', u'') : u'Sports',
(u'talks', u'') : u'Talk',
(u'talkshow', u'') : u'Talk',
(u'wetenschap', u'') : u'Science/Nature',
(u'overige', u'') : u'Unknown'}
self.genre_list = []
# These ara all dicts used in merging the sources
self.source_cattrans = {}
self.new_cattrans = {}
# tvgids.tv subgenre to genre translation table
self.source_cattrans[1] = {'euromillions': 'Amusement',
'erotisch magazine': 'Amusement',
'reality-reeks': 'Amusement',
'keno': 'Amusement',
'loterij': 'Amusement',
'spektakel': 'Amusement',
'informatief programma': 'Informatief',
'reportage': 'Informatief',
'biografie': 'Informatief',
'schooltelevisie ': 'Informatief',
'peuterprogramma': 'Jeugd',
'kleuterprogramma': 'Jeugd',
'tekenfilm': 'Jeugd',
'animatiereeks': 'Jeugd',
'theatershow': 'Kunst en Cultuur',
'concert': 'Muziek',
'musical': 'Muziek',
'weerbericht': 'Nieuws/Actualiteiten',
'verkeersinfo': 'Nieuws/Actualiteiten',
'actualiteitenmagazine': 'Nieuws/Actualiteiten',
'actuele reportage': 'Nieuws/Actualiteiten',
'praatprogramma over de actualiteit': 'Nieuws/Actualiteiten',
'voetbal': 'Sport',
'darts': 'Sport',
'golf': 'Sport',
'wielrennen op de weg': 'Sport',
'baanwielrennen': 'Sport',
'tennis': 'Sport',
'veldrijden': 'Sport',
'volleybal': 'Sport',
'motorcross': 'Sport',
'religieuze uitzending': 'Religieus',
'docusoap': 'Informatief',
'sitcom': 'Serie/Soap'}
self.new_cattrans[1] = []
# teveblad.be genre translation table
self.source_cattrans[3] = {'amusement' : (u'Amusement', u''),
'documentaire' : (u'Informatief', u'Documentaire'),
'film' : (u'Film', u''),
'kinderen' : (u'Jeugd', u''),
'kunst & cultuur': (u'Kunst en Cultuur', u''),
'magazine' : (u'Magazine', u''),
'muziek' : (u'Muziek', u''),
'nieuws' : (u'Nieuws/Actualiteiten', u''),
'reality' : (u'informatief', u'realityprogramma'),
'serie' : (u'Serie/Soap', u''),
'sport' : (u'Sport', u''),
'andere' : (u'Overige', u'')}
self.new_cattrans[3] = {}
# npo.nl genre translation table
self.source_cattrans[4] = {('nieuws-actualiteiten', ): (u'nieuws/actualiteiten', u''),
('amusement', ): (u'amusement', u''),
('amusement', 'komisch', ): (u'amusement', u'komedie'),
('amusement', 'spel-quiz', ): (u'amusement', u'quiz'),
('informatief', ): (u'informatief', u''),
('informatief', 'nieuws-actualiteiten', ): (u'nieuws/actualiteiten', u''),
('informatief', 'kunst-cultuur', ): (u'informatief', u'kunst/cultuur'),
('informatief', 'gezondheid-opvoeding', ): (u'informatief', u'gezondheid'),
('informatief', 'consumenten-informatie', ): (u'informatief', u'consument'),
('informatief', 'spel-quiz', ): (u'informatief', u'quiz'),
('informatief', 'koken-eten', ): (u'informatief', u'kookprogramma'),
('informatief', 'natuur', ): (u'natuur', u''),
('informatief', 'religieus' ): (u'religieus', u''),
('religieus', ): (u'religieus', u''),
('jeugd', ): (u'jeugd', u''),
('jeugd', 'animatie', ): (u'jeugd', u'animatieserie'),
('jeugd', 'spel-quiz', ): (u'jeugd', u'quiz'),
('documentaire', ): (u'documentaire', u''),
('documentaire', 'kunst-cultuur', ): (u'documentaire', u'kunst/cultuur'),
('sport', ): (u'sport', u''),
('sport', 'sport-informatie', ): (u'sport', u'journaal'),
('animatie', ): (u'serie/soap', u'animatieserie'),
('natuur', ): (u'natuur', u''),
('muziek', ): (u'muziek', u''),
('muziek', 'muziek-populair', ): (u'muziek', u'populair'),
('muziek', 'muziek-klassiek', ): (u'muziek', u'klassiek'),
('film', ): (u'film', u''),
('film', 'animatie', ): (u'film', u'animatieserie'),
('film', 'spanning', ): (u'film', u'thriller'),
('wetenschap', ): (u'wetenschap', u''),
('drama', ): (u'serie/soap', u'drama'),
('reizen', ): (u'reizen', u''),
('serie', ): (u'serie/soap', u''),
('serie', 'soap-serie', ): (u'serie/soap', u'soap')}
#~ '14': (u'serie/soap', u''),
#~ '15': (u'overige', u''),
#~ '18': (u'serie/soap', u'misdaadserie'),
#~ '19': (u'kunst/cultuur', u''),
#~ '20': (u'amusement', u'erotisch programma'),
#~ '23': (u'amusement', u'komedie'),
#~ '26': (u'educatief', u''),
#~ '27': (u'informatief', u'fitnessprogramma'),
#~ '29': (u'jeugd', u'6-12'),
#~ '30': (u'maatschappij', u''),
#~ '32': (u'jeugd', u'2-5'),
#~ '34': (u'muziek', u'klassiek'),
#~ '77': (u'gezondheid-opvoeding', u''),
#~ '79': (u'komisch', u''),
#~ '80': (u'spanning', u''),
#~ '81': (u'consumenten-informatie', u''),
#~ '82': (u'wonen-tuin', u''),
#~ '83': (u'muziek-populair', u''),
#~ '84': (u'spel-quiz', u''),
#~ '85': (u'cabaret', u''),
#~ '86': (u'sport-informatie', u''),
#~ '87': (u'muziek-klassiek', u''),
#~ '88': (u'koken-eten', u''),
#~ '89': (u'geschiedenis', u''),
#~ '90': (u'sport-wedstrijd', u''),
#~ '91': (u'soap-serie', u'')}
self.new_cattrans[4] = {}
self.npo_fill = 'Programmainfo en Reclame'
# horizon.tv genre translation table
self.source_cattrans[5] ={('13946319', ): ('nieuws/actualiteiten',''),
('13946319', '13946323'): ('informatief', 'Documentaire'),
('13946319', '13946324'): ('informatief', 'Discussie'),
('13946336', ): ('amusement',''),
('13946336', '13946338'): ('kunst en cultuur', 'Variété'),
('13946336', '13946340'): ('talkshow', ''),
('13946352', ): ('sport',''),
('13946369', ): ('jeugd', ''),
('13946386', ): ('muziek', ''),
('13946404', ): ('kunst en cultuur', ''),
('13946404', '13946407'): ('religieus', ''),
('13946455', ): ('informatief', ''),
('13946420', ): ('informatief', ''),
('13946438', ): ('informatief', ''),
('13946472', ): ('informatief', ''),
('13948023', ): ('serie/soap', ''),
('13948023', '13948024'): ('serie/soap', 'thriller'),
('13948023', '13948025'): ('serie/soap', 'actieserie'),
('13948023', '13948026'): ('serie/soap', 'sciencefictionserie'),
('13948023', '13948027'): ('serie/soap', 'comedyserie'),
('13948023', '13948028'): ('serie/soap', 'melodrama'),
('13948023', '13948031'): ('serie/soap', 'historisch'),
('13948023', '13948032'): ('serie/soap', 'waar gebeurt'),
('13948023', '13948033'): ('serie/soap', 'detectiveserie')}
self.new_cattrans[5] = {}
# humo.be genre translation table
self.source_cattrans[6] = {'nieuws' : (u'Nieuws/Actualiteiten', u''),
'current-affairs': (u'Nieuws/Actualiteiten', u'Actualiteiten'),
'magazine' : (u'Magazine', u''),
'reportage' : (u'Informatief', u'Reportage'),
'documentaire' : (u'Informatief', u'Documentaire'),
'talkshow' : (u'Talkshow', u''),
'reality' : (u'Amusement', u'Realityserie'),
'kinderen' : (u'jeugd', u''),
'animated-cartoon': (u'serie/soap', u'animatieserie'),
'serie' : (u'Serie/Soap', u''),
'miniserie' : (u'Serie/Soap', u''),
'soap' : (u'Serie/Soap', u'Soap'),
'film' : (u'Film', u''),
'tv-film' : (u'Film', u'TV Film'),
'movie-short' : (u'Film', u'Korte Film'),
'quiz' : (u'Amusement', u'Quiz'),
'spel' : (u'amusement', u'spelshow'),
'amusement' : (u'Amusement', u''),
'religion' : (u'Religieus', u''),
'muziek' : (u'Muziek', u''),
'kunst-cultuur' : (u'kunst en cultuur', u''),
'sports-football': (u'Sports', u'Voetbal'),
'sports-cycling' : (u'Sport', u'Wielrennen'),
'sports-formula-1-racing' : (u'Sport', u'Formule-1'),
'sports-tennis' : (u'Sport', u'Tennis'),
'sport' : (u'Sport', u''),
'andere' : (u'Overige', u'')}
self.new_cattrans[6] = {}
# vpro.nl genre translation table
self.source_cattrans[7] ={('g3011', ): ('jeugd', ''),
('g3012', ): ('film', ''),
('g3013', ): ('serie/soap', ''),
('g3014', ): ('sport',''),
('g3015', ): ('muziek', ''),
('g3016', ): ('amusement',''),
('g3017', ): ('informatief', ''),
('g301721', ): ('Nieuws/Actualiteiten', ''),
('g3017','g301721'): ('Nieuws/Actualiteiten', ''),
('g301724', ): (u'kunst/cultuur', u''),
('g3017', 'g301724'): (u'informatief', u'kunst/cultuur'),
('g301725'): (u'natuur', u''),
('g3017', 'g301725', ): (u'natuur', u''),
('g301726', ): (u'religieus', u''),
('g3017', 'g301726' ): (u'religieus', u''),
('g301727', ): (u'informatief, wetenschap', u''),
('g3017', 'g301727',): (u'informatief, wetenschap', u''),
('g3018', ): ('informatief', 'Documentaire')}
self.new_cattrans[7] = {}
# nieuwsblad.be genre translation table
self.source_cattrans[8] ={}
self.new_cattrans[8] = {}
# primo.eu genre translation table
self.source_cattrans[9] ={'actua': ('nieuws/actualiteiten', 'actua'),
'amusement': ('amusement', ''),
'documentaire': ('documentaire', ''),
'film': ('film', ''),
'kortfilm': ('film', ''),
'magazine': ('magazine', ''),
'muziek': ('muziek', ''),
'nieuws': ('nieuws/actualiteiten', 'nieuws'),
'reality-tv': ('amusement', 'realityprogramma'),
'religie': ('religieus', ''),
'reportage': ('nieuws/actualiteiten', 'reportage'),
'serie': ('serie/soap', ''),
'spel': ('amusement', 'spelshow'),
'sport': ('sport', ''),
'talkshow': ('amusement', 'talkshow'),
'varia': ('informatief', 'varia'),
'zwart/wit film': ('film', ''),
('serie', 'actiereeks'): (u'serie/soap', u'actieserie'),
('serie', 'advocatenreeks'): (u'serie/soap', u'advocatenserie'),
('serie', 'avonturenreeks'): (u'serie/soap', u'avonturenserie'),
('serie', 'detectivereeks'): (u'serie/soap', u'detectiveserie'),
('serie', 'dramareeks'): (u'serie/soap', u'dramaserie'),
('serie', 'fictiereeks'): (u'serie/soap', u'fictieserie'),