Project

General

Profile

RE: XMLTV, Kazer & French categories » cambia_categorias.pl

Nicolas Rioja, 2016-09-14 16:55

 
1
#!/share/CACHEDEV1_DATA/.qpkg/Optware/bin/perl -w
2

    
3
# ATENCION: Este es el script para ejecutarlo QNAP!!!
4
# Estas son las categorias (solo en Ingles) reconocidas por Tvheadend (ver epg.c) 
5
# Actualizado el 14/09/2016
6

    
7
open(LOG, ">>", "/share/CACHEDEV1_DATA/homes/nico/wg++/categorias/cat_log.txt")  or die "Can't open LOG file: $!";
8

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

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

    
27
my $SHOW              =    "Show / Game show";
28
my $GAME              =    "Game show / Quiz / Contest";
29
my $VARIETY           =    "Variety show";
30
my $TALKSHOW          =    "Talk show";
31

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

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

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

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

    
66
my $SOCIAL            =    "Social / Political issues / Economics";
67
my $MAGAZINE          =    "Magazines / Reports / Documentary";
68
my $ECONOMIC          =    "Economics / Social advisory";
69
my $VIP               =    "Remarkable people";
70

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

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

    
90
#
91
# A continuacion las equivalencias de las categorias de la EPG que obtengo con las de Tvheadend 
92
#
93
#
94
#
95

    
96
my %REPLACE=(
97
    "El Tiempo"        					=> $WEATHER ,
98
    "Acción y Aventuras"        		=> $ADVENTURE ,
99
    "Acción"							=> $THRILLER ,
100
    "Aventuras"							=> $ADVENTURE ,
101
    "Animación Adultos" 				=> $XXX ,
102
    "Animación"             			=> $CARTOON,
103
    "Automovilismo"           			=> $SPORT_MOTOR ,
104
    "Actualidad"     					=> $VARIETY ,
105
	"Artes Marciales"					=> $SPORT_SPECIAL ,
106
    "Atletismo"           				=> $ATHLETICS ,
107
    "Baloncesto"           				=> $SPORT_TEAM ,
108
    "Balonmano"							=> $SPORT_TEAM ,
109
    "Bélica"           					=> $ADVENTURE  ,
110
    "Bricolaje"							=> $HANDICRAF ,
111
    "Boxeo"								=> $SPORT ,
112
    "Biográficos"						=> $DOCUMENTARY  ,
113
    "Caza"           					=> $NATURE ,
114
    "Champions League"					=> $FOOTBALL ,
115
    "Ciencia y tecnología"				=> $TECHNOLOGY ,
116
    "Curso educativo"					=> $SCIENCE ,
117
    "Concursos"                			=> $GAME ,
118
    "Cultura"            				=> $CULTURE,
119
	"Cultural/Educativo"				=> $CULTURE ,
120
    "Cocina"          					=> $COOKING  ,
121
    "Cine"           					=> $MOVIE ,
122
	"Cine, Acción"						=> $THRILLER  ,
123
	"Cine, Acción y Aventuras"			=> $THRILLER  ,
124
	"Cine, Animación"					=> $MOVIE ,
125
	"Cine, Artes Marciales"				=> $MOVIE ,
126
	"Cine, Aventuras"					=> $THRILLER  ,
127
	"Cine, Bélica"						=> $MOVIE ,
128
    "Cine, Ciencia ficción"				=> $SF ,
129
	"Cine, Cine Negro"					=> $MOVIE ,
130
	"Cine, Comedia"						=> $COMEDY ,
131
	"Cine, Documental"					=> $DOCUMENTARY ,
132
	"Cine, Documentales"				=> $DOCUMENTARY ,
133
	"Cine, Drama"						=> $MOVIE ,
134
	"Cine, Erótica"						=> $XXX ,
135
	"Cine, Fantástico"					=> $SF ,
136
	"Cine, Histórico"					=> $HISTORICAL ,
137
	"Cine, Infantil / Familiar"			=> $ADVENTURE ,
138
	"Cine, Musical"						=> $SOAP ,
139
	"Cine, Romántica"					=> $ROMANCE ,
140
	"Cine, Suspense / Thriller"			=> $THRILLER ,
141
	"Cine, Terror"						=> $SF ,
142
	"Cine, Wéstern"						=> $ADVENTURE ,
143
	"Cine Negro"        				=> $MOVIE ,
144
    "Corazón"       					=> $VARIETY ,
145
    "Concierto"             			=> $MUSIC ,
146
	"Concurso"							=> $GAME ,
147
    "Comedia"           				=> $COMEDY,
148
    "Ciencia ficción"           		=> $SF  ,
149
    "Ciclismo"           				=> $SPORT ,
150
    "Cortometraje"						=> $EXPERIMENTAL_FILM ,
151
    "Divulgativo"						=> $NEWS_MAGAZINE ,
152
	"Deportes, Automovilismo"			=> $SPORT_MOTOR ,
153
	"Deportes, Balonmano"				=> $SPORT_TEAM ,
154
	"Deportes, Boxeo"					=> $SPORT ,
155
	"Deportes, Champions League"		=> $FOOTBALL ,
156
	"Deportes, Ciclismo"				=> $SPORT_SPECIAL ,
157
	"Deportes, Deportes náuticos"		=> $SPORT_WATER ,
158
	"Deportes, Documentales"			=> $SPORT_MAGAZINE ,
159
	"Deportes, Fútbol"					=> $FOOTBALL ,
160
	"Deportes, Golf"					=> $SPORT_SPECIAL ,
161
	"Deportes, Hípica"					=> $SPORT_SPECIAL ,
162
	"Deportes, Juegos Olímpicos"		=> $SPORT_SPECIAL ,
163
	"Deportes, Motociclismo"			=> $SPORT_MOTOR ,
164
	"Deportes, Otros deportes"			=> $SPORT ,
165
	"Deportes, Pesca"					=> $HOBBIES ,
166
	"Deportes, Póquer"					=> $GAME ,
167
	"Deportes, Voleibol"				=> $SPORT_TEAM ,
168
    "Drama"               				=> $MOVIE ,
169
    "Documental Viaje"          		=> $TRAVEL,
170
    "Documentaire"       				=> $DOCUMENTARY ,
171
    "Documental Actualidad"     		=> $DOCUMENTARY,
172
	"Documental Cine"					=> $DOCUMENTARY ,
173
    "Documental Historia"       		=> $DOCUMENTARY,
174
    "Documental Naturaleza y Animales"  => $NATURE ,
175
	"Docu-reality"						=> $MAGAZINE ,
176
    "Deportes"              			=> $SPORT ,
177
    "Dibujos Animados"           		=> $CARTOON ,
178
    "Documental Antropológico"          => $DOCUMENTARY  ,
179
    "Documental Biográfico"           	=> $DOCUMENTARY  ,
180
    "Documentales"           			=> $DOCUMENTARY  ,
181
    "Documental Arte y Espectáculos"    => $CULTURE  ,
182
    "Documental Ciencia y tecnología"   => $TECHNOLOGY ,
183
    "Documental"           				=> $DOCUMENTARY ,
184
    "Deportiva"           				=> $SPORT ,
185
    "Docu-Drama"           				=> $HISTORICAL ,
186
    "Deportes náuticos"					=> $SPORT_WATER ,
187
    "Deportes de invierno"				=> $SPORT_SPECIAL ,
188
    "Decoración"						=> $CULTURE ,
189
    "Debates"							=> $DEBATE , 
190
    "Economía"							=> $ECONOMIC ,
191
    "Entrevistas"						=> $INTERVIEW ,
192
	"Entretenimiento"					=> $VARIETY ,
193
    "Eróticas"							=> $XXX ,
194
    "Erótica"							=> $XXX ,
195
	"Especial"							=> $SPORT_SPECIAL ,
196
    "Fantástico"            			=> $SF  ,
197
    "Fantástica"           				=> $SF ,
198
    "Fútbol"         					=> $FOOTBALL ,
199
    "Fórmula 1"							=> $SPORT_MOTOR ,
200
	"Gastronómico"						=> $COOKING ,
201
    "Gimnasia"							=> $SPORT ,
202
	"Golf"								=> $SPORT_SPECIAL ,
203
    "Humor"           					=> $COMEDY ,
204
    "Histórico"							=> $HISTORICAL ,
205
    "Histórica"							=> $HISTORICAL ,
206
    "Hípica"							=> $SPORT ,
207
    "Informativos"						=> $NEWS ,
208
	"Informativos, Otros"				=> $NEWS ,
209
	"Información"						=> $NEWS ,
210
    "Infantil"           				=> $KIDS ,
211
	"Infantil, Dibujos Animados"		=> $KIDS ,
212
	"Infantil, Series"					=> $KIDS ,
213
    "Infantil / Familiar"           	=> $KIDS , 
214
    "Juvenil"							=> $KIDS ,
215
	"Juveniles"							=> $KIDS ,
216
    "Juegos Olímpicos"					=> $SPORT_SPECIAL ,
217
    "Judicial"							=> $SOCIAL ,
218
    "Literatura"						=> $LITERATURE ,
219
    "Lucha"								=> $SPORT ,
220
    "Magacín"           				=> $MAGAZINE ,
221
	"Magacín, Biográficos"				=> $MAGAZINE ,
222
	"Magacín, Magazines"				=> $MAGAZINE ,
223
	"Magacín, Ciencia y tecnología"		=> $TECHNOLOGY ,
224
	"Magacín, Musicales"				=> $MUSIC ,
225
	"Magacín, Otros"					=> $MAGAZINE ,
226
	"Magacín, Reality Show"				=> $VARIETY ,
227
	"Magacín, Religiosos"				=> $RELIGION ,
228
	"Magacín, Videoclips"				=> $MUSIC ,	
229
    "Magazines"							=> $MAGAZINE ,
230
	"Manga"								=> $KIDS_10_16 ,
231
    "Medio Ambiente"             		=> $DOCUMENTARY ,
232
    "Musicales"           				=> $MUSIC ,
233
    "Musical"							=> $OPERA ,
234
    "Moda"								=> $CULTURE ,
235
    "Motociclismo"           			=> $SPORT_MOTOR ,
236
    "Misterio"           				=> $THRILLER ,
237
    "Música popular"					=> $FOLK ,
238
	"Natación"							=> $SPORT_WATER ,
239
    "Naturaleza y animales"           	=> $NATURE ,
240
    "Noticias"           				=> $NEWS ,
241
	"Ocio y Aficiones"					=> $HOBBIES ,
242
    "Ópera"								=> $OPERA ,
243
    "Otros deportes"           			=> $SPORT,
244
    "Otros"           					=> 0 ,
245
    "Política"							=> $SOCIAL ,         
246
    "Parapsicología"					=> $MEDECINE ,
247
    "Póquer"							=> $GAME ,
248
    "Policíacas"                		=> $THRILLER  ,
249
    "Pesca"           					=> $NATURE ,
250
    "Programas"							=> $VARIETY ,
251
    "Profesiones"           			=> $THRILLER , 
252
    "Reportajes"						=> $NEWS_MAGAZINE ,
253
    "Romántica"							=> $ROMANCE ,
254
    "Reportaje Actualidad"				=> $NEWS_MAGAZINE ,
255
	"Reportaje Economía"				=> $ECONOMIC ,
256
    "Reportaje Sociológico"				=> $SOCIAL ,
257
    "Religion"           				=> $RELIGION ,
258
    "Reality Show"           			=> $VARIETY ,
259
    "Religiosos"						=> $RELIGION ,
260
	"Rugby"								=> $SPORT_TEAM ,
261
    "Sorteos"							=> $GAME ,
262
	"Serie"								=> $SHOW ,
263
	"Serie documental"					=> $DOCUMENTARY ,
264
    "Series"              				=> $SHOW ,
265
	"Series, Acción y aventuras"		=> $SHOW ,
266
	"Series, Animación Adultos"			=> $KIDS_10_16 ,
267
	"Series, Comedia"					=> $SHOW ,
268
	"Series, Ciencia ficción"			=> $SF  ,
269
	"Series, Docu-Drama"				=> $SHOW ,
270
	"Series, Drama"						=> $SHOW ,
271
	"Series, Eróticas"					=> $XXX ,
272
	"Series, Fantástica"				=> $SHOW ,
273
	"Series, Juvenil"					=> $KIDS_10_16 ,
274
	"Series, Manga"						=> $KIDS_10_16 ,
275
	"Series, Misterio"					=> $SHOW ,
276
	"Series, Policíacas"				=> $SHOW ,
277
	"Series, Profesiones"				=> $SHOW ,
278
	"Series, Telenovela"				=> $SHOW ,
279
	"Series, Todas"						=> $SHOW ,	
280
    "Salud y belleza"					=> $FITNESS ,
281
	"Sin clasificar"					=> 0 ,
282
    "Sucesos"							=> $NEWS ,
283
    "Suspense / Thriller"           	=> $THRILLER  ,
284
	"Talent Show"						=> $GAME ,
285
	"Talk Shows"						=> $TALKSHOW ,
286
    "Telenovela"						=> $ROMANCE ,
287
    "Televisión"						=> $VARIETY ,
288
    "Terror"           					=> $SF , 
289
    "Teatro"							=> $MOVIE , 
290
    "Tenis"           					=> $TENNIS ,
291
    "Teletienda"           				=> $SHOPPING ,
292
    "Todas"								=> 0 ,
293
    "Toros"								=> $SPORT_SPECIAL ,	
294
    "Viajes"             				=> $TRAVEL ,
295
    "Videoclips"           				=> $MUSIC ,
296
	"Voleibol"							=> $SPORT_TEAM ,
297
    "Variedades"           				=> $VARIETY ,
298
    "Wéstern"           				=> $ADVENTURE ,
299
    "Waterpolo"							=> $SPORT_WATER ,
300
	"Zapping"							=> $HOBBIES ,
301
	
302
	
303

    
304
    
305
 ) ; 
306

    
307
my $PRE  = '<category lang=\"es\">' ;
308
my $POST = '</category>'  ;
309

    
310
sub myfilter {
311
  my ($a) = @_;
312
  if ( exists $REPLACE{$a} ) {     
313
      return $REPLACE{$a} ;
314
  } else {
315
open(FH, '>', '/share/CACHEDEV1_DATA/homes/nico/wg++/categorias/temporal.txt') or die "cannot open file";
316
select FH;
317
  if ( ! exists $BAD{$a} ) {
318
      print STDERR "ATENCION: Agregar categoria al script: '$a'\n" ;
319
	  print LOG    "ATENCION: Agregar categoria al script: '$a'\n" ;
320
  # Record in BAD map so next error won´t produce a message
321
      $BAD{$a} = 1 ;
322
      return $a ;
323
  }
324
}
325

    
326
while (<>) {
327
    my $line = $_ ;
328
    $line =~ s/($PRE)(.*)($POST)/"$1".myfilter("$2")."$3"/ge ;
329
    print $line;
330
}
    (1-1/1)