Project

General

Profile

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

thierry castelot, 2016-09-15 10:07

 
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
	"Talk show"							 => $TALKSHOW ,
101
    "Météo"								 => $WEATHER ,
102
    "Drame"								 => $MOVIE ,
103
    "Série fantastique"                  => $SF,
104
	"Magazine scientifique"              => $SCIENCE,
105
	"Magazine de télé-achat"             => $SHOPPING, 
106
	"Série réaliste"                     => $MOVIE,
107
	"Série hospitalière"                 => $MOVIE,
108
	"Jeu"               				 => $GAME ,
109
	"Magazine de la gastronomie"  		 => $COOKING, 
110
    "Journal"            				 => $NEWS ,
111
    "Feuilleton sentimental"      		 => $SOAP ,
112
    "Téléfilm romanesque"          		 => $SOAP ,
113
    "Feuilleton réaliste"         		 => $SOAP ,
114
    "Série sentimentale"          		 => $SOAP ,
115
    "Téléfilm de suspense"         		 => $THRILLER ,
116
    "Téléréalité"                		 => $VIP ,
117
    "Série de téléréalité"       		 => $VIP ,
118
    "Magazine du show-biz"      	     => $VIP ,
119
    "Série humoristique"         	     => $COMEDY ,
120
    "Téléfilm humoristique"       		 => $COMEDY ,
121
    "Série policière"                	 => $THRILLER ,
122
    "Comédie policière"                	 => $THRILLER ,
123
    "Magazine sportif"              	 => $SPORT_MAGAZINE,
124
    "Téléfilm dramatique"           	 => $MOVIE ,
125
    "Téléfilm humoristique"        		 => $COMEDY ,
126
    "Téléfilm sentimental"       	     => $SOAP ,
127
    "Téléfilm romanesque"          		 => $SOAP ,
128
    "Football"              		     => $FOOTBALL , 
129
    "Tennis"                		     => $TENNIS ,
130
    "Divertissement"       			     => $SHOW ,
131
	"Divertissement - humour"       	 => $SHOW ,
132
    "Multisports"                        => $SPORT ,
133
    "Sport"                              => $SPORT ,
134
    "Sports mécaniques"      		     => $SPORT_MOTOR ,
135
    "Comédie"                  			 => $COMEDY ,
136
    "Classique"                		     => $CLASSICAL,
137
    "Documentaire"     					 => $DOCUMENTARY ,
138
    "Magazine de la mode"  				 => $MAGAZINE ,
139
	"Animalier"             			 => $NATURE ,
140
    "Nature"              			     => $NATURE ,
141
    "Magazine animalier"  			     => $NATURE ,
142
    "Découvertes"          			     => $FOREIGN ,
143
    "Magazine religieux"   			     => $RELIGION ,
144
    "Sports"          					 => $SPORT ,
145
    "Voyage"           				   	 => $FOREIGN ,
146
    "Culture"           				 => $CULTURE ,
147
    "Magazine littéraire"		       	 => $LITERATURE ,
148
    "Magazine sportif"       		   	 => $SPORT_MAGAZINE ,
149
    "Téléfilm policier"    		         => $THRILLER ,
150
    "Magazine politique"   			     => $SOCIAL,
151
    "Série dramatique"				  	=> $MOVIE ,
152
    "Environnement"         		    => $NATURE ,
153
    "Opéra"             				=> $OPERA ,
154
    "Magazine de géopolitique"   		=> $DOCUMENTARY ,
155
    "Série de suspense"          		=> $THRILLER ,
156
    "Economie"                			=> $SOCIAL,
157
    "Film"                      		=> $FILM ,
158
    "Téléfilm catastrophe"      	    => $FILM ,
159
    "Magazine du cinéma"                => $FILM ,
160
    "Magazine du court métrage"         => $FILM ,
161
    "Magazine pornographique"           => $XXX ,
162
    "Magazine de charme"        	    => $XXX ,
163
    "Magazine culturel"          		=> $CULTURE ,
164
    "Cérémonie"                   		=> $SPORT_SPECIAL ,
165
    "Magazine de découvertes"     		=> $TRAVEL ,
166
    "Magazine de reportages"          	=> $TRAVEL ,
167
    "Magazine régional"                 => $TRAVEL ,
168
    "Magazine du multimédia"         	=> $EXPERIMENTAL_FILM ,
169
    "Magazine de services"            	=> $NEWS_MAGAZINE ,
170
    "Magazine du jeu vidéo"             => $HOBBIES ,
171
    "Magazine de la mer"   				=> $MAGAZINE ,
172
    "Magazine de société"  				=> $MAGAZINE ,
173
    "Magazine historique" 			    => $MAGAZINE ,
174
    "Magazine du consommateur"  	    => $ECONOMIC ,
175
    "Dessin animé"                      => $CARTOON ,
176
    "Série jeunesse"            		=> $CARTOON ,
177
    "Politique"                         => $SOCIAL,
178
    "Magazine culinaire"                => $COOKING, 
179
    "Ballet"                         	=> $MUSIC ,
180
    "Magazine musical"                  => $MUSIC ,
181
    "Formule 1"                         => $SPORT_MOTOR ,
182
    "Comédie sentimentale"              => $SOAP ,
183
	"Comédie dramatique"                => $SOAP ,
184
    "Athlétisme"                        => $ATHLETICS,
185
    "Magazine du jardinage"             => $GARDENING ,
186
    "Interview"                         => $DEBATE ,
187
    "Rugby"                  			=> $SPORT_TEAM ,
188
    "Gastronomie"                       => $COOKING, 
189
    "Magazine de la décoration"    		=> $HOBBIES ,
190
    "Indycar"                           => $SPORT_MOTOR ,
191
    "Automobilisme"                     => $SPORT_MOTOR ,
192
    "Magazine de la santé"              => $MEDECINE ,
193
    "Magazine médical"                  => $MEDECINE ,
194
    "Santé"                             => $MEDECINE ,
195
    "Débat"                             => $DEBATE ,
196
    "Sciences et technique"             => $TECHNOLOGY ,
197
    "Clip"          					=> $MUSIC ,
198
    "Clips"          					=> $MUSIC ,
199
    "Téléfilm musical"                  => $MUSIC ,
200
    "Téléfilm dramatique"               => $MOVIE ,
201
    "Concert"                           => $MUSIC ,
202
    "Théâtre"       					=> $CULTURE ,
203
    "Spectacle"                     	=> $SHOW ,
204
    "Fitness"           				=> $FITNESS ,
205
    "Magazine jeunesse"     			=> $KIDS ,
206
    "Emission jeunesse"    				=> $KIDS ,
207
	"Jeunesse"    						=> $KIDS ,
208
    "Série d'aventures"    				=> $ADVENTURE ,
209
    "Magazine d'actualité"              => $NEWS_MAGAZINE ,
210
    "Magazine d'information"            => $NEWS_MAGAZINE ,
211
    "Magazine de l'automobile"          => $MOTORING , 
212
    "Magazine de l'économie"            => $ECONOMIC ,
213
    "Série d'animation"                 => $CARTOON ,
214
    "Téléfilm d'animation"              => $CARTOON ,
215
    "Court métrage d'animation"         => $CARTOON ,
216
    "Film d'animation"                  => $CARTOON ,
217
    "Série d'action"         			=> $ADVENTURE ,
218
    "Magazine de l'art de vivre"        => $TRAVEL ,
219
    "Magazine de l'environnement"       => $NATURE ,
220
    "Téléfilm d'horreur"          		=> $SF ,
221
    "Série d'horreur"          			=> $SF ,
222
	"Téléfilm de science-fiction"		=> $SF ,
223
	"Téléfilm d'action"					=> $THRILLER ,
224
	"Téléfilm"							=> $MOVIE ,
225
	"Série de science-fiction"			=> $SF ,
226
	"Série historique"					=> $HISTORICAL ,
227
 ) ; 
228

    
229
my $PRE  = '<category lang=\"fr\">' ;
230
my $POST = '</category>'  ;
231

    
232
sub myfilter {
233
  my ($a) = @_;
234
  if ( exists $REPLACE{$a} ) {     
235
      return $REPLACE{$a} ;
236
  } else {
237
      print STDERR "Warning: Unmanaged category: '$a'\n" ;
238
      return $a ;
239
  }
240
}
241

    
242
while (<>) {
243
    my $line = $_ ;
244
    $line =~ s/($PRE)(.*)($POST)/"$1".myfilter("$2")."$3"/ge ;
245
    print $line;
246
} 
247

    
    (1-1/1)