Project

General

Profile

RE: XMLTV, Kazer & French categories » category-filter.pl

thierry castelot, 2017-09-12 11:32

 
1
#!/usr/bin/perl -w
2

    
3
#
4
# The categories recognized by tvheadend (see epg.c) 
5
#  
6

    
7
my $MOVIE             =    "Movie / Drama";
8
my $THRILLER          =    "Detective / Thriller";
9
my $ADVENTURE         =    "Adventure / Western / War";
10
my $SF                =    "Science fiction / Fantasy / Horror";
11
my $COMEDY            =    "Comedy";
12
my $SOAP              =    "Soap / Melodrama / Folkloric";
13
my $ROMANCE           =    "Romance";
14
my $HISTORICAL        =    "Serious / Classical / Religious / Historical movie / Drama";
15
my $XXX               =    "Adult movie / Drama";
16

    
17
my $NEWS              =    "News / Current affairs";
18
my $WEATHER           =    "News / Weather report";
19
my $NEWS_MAGAZINE     =    "News magazine";
20
my $DOCUMENTARY       =    "Documentary";
21
my $DEBATE            =    "Discussion / Interview / Debate";
22
my $INTERVIEW         =    $DEBATE ;
23

    
24
my $SHOW              =    "Show / Game show";
25
my $GAME              =    "Game show / Quiz / Contest";
26
my $VARIETY           =    "Variety show";
27
my $TALKSHOW          =    "Talk show";
28

    
29
my $SPORT             =    "Sports";
30
my $SPORT_SPECIAL     =    "Special events (Olympic Games; World Cup; etc.)";
31
my $SPORT_MAGAZINE    =    "Sports magazines";
32
my $FOOTBALL          =    "Football / Soccer";
33
my $TENNIS            =    "Tennis / Squash";
34
my $SPORT_TEAM        =    "Team sports (excluding football)";
35
my $ATHLETICS         =    "Athletics";
36
my $SPORT_MOTOR       =    "Motor sport";
37
my $SPORT_WATER       =    "Water sport";
38

    
39
my $KIDS              =    "Children's / Youth programs";
40
my $KIDS_0_5          =    "Pre-school children's programs";
41
my $KIDS_6_14         =    "Entertainment programs for 6 to 14";
42
my $KIDS_10_16        =    "Entertainment programs for 10 to 16";
43
my $EDUCATIONAL       =    "Informational / Educational / School programs";
44
my $CARTOON           =    "Cartoons / Puppets";
45

    
46
my $MUSIC             =    "Music / Ballet / Dance";
47
my $ROCK_POP          =    "Rock / Pop";
48
my $CLASSICAL         =    "Serious music / Classical music";
49
my $FOLK              =    "Folk / Traditional music";
50
my $JAZZ              =    "Jazz";
51
my $OPERA             =    "Musical / Opera";
52

    
53
my $CULTURE           =    "Arts / Culture (without music)";
54
my $PERFORMING        =    "Performing arts";
55
my $FINE_ARTS         =    "Fine arts";
56
my $RELIGION          =    "Religion";
57
my $POPULAR_ART       =    "Popular culture / Traditional arts";
58
my $LITERATURE        =    "Literature";
59
my $FILM              =    "Film / Cinema";
60
my $EXPERIMENTAL_FILM =    "Experimental film / Video";
61
my $BROADCASTING      =    "Broadcasting / Press";
62

    
63
my $SOCIAL            =    "Social / Political issues / Economics";
64
my $MAGAZINE          =    "Magazines / Reports / Documentary";
65
my $ECONOMIC          =    "Economics / Social advisory";
66
my $VIP               =    "Remarkable people";
67

    
68
my $SCIENCE           =    "Education / Science / Factual topics";
69
my $NATURE            =    "Nature / Animals / Environment";
70
my $TECHNOLOGY        =    "Technology / Natural sciences";
71
my $DIOLOGY           =    $TECHNOLOGY;
72
my $MEDECINE          =    "Medicine / Physiology / Psychology";
73
my $FOREIGN           =    "Foreign countries / Expeditions";
74
my $SPIRITUAL         =    "Social / Spiritual sciences";
75
my $FURTHER_EDUCATION =    "Further education";
76
my $LANGUAGES         =    "Languages";
77

    
78
my $HOBBIES           =    "Leisure hobbies";
79
my $TRAVEL            =    "Tourism / Travel";
80
my $HANDICRAF         =    "Handicraft";
81
my $MOTORING          =    "Motoring";
82
my $FITNESS           =    "Fitness and health";
83
my $COOKING           =    "Cooking";
84
my $SHOPPING          =    "Advertisement / Shopping";
85
my $GARDENING         =    "Gardening";
86

    
87
#
88
# This is the 
89
#
90
#
91
#
92

    
93
my %REPLACE=(
94
    
95
    "Émission"          				 => 0,
96
    "Fin"               				 => 0,
97
    "Fin des programmes" 				 => 0 ,
98
    "Loterie"           				 => 0 ,
99
	"Programme indéterminé" 			 => 0 ,
100
    "Autre"                              => 0 ,
101
    "Série TV"                           => $MOVIE ,
102
    "Série Télé"                         => $MOVIE ,
103
    "Série"                              => $MOVIE ,  
104
    "Emission spéciale"                  => 0 ,
105
	"Talk show"							 => $TALKSHOW ,
106
    "Talk-show"							 => $TALKSHOW ,
107
    "Météo"								 => $WEATHER ,
108
    "Drame"								 => $MOVIE ,
109
    "Série fantastique"                  => $SF,
110
	"Magazine scientifique"              => $SCIENCE,
111
	"Magazine de télé-achat"             => $SHOPPING, 
112
    "Publicité"                          => $SHOPPING, 
113
	"Série réaliste"                     => $MOVIE,
114
	"Série hospitalière"                 => $MOVIE,
115
    "Mélodrame"                          => $MOVIE,
116
	"Jeu"               				 => $GAME ,
117
	"Magazine de la gastronomie"  		 => $COOKING, 
118
    "Journal"            				 => $NEWS ,
119
    "Actualité"            				 => $NEWS ,
120
    "Information"            			 => $NEWS ,
121
    "Feuilleton sentimental"      		 => $SOAP ,
122
    "Téléfilm romanesque"          		 => $ROMANCE  ,
123
    "Feuilleton réaliste"         		 => $SOAP ,
124
    "Série sentimentale"          		 => $ROMANCE  ,
125
    "Téléfilm de suspense"         		 => $THRILLER ,
126
    "Téléréalité"                		 => $VIP ,
127
    "Série de téléréalité"       		 => $VIP ,
128
    "Magazine du show-biz"      	     => $VIP ,
129
    "Série humoristique"         	     => $COMEDY ,
130
    "Téléfilm humoristique"       		 => $COMEDY ,
131
    "Comédie satirique"                  => $COMEDY , 
132
    "Humour"                             => $COMEDY , 
133
    "Série policière"                	 => $THRILLER ,
134
    "Comédie policière"                	 => $THRILLER ,
135
    "Magazine sportif"              	 => $SPORT_MAGAZINE,
136
    "JT sport"                           => $SPORT_MAGAZINE,
137
    "Téléfilm dramatique"           	 => $MOVIE ,
138
    "Téléfilm humoristique"        		 => $COMEDY ,
139
    "Série à sketches"                   => $COMEDY ,
140
    "Téléfilm sentimental"       	     => $ROMANCE ,
141
    "Téléfilm romanesque"          		 => $ROMANCE ,
142
    "Comédie romantique"                 => $ROMANCE ,
143
    "Feuilleton"                         => $SOAP ,
144
    "Football"              		     => $FOOTBALL , 
145
    "Tennis"                		     => $TENNIS ,
146
    "Divertissement"       			     => $SHOW ,
147
	"Divertissement - humour"       	 => $SHOW ,
148
    "Divertissement-humour"              => $SHOW ,
149
    "Gala"                               => $SHOW ,
150
    "One man show"                       => $SHOW ,
151
    "Multisports"                        => $SPORT ,
152
    "Sport"                              => $SPORT ,
153
    "e-sport"                            => $SPORT ,
154
    "Golf"                               => $SPORT ,
155
    "Basket-ball"                        => $SPORT ,
156
    "Equitation"                         => $SPORT ,
157
    "Boxe"                               => $SPORT ,
158
    "Hockey sur gazon"                   => $SPORT ,
159
    "Football américain"                 => $SPORT ,
160
    "Rugby à XIII"                       => $SPORT ,
161
    "Handball"                           => $SPORT ,
162
    "Baseball"                           => $SPORT ,
163
    "Gymnastique rythmique"              => $SPORT ,
164
    "Badminton"                          => $SPORT ,
165
    "Gymnastique artistique"             => $SPORT ,
166
    "BMX"                                => $SPORT ,
167
    "Skate-board"                        => $SPORT ,
168
    "VTT"                               => $SPORT ,
169
    "Voltige aérienne"                   => $SPORT ,
170
    "Sports extrêmes"                   => $SPORT ,
171
    "Roller"                            => $SPORT ,
172
    "Sports fun"                         => $SPORT ,
173
    "Escalade"                          => $SPORT ,
174
    "Kick-boxing"                       => $SPORT ,
175
    "Lutte"                              => $SPORT ,
176
    "Arts martiaux"                      => $SPORT ,
177
    "Boxe thaï"                         => $SPORT ,
178
    "Karaté"                            => $SPORT ,
179
    "MMA"                                => $SPORT ,
180
    "Ju jitsu"                          => $SPORT ,
181
    "Sports de combat"                  => $SPORT ,
182
    "Sumo"                              => $SPORT ,
183
    "Surf"                               => $SPORT_WATER ,
184
    "Plongeon"                          => $SPORT_WATER ,
185
    "Canoë-kayak"                       => $SPORT_WATER ,
186
    "Wakeboard"                         => $SPORT_WATER ,
187
    "Sports mécaniques"      		     => $SPORT_MOTOR ,
188
    "Motocross"                          => $SPORT_MOTOR ,
189
    "Magazine de la moto"               => $SPORT_MOTOR ,
190
    "Enduro"                             => $SPORT_MOTOR ,
191
    "Motocross freestyle"                => $SPORT_MOTOR ,
192
    "Speedway"                           => $SPORT_MOTOR ,
193
    "Comédie"                  			 => $COMEDY ,
194
    "Classique"                		     => $CLASSICAL,
195
    "Documentaire"     					 => $DOCUMENTARY ,
196
    "Magazine de la mode"  				 => $MAGAZINE ,
197
    "Emission"                           => $MAGAZINE ,
198
	"Animalier"             			 => $NATURE ,
199
    "Nature"              			     => $NATURE ,
200
    "Magazine animalier"  			     => $NATURE ,
201
    "Découvertes"          			     => $FOREIGN ,
202
    "Magazine du tourisme"               => $FOREIGN ,
203
    "Magazine religieux"   			     => $RELIGION ,
204
    "Sports"          					 => $SPORT ,
205
    "Voyage"           				   	 => $FOREIGN ,
206
    "Culture"           				 => $CULTURE ,
207
    "Pièce de théâtre"                  => $CULTURE ,
208
    "Magazine littéraire"		       	 => $LITERATURE ,
209
    "Magazine sportif"       		   	 => $SPORT_MAGAZINE ,
210
    "Téléfilm policier"    		         => $THRILLER ,
211
    "Magazine politique"   			     => $SOCIAL,
212
    "Série dramatique"				  	=> $MOVIE ,
213
    "Drame psychologique"               => $MOVIE ,
214
    "Environnement"         		    => $NATURE ,
215
    "Opéra"             				=> $OPERA ,
216
    "Magazine de géopolitique"   		=> $DOCUMENTARY ,
217
    "Film documentaire"                 => $DOCUMENTARY ,
218
    "Série documentaire"                => $DOCUMENTARY ,
219
    "Reportage"                          => $DOCUMENTARY ,
220
    "Making-of"                          => $DOCUMENTARY ,
221
    "Série de suspense"          		=> $THRILLER ,
222
    "Economie"                			=> $SOCIAL,
223
    "Programme court"                   => $EXPERIMENTAL_FILM ,
224
    "Court-métrage"                      => $EXPERIMENTAL_FILM ,
225
    "Court métrage"                      => $EXPERIMENTAL_FILM ,
226
    "Prog court"                         => $EXPERIMENTAL_FILM ,
227
    "Court métrage dramatique"          => $EXPERIMENTAL_FILM ,
228
    "Moyen-métrage"                     => $FILM ,
229
    "Film"                      		=> $FILM ,
230
    "Films"                      		=> $FILM ,
231
    "Téléfilm catastrophe"      	    => $FILM ,
232
    "Magazine du cinéma"                => $FILM ,
233
    "Magazine du court métrage"         => $FILM ,
234
    "Cinéma"                            => $FILM ,
235
    "Magazine pornographique"           => $XXX ,
236
    "Magazine de charme"        	    => $XXX ,
237
    "Film pornographique"               => $XXX ,
238
    "Film érotique"                     => $XXX ,
239
    "Série érotique"                    => $XXX ,
240
    "Téléfilm pornographique"           => $XXX ,
241
    "Téléfilm érotique"                 => $XXX ,
242
    "Magazine culturel"          		=> $CULTURE ,
243
    "Cérémonie"                   		=> $SPORT_SPECIAL ,
244
    "Magazine de découvertes"     		=> $TRAVEL ,
245
    "Magazine de reportages"          	=> $TRAVEL ,
246
    "Magazine régional"                 => $TRAVEL ,
247
    "Magazine du multimédia"         	=> $EXPERIMENTAL_FILM ,
248
    "Magazine de services"            	=> $NEWS_MAGAZINE ,
249
    "Magazine du jeu vidéo"             => $HOBBIES ,
250
    "Magazine de la mer"   				=> $MAGAZINE ,
251
    "Magazine de l'armée"               => $MAGAZINE ,
252
    "Magazine"                          => $MAGAZINE ,
253
    "Magazine de société"  				=> $MAGAZINE ,
254
    "Magazine historique" 			    => $MAGAZINE ,
255
    "Magazine du consommateur"  	    => $ECONOMIC ,
256
    "Dessin animé"                      => $CARTOON ,
257
    "Série jeunesse"            		=> $CARTOON ,
258
    "Politique"                         => $SOCIAL,
259
    "Magazine culinaire"                => $COOKING, 
260
    "Ballet"                         	=> $MUSIC ,
261
    "Magazine musical"                  => $MUSIC ,
262
    "Formule 1"                         => $SPORT_MOTOR ,
263
    "Comédie sentimentale"              => $SOAP ,
264
	"Comédie dramatique"                => $SOAP ,
265
    "Athlétisme"                        => $ATHLETICS,
266
    "Magazine du jardinage"             => $GARDENING ,
267
    "Interview"                         => $DEBATE ,
268
    "Rugby"                  			=> $SPORT_TEAM ,
269
    "Gastronomie"                       => $COOKING, 
270
    "Magazine de la décoration"    		=> $HOBBIES ,
271
    "Indycar"                           => $SPORT_MOTOR ,
272
    "Automobilisme"                     => $SPORT_MOTOR ,
273
    "Magazine de la santé"              => $MEDECINE ,
274
    "Magazine médical"                  => $MEDECINE ,
275
    "Santé"                             => $MEDECINE ,
276
    "Débat"                             => $DEBATE ,
277
    "Sciences et technique"             => $TECHNOLOGY ,
278
    "Clip"          					=> $MUSIC ,
279
    "Musique"          					=> $MUSIC ,
280
    "Clips"          					=> $MUSIC ,
281
    "Téléfilm musical"                  => $MUSIC ,
282
    "Série musicale"                    => $MUSIC ,
283
    "Téléfilm dramatique"               => $MOVIE ,
284
    "Concert"                           => $MUSIC ,
285
    "Emission musicale"                 => $MUSIC ,
286
    "Film musical"                      => $MUSIC ,
287
    "Comédie musicale"                   => $MUSIC ,
288
    "Pop & Rock"                        => $MUSIC ,
289
    "World Music"                       => $MUSIC ,
290
    "Emission sportive"                 => $SPORT_MAGAZINE ,
291
    "Théâtre"       					=> $CULTURE ,
292
    "Spectacle"                     	=> $SHOW ,
293
    "Fitness"           				=> $FITNESS ,
294
    "Magazine jeunesse"     			=> $KIDS ,
295
    "Enfants"                           => $KIDS ,
296
    "Emission jeunesse"    				=> $KIDS ,
297
	"Jeunesse"    						=> $KIDS ,
298
    "Film pour la jeunesse"             => $KIDS ,
299
    "Téléfilm pour la jeunesse"         => $KIDS ,
300
    "Série d'aventures"    				=> $ADVENTURE ,
301
    "Aventures"                         => $ADVENTURE ,
302
    "Péplum"                            => $HISTORICAL ,
303
    "Magazine d'actualité"              => $NEWS_MAGAZINE ,
304
    "Magazine d'information"            => $NEWS_MAGAZINE ,
305
    "Magazine de l'automobile"          => $MOTORING , 
306
    "Magazine de l'économie"            => $ECONOMIC ,
307
    "Série d'animation"                 => $CARTOON ,
308
    "Animation"                         => $CARTOON ,
309
    "Téléfilm d'animation"              => $CARTOON ,
310
    "Court métrage d'animation"         => $CARTOON ,
311
    "Film d'animation"                  => $CARTOON ,
312
    "Dessin animé manga"                => $CARTOON ,
313
    "Dessin animé jeunesse"             => $CARTOON ,
314
    "Dessin animé Dessin animé"         => $CARTOON ,
315
    "Série d'action"         			=> $ADVENTURE ,
316
    "Film de guerre"                    => $ADVENTURE ,
317
    "Film d'aventures"                  => $ADVENTURE ,
318
    "Film de suspense"                  => $THRILLER ,
319
    "Comédie noire"                     => $THRILLER ,
320
    "Thriller"                          => $THRILLER ,
321
    "Film policier"                     => $THRILLER ,
322
    "Thriller politique"                => $THRILLER ,
323
    "Magazine de l'art de vivre"        => $TRAVEL ,
324
    "Magazine de l'environnement"       => $NATURE ,
325
    "Téléfilm d'horreur"          		=> $SF ,
326
    "Série d'horreur"          			=> $SF ,
327
	"Téléfilm de science-fiction"		=> $SF ,
328
    "Film de science-fiction"           => $SF ,
329
    "Film fantastique"                  => $SF ,
330
    "Film d'horreur"                    => $SF ,
331
	"Téléfilm d'action"					=> $ADVENTURE ,
332
    "Film d'action"					    => $ADVENTURE ,
333
    "Western"                           => $ADVENTURE ,
334
	"Téléfilm"							=> $MOVIE ,
335
	"Série de science-fiction"			=> $SF ,
336
	"Série historique"					=> $HISTORICAL ,
337
    "Biographie"                        => $HISTORICAL ,
338
    "Civilisations"                     => $HISTORICAL ,
339
    "Histoire"                          => $HISTORICAL ,
340
    "Société"                           => $SOCIAL , 
341
    "Magazine de l'emploi"              => $SOCIAL , 
342
    "Justice"                           => $SOCIAL , 
343
    "Conférence"                        => $DEBATE ,
344
    "Variétés"                          => $VARIETY ,
345
    "Emission du bien-être"             => $FITNESS ,
346
    "Magazine de la nature"             => $NATURE , 
347
    "Magazine de la pêche"              => $NATURE , 
348
    "Magazine des loisirs"              => $HOBBIES ,
349
    "Voyance"                           => $SPIRITUAL ,
350
    "Médias"                            => $BROADCASTING ,          
351
 ) ; 
352

    
353
my $PRE  = '<category lang=\"fr\">' ;
354
my $POST = '</category>'  ;
355

    
356
sub myfilter {
357
  my ($a) = @_;
358
  if ( exists $REPLACE{$a} ) {     
359
      return $REPLACE{$a} ;
360
  } else {
361
      print STDERR "Warning: Unmanaged category: '$a'\n" ;
362
      return $a ;
363
  }
364
}
365

    
366
while (<>) {
367
    my $line = $_ ;
368
    $line =~ s/($PRE)(.*)($POST)/"$1".myfilter("$2")."$3"/ge ;
369
    print $line;
370
} 
371

    
(2-2/2)