#!/usr/bin/perl -w

#
# The categories recognized by tvheadend (see epg.c) 
#  

my $MOVIE             =    "Movie / Drama";
my $THRILLER          =    "Detective / Thriller";
my $ADVENTURE         =    "Adventure / Western / War";
my $SF                =    "Science fiction / Fantasy / Horror";
my $COMEDY            =    "Comedy";
my $SOAP              =    "Soap / Melodrama / Folkloric";
my $ROMANCE           =    "Romance";
my $HISTORICAL        =    "Serious / Classical / Religious / Historical movie / Drama";
my $XXX               =    "Adult movie / Drama";

my $NEWS              =    "News / Current affairs";
my $WEATHER           =    "News / Weather report";
my $NEWS_MAGAZINE     =    "News magazine";
my $DOCUMENTARY       =    "Documentary";
my $DEBATE            =    "Discussion / Interview / Debate";
my $INTERVIEW         =    $DEBATE ;

my $SHOW              =    "Show / Game show";
my $GAME              =    "Game show / Quiz / Contest";
my $VARIETY           =    "Variety show";
my $TALKSHOW          =    "Talk show";

my $SPORT             =    "Sports";
my $SPORT_SPECIAL     =    "Special events (Olympic Games; World Cup; etc.)";
my $SPORT_MAGAZINE    =    "Sports magazines";
my $FOOTBALL          =    "Football / Soccer";
my $TENNIS            =    "Tennis / Squash";
my $SPORT_TEAM        =    "Team sports (excluding football)";
my $ATHLETICS         =    "Athletics";
my $SPORT_MOTOR       =    "Motor sport";
my $SPORT_WATER       =    "Water sport";

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

my $MUSIC             =    "Music / Ballet / Dance";
my $ROCK_POP          =    "Rock / Pop";
my $CLASSICAL         =    "Serious music / Classical music";
my $FOLK              =    "Folk / Traditional music";
my $JAZZ              =    "Jazz";
my $OPERA             =    "Musical / Opera";

my $CULTURE           =    "Arts / Culture (without music)";
my $PERFORMING        =    "Performing arts";
my $FINE_ARTS         =    "Fine arts";
my $RELIGION          =    "Religion";
my $POPULAR_ART       =    "Popular culture / Traditional arts";
my $LITERATURE        =    "Literature";
my $FILM              =    "Film / Cinema";
my $EXPERIMENTAL_FILM =    "Experimental film / Video";
my $BROADCASTING      =    "Broadcasting / Press";

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

my $SCIENCE           =    "Education / Science / Factual topics";
my $NATURE            =    "Nature / Animals / Environment";
my $TECHNOLOGY        =    "Technology / Natural sciences";
my $DIOLOGY           =    $TECHNOLOGY;
my $MEDECINE          =    "Medicine / Physiology / Psychology";
my $FOREIGN           =    "Foreign countries / Expeditions";
my $SPIRITUAL         =    "Social / Spiritual sciences";
my $FURTHER_EDUCATION =    "Further education";
my $LANGUAGES         =    "Languages";

my $HOBBIES           =    "Leisure hobbies";
my $TRAVEL            =    "Tourism / Travel";
my $HANDICRAF         =    "Handicraft";
my $MOTORING          =    "Motoring";
my $FITNESS           =    "Fitness and health";
my $COOKING           =    "Cooking";
my $SHOPPING          =    "Advertisement / Shopping";
my $GARDENING         =    "Gardening";

#
# This is the 
#
#
#

my %REPLACE=(
    
    "Émission"          				 => 0 ,
    "fin"               				 => 0 ,
    "Fin des programmes" 				 => 0 ,
    "loterie"           				 => 0 ,
	"programme indéterminé" 			 => 0 ,
    "autre"                              => 0 ,
	"Divers"							=> 0 ,
	"Education"							=> $EDUCATIONAL ,
    "pop %26 rock"                      	=> $ROCK_POP ,
	"documentaire : rock-pop"                      	=> $ROCK_POP ,
    "Série TV"                           => $MOVIE ,
    "Série Télé"                         => $MOVIE ,
    "Série"                              => $MOVIE ,  
	"feuilleton réaliste"                              => $MOVIE ,  
	"série hospitalière"                              => $MOVIE , 
	"série carcérale"                              => $MOVIE , 
    "Emission spéciale"                  => 0 ,
	"Marathon"							=> $ATHLETICS ,
	"talk show"							 => $TALKSHOW ,
    "Talk-show"							 => $TALKSHOW ,
    "météo"								 => $WEATHER ,
    "Drame"								 => $MOVIE ,
    "Série fantastique"                  => $SF ,
	"film : fantastique"                  => $SF ,
	"téléfilm d'épouvante"                  => $SF ,
	"film d'horreur"                  => $SF ,
	"film fantastique"                  => $SF ,
	"téléfilm d'horreur"                  => $SF ,
	"série d'horreur"                  => $SF ,
	"série de science-fiction"                  => $SF ,
	"magazine scientifique"              => $SCIENCE ,
	"documentaire : sciences et technique"              => $SCIENCE ,	
	"magazine de télé-achat"             => $SHOPPING , 
    "Publicité"                          => $SHOPPING , 
	"COMMERCIAL"						=> $SHOPPING , 
	"Série réaliste"                     => $MOVIE ,
	"Série hospitalière"                 => $MOVIE ,
    "Mélodrame"                          => $MOVIE ,
	"série réaliste"                          => $SOAP ,
	"jeu"               				 => $GAME ,
	"magazine de la gastronomie"  		 => $COOKING , 
	"documentaire : gastronomie"  		 => $COOKING , 
	
	"magazine culinaire"  		 => $COOKING , 
    "journal"            				 => $NEWS ,
    "Actualité"            				 => $NEWS ,
    "Information"            			 => $NEWS ,
    "feuilleton sentimental"      		 => $ROMANCE ,
	"TELENOVELA"						=> $SOAP ,
    "Téléfilm romanesque"          		 => $ROMANCE  ,
    "Feuilleton réaliste"         		 => $SOAP ,
    "Série sentimentale"          		 => $ROMANCE  ,
	 "téléfilm sentimental"          		 => $ROMANCE  ,
	 "film : comédie sentimentale"          		 => $ROMANCE  , 
    "Téléfilm de suspense"         		 => $THRILLER ,
	"Film noir"							=> $THRILLER ,
	"film : thriller"							=> $THRILLER ,
	"film policier"							=> $THRILLER ,
	"série judiciaire"							=> $THRILLER ,
	"série policière"							=> $THRILLER ,
	"série politique"							=> $THRILLER ,
	"film d'espionnage"							=> $THRILLER ,
    "téléréalité"                		 => $VIP ,
    "Série de téléréalité"       		 => $VIP ,
    "Magazine du show-biz"      	     => $VIP ,
	"documentaire : téléréalité"      	     => $DOCUMENTARY ,
    "Série humoristique"         	     => $COMEDY ,
	"série à sketches"         	     => $COMEDY ,
    "Téléfilm humoristique"       		 => $COMEDY ,
    "Comédie satirique"                  => $COMEDY , 
    "Humour"                             => $COMEDY , 
	"Film à sketches"					 => $COMEDY , 
	"Comédie de moeurs"					=> $COMEDY , 
	"film : comédie"					=> $COMEDY , 
	"série burlesque"					=> $COMEDY , 
	"téléfilm humoristique"					=> $COMEDY ,
	"divertissement-humour"					=> $COMEDY ,
	"série humoristique"					=> $COMEDY ,
	"humour"					=> $COMEDY ,
    "Série policière"                	 => $THRILLER ,
    "Comédie policière"                	 => $THRILLER ,
	"téléfilm policier"                	 => $THRILLER ,
	"film : policier"                	 => $THRILLER ,
    "Magazine sportif"              	 => $SPORT_MAGAZINE ,
    "jt sport"                           => $SPORT_MAGAZINE ,
	"magazine sportif"                           => $SPORT_MAGAZINE ,
	"documentaire : sport"                           => $SPORT_MAGAZINE ,
    "Téléfilm dramatique"           	 => $MOVIE ,
	"film : drame"           	 => $MOVIE ,
    "Téléfilm humoristique"        		 => $COMEDY ,
    "Série à sketches"                   => $COMEDY ,
    "Téléfilm sentimental"       	     => $ROMANCE ,
    "Téléfilm romanesque"          		 => $ROMANCE ,
    "Comédie romantique"                 => $ROMANCE ,
	"série sentimentale"                 => $ROMANCE ,
	"film : comédie romantique"          => $ROMANCE ,
    "Feuilleton"                         => $SOAP ,
    "football"              		     => $FOOTBALL , 
	 "sport : football"              		     => $FOOTBALL , 
    "Tennis"                		     => $TENNIS ,
    "divertissement"       			     => $SHOW ,
	"Divertissement - humour"       	 => $SHOW ,
    "Divertissement-humour"              => $SHOW ,
    "Gala"                               => $SHOW ,
    "one man show"                       => $SHOW ,
    "Multisports"                        => $SPORT ,
	"Patinage artistique"				=> $SPORT ,
	"Ski"								=> $SPORT ,
	"Hockey sur glace"					=> $SPORT ,
	"Trial"								=> $SPORT ,
	"Danse sportive"					=> $SPORT ,
	"Sports de glisse"					=> $SPORT ,
    "Sport"                              => $SPORT ,
    "e-sport"                            => $SPORT ,
	"sport : e-sport"                            => $SPORT ,
    "Golf"                               => $SPORT ,
    "Basket-ball"                        => $SPORT ,
    "Equitation"                         => $SPORT ,
    "Boxe"                               => $SPORT ,
    "Hockey sur gazon"                   => $SPORT ,
    "Football américain"                 => $SPORT ,
    "Rugby à XIII"                       => $SPORT ,
    "Handball"                           => $SPORT ,
    "Baseball"                           => $SPORT ,
    "Gymnastique rythmique"              => $SPORT ,
    "Badminton"                          => $SPORT ,
    "Gymnastique artistique"             => $SPORT ,
    "BMX"                                => $SPORT ,
    "Skate-board"                        => $SPORT ,
    "VTT"                               => $SPORT ,
    "Voltige aérienne"                   => $SPORT ,
    "Sports extrêmes"                   => $SPORT ,
    "Roller"                            => $SPORT ,
    "Sports fun"                         => $SPORT ,
    "Escalade"                          => $SPORT ,
    "Kick-boxing"                       => $SPORT ,
    "Lutte"                              => $SPORT ,
    "Arts martiaux"                      => $SPORT ,
    "Boxe thaï"                         => $SPORT ,
    "Karaté"                            => $SPORT ,
    "MMA"                                => $SPORT ,
    "Ju jitsu"                          => $SPORT ,
    "Sports de combat"                  => $SPORT ,
    "Sumo"                              => $SPORT ,
	"Cyclisme"							=> $SPORT ,
	"Curling"							=> $SPORT ,
	"Taekwondo"							=> $SPORT ,
	"Gymnastique"						=> $SPORT ,
	"Snowboard"							=> $SPORT ,
	"Tennis de table"					=> $SPORT ,
	"Voile"								=> $SPORT ,
	"sport : tennis"								=> $SPORT ,
	"sport : hockey sur glace"								=> $SPORT ,
	"sport : golf"								=> $SPORT ,
	"magazine hippique"								=> $SPORT ,
	"sport : cyclisme"								=> $SPORT ,
	"trail"								=> $SPORT ,
	"pétanque"								=> $SPORT ,
	"sport : boxe"								=> $SPORT ,
	"multisports"								=> $SPORT ,
	"trail"								=> $SPORT ,
	"sport : rugby"								=> $SPORT ,
	"sports de glisse"								=> $SPORT ,
	"kick-boxing"								=> $SPORT ,
	"triathlon"								=> $SPORT ,
	"sport : futsal"								=> $SPORT ,
	"sport : snowboard"								=> $SPORT ,
	"sport : ski"								=> $SPORT ,
	"sport : volley-ball"								=> $SPORT ,
	"sport : pétanque"								=> $SPORT ,
	"sport : trail"								=> $SPORT ,
	"sport : judo"								=> $SPORT ,
	"cyclisme"								=> $SPORT ,
	"sport : multisports"								=> $SPORT ,
    "Surf"                               => $SPORT_WATER ,
    "Plongeon"                          => $SPORT_WATER ,
    "Canoë-kayak"                       => $SPORT_WATER ,
    "Wakeboard"                         => $SPORT_WATER ,
	"Natation"							=> $SPORT_WATER ,
	"sports nautiques"							=> $SPORT_WATER ,
    "sports mécaniques"      		     => $SPORT_MOTOR ,
    "Motocross"                          => $SPORT_MOTOR ,
    "Magazine de la moto"               => $SPORT_MOTOR ,
    "Enduro"                             => $SPORT_MOTOR ,
    "Motocross freestyle"                => $SPORT_MOTOR ,
    "Speedway"                           => $SPORT_MOTOR ,
	"Moto2"								=> $SPORT_MOTOR ,
	"Moto"								=> $SPORT_MOTOR ,
	"sport : rallye"								=> $SPORT_MOTOR ,
	"magazine de l'automobile"								=> $SPORT_MOTOR ,
	"Trail"								=> $SPORT ,
    "Comédie"                  			 => $COMEDY ,
    "classique"                		     => $CLASSICAL ,
	"Musique classique"					=> $CLASSICAL ,
    "Documentaire"     					 => $DOCUMENTARY ,
	"documentaire : géopolitique"     					 => $DOCUMENTARY ,
	"documentaire : justice"     					 => $DOCUMENTARY ,
	 "documentaire : musique"     					 => $DOCUMENTARY ,
	"film : documentaire"     					 => $DOCUMENTARY ,
    "magazine de la mode"  				 => $MAGAZINE ,
	"magazine du cinéma"  				 => $MAGAZINE ,
	"magazine historique"  				 => $MAGAZINE ,
	"magazine régional"  				 => $MAGAZINE ,
	"magazine de l'art de vivre"  				 => $MAGAZINE ,
	"magazine du show-biz"  				 => $MAGAZINE ,
	"magazine de la décoration"  				 => $MAGAZINE ,
	"magazine de découvertes"  				 => $MAGAZINE ,
	"MAGAZINE"							=> $MAGAZINE ,
	"magazine musical"                           => $MAGAZINE ,
	"Emission"                           => $MAGAZINE ,
	"magazine de reportages"                           => $MAGAZINE ,
	"magazine judiciaire"                           => $MAGAZINE ,
	"magazine du consommateur"                           => $MAGAZINE ,
	"magazine de services"                           => $MAGAZINE ,
	"Animalier"             			 => $NATURE ,
    "Nature"              			     => $NATURE ,
    "magazine animalier"  			     => $NATURE ,
	"documentaire : animalier"  			     => $NATURE ,
	"Chasse"							=> $NATURE ,
	"magazine de l'environnement"							=> $NATURE ,
    "Découvertes"          			     => $FOREIGN ,
    "Magazine du tourisme"               => $FOREIGN ,
    "magazine religieux"   			     => $RELIGION ,
	"Religions"							=> $RELIGION ,
	"documentaire : religions"							=> $RELIGION ,
    "Sports"          					 => $SPORT ,
    "Voyage"           				   	 => $FOREIGN ,
    "Culture"           				 => $CULTURE ,
    "Pièce de théâtre"                  => $CULTURE ,
	"documentaire : culture"                  => $CULTURE ,
    "magazine littéraire"		       	 => $LITERATURE ,
	"Lettres"							=> $LITERATURE ,
    "Magazine sportif"       		   	 => $SPORT_MAGAZINE ,
    "téléfilm policier"    		         => $THRILLER ,
	 "téléfilm de suspense"    		         => $THRILLER ,
    "Magazine politique"   			     => $SOCIAL ,
	"emission politique"   			     => $SOCIAL ,
	"Série Autre"						=> $MOVIE ,
	"Série politique"					=> $SOCIAL ,
    "Série dramatique"				  	=> $MOVIE ,
    "Drame psychologique"               => $MOVIE ,
	"Drame social"						=> $MOVIE ,
	"film : comédie dramatique"						=> $MOVIE ,
	"film : comédie dramatique"						=> $MOVIE ,
	"téléfilm dramatique"						=> $MOVIE ,
	"série dramatique"						=> $MOVIE ,
    "Environnement"         		    => $NATURE ,
    "opéra"             				=> $OPERA ,
	"Opéra comique"						=> $OPERA ,	
	"Opéra bouffe"						=> $OPERA ,
    "Magazine de géopolitique"   		=> $DOCUMENTARY ,
    "Film documentaire"                 => $DOCUMENTARY ,
    "Série documentaire"                => $DOCUMENTARY ,
    "Reportage"                          => $DOCUMENTARY ,
    "Making-of"                          => $DOCUMENTARY ,
	"fiction"							 => $DOCUMENTARY ,
	"DOC"								=> $DOCUMENTARY ,
	"documentaire : environnement"								=> $DOCUMENTARY ,
	"documentaire : justice"								=> $DOCUMENTARY ,
	"documentaire : aventures"								=> $DOCUMENTARY ,
	"film documentaire"								=> $DOCUMENTARY ,
	"documentaire : sciences et technique" => $DOCUMENTARY ,
	"documentaire : histoire" => $DOCUMENTARY ,
	"documentaire : civilisations" => $DOCUMENTARY ,
	"documentaire : cinéma" => $DOCUMENTARY ,
    "Série de suspense"          		=> $THRILLER ,
    "Economie"                			=> $SOCIAL ,
	"magazine de société"               => $SOCIAL ,
	"documentaire : société"            => $SOCIAL ,
	"documentaire : politique"            => $SOCIAL ,
	"magazine de géopolitique"            => $SOCIAL ,
	"magazine politique"            => $SOCIAL ,
    "Programme court"                   => $EXPERIMENTAL_FILM ,
	"Contemporain"						=> $EXPERIMENTAL_FILM ,
    "Court-métrage"                      => $EXPERIMENTAL_FILM ,
    "Court métrage"                      => $EXPERIMENTAL_FILM ,
    "Prog court"                         => $EXPERIMENTAL_FILM ,
    "Court métrage dramatique"          => $EXPERIMENTAL_FILM ,
	"magazine du court métrage"          => $EXPERIMENTAL_FILM ,
	"Film d'espionnage"                 => $FILM ,				
    "Moyen-métrage"                     => $FILM ,
    "Film"                      		=> $FILM ,
	"FILM"								=> $FILM ,
    "Films"                      		=> $FILM ,
	"film : autre"                      		=> $FILM ,
	"film : divers"                      		=> $FILM ,
    "film"                      		=> $FILM ,	
    "Téléfilm catastrophe"      	    => $FILM ,
	"Film catastrophe"					=> $FILM ,
    "Magazine du cinéma"                => $FILM ,
    "Magazine du court métrage"         => $FILM ,
    "Cinéma"                            => $FILM ,
    "Magazine pornographique"           => $XXX ,
    "magazine de charme"        	    => $XXX ,
    "Film pornographique"               => $XXX ,
    "Film érotique"                     => $XXX ,
    "Série érotique"                    => $XXX ,
    "Téléfilm pornographique"           => $XXX ,
    "téléfilm érotique"                 => $XXX ,
    "magazine culturel"          		=> $CULTURE ,
	"Beaux-arts"						=> $CULTURE ,
    "cérémonie"                   		=> $SPORT_SPECIAL ,
	"emission spéciale"                   		=> $SPORT_SPECIAL ,
    "Magazine de découvertes"     		=> $TRAVEL ,
	"Magazine de reportages"          	=> $TRAVEL ,
    "documentaire : découvertes"          	=> $TRAVEL ,
    "Magazine régional"                 => $TRAVEL ,
	"magazine du tourisme"                 => $TRAVEL ,
	"documentaire : voyage"                 => $TRAVEL ,
    "Magazine du multimédia"         	=> $EXPERIMENTAL_FILM ,
    "Magazine de services"            	=> $NEWS_MAGAZINE ,
	"magazine d'actualité"            	=> $NEWS_MAGAZINE ,
	"magazine d'information"            	=> $NEWS_MAGAZINE ,
    "Magazine du jeu vidéo"             => $HOBBIES ,
	"magazine des loisirs"             => $HOBBIES ,
    "magazine de la mer"   				=> $MAGAZINE ,
    "Magazine de l'armée"               => $MAGAZINE ,
    "Magazine"                          => $MAGAZINE ,
    "Magazine de société"  				=> $MAGAZINE ,
    "Magazine historique" 			    => $MAGAZINE ,
	"Magazine judiciaire"				=> $MAGAZINE ,
    "Magazine du consommateur"  	    => $ECONOMIC ,
	"magazine de l'économie"  	    => $ECONOMIC ,
	"documentaire : economie"  	    => $ECONOMIC ,
    "Dessin animé"                      => $CARTOON ,
    "Série jeunesse"            		=> $CARTOON ,
	"DESSIN ANIME"						=> $CARTOON ,
	"jeunesse : dessin animé d'animation"						=> $CARTOON ,
	"jeunesse : dessin animé jeunesse"						=> $CARTOON ,
	"jeunesse : dessin animé manga"						=> $CARTOON ,
	"téléfilm d'animation"						=> $CARTOON ,
	"film d'animation"						=> $CARTOON ,
    "Politique"                         => $SOCIAL ,
    "Magazine culinaire"                => $COOKING, 
    "Ballet"                         	=> $MUSIC ,
    "Magazine musical"                  => $MUSIC ,
	"Danse"								=> $MUSIC ,
	"JINGLE"							=> $MUSIC ,
	"clips"							=> $MUSIC ,
	"rap"							=> $MUSIC ,
    "Formule 1"                         => $SPORT_MOTOR ,
    "Comédie sentimentale"              => $SOAP ,
	"Comédie dramatique"                => $SOAP ,
    "Athlétisme"                        => $ATHLETICS ,
    "magazine du jardinage"             => $GARDENING ,
    "Interview"                         => $DEBATE ,
	"débat parlementaire"                         => $DEBATE ,
    "Rugby"                  			=> $SPORT_TEAM ,
    "Gastronomie"                       => $COOKING , 
	"Série culinaire"					=> $COOKING , 
    "Magazine de la décoration"    		=> $HOBBIES ,
    "Indycar"                           => $SPORT_MOTOR ,
    "Automobilisme"                     => $SPORT_MOTOR ,
    "magazine de la santé"              => $MEDECINE ,
    "Magazine médical"                  => $MEDECINE ,
    "Santé"                             => $MEDECINE ,
	"documentaire : santé"                  => $MEDECINE ,
    "débat"                             => $DEBATE ,
	"interview"                             => $DEBATE ,
    "Sciences et technique"             => $TECHNOLOGY ,
	"musical"							=> $MUSIC ,
	"world music"							=> $MUSIC ,
	"blues %26 soul"							=> $MUSIC ,
    "Clip"          					=> $MUSIC ,
    "Musique"          					=> $MUSIC ,
    "Clips"          					=> $MUSIC ,
    "Téléfilm musical"                  => $MUSIC ,
    "Série musicale"                    => $MUSIC ,
    "Téléfilm dramatique"               => $MOVIE ,
    "Concert"                           => $MUSIC ,
    "Emission musicale"                 => $MUSIC ,
    "Film musical"                      => $MUSIC ,
    "Comédie musicale"                  => $MUSIC ,
    "Pop &amp; Rock"                    => $MUSIC ,
    "World Music"                       => $MUSIC ,
	"Rap"								=> $MUSIC ,
    "Emission sportive"                 => $SPORT_MAGAZINE ,
    "Théâtre"       					=> $CULTURE ,
    "Spectacle"                     	=> $SHOW ,
    "fitness"           				=> $FITNESS ,
	"emission du bien-être"           				=> $FITNESS ,
    "magazine jeunesse"     			=> $KIDS ,
    "Enfants"                           => $KIDS ,
    "Emission jeunesse"    				=> $KIDS ,
	"Jeunesse"    						=> $KIDS ,
    "film pour la jeunesse"             => $KIDS ,
    "téléfilm pour la jeunesse"         => $KIDS ,
	"téléfilm féerique"         => $KIDS ,
	"série jeunesse"         => $KIDS ,
    "série d'aventures"    				=> $ADVENTURE ,
    "Aventures"                         => $ADVENTURE ,
	"film : guerre"                         => $ADVENTURE ,
	"film : aventure"                         => $ADVENTURE ,
	"film d'aventures"                         => $ADVENTURE ,
	"téléfilm d'aventures"				 => $ADVENTURE ,
	"Série de guerre"					 => $ADVENTURE ,
	"série d'action"					 => $ADVENTURE ,
	"film d'action"					 => $ADVENTURE ,
	"film de kung-fu"					 => $ADVENTURE ,
	"téléfilm catastrophe"					 => $ADVENTURE ,
	"film catastrophe"					 => $ADVENTURE ,
	"téléfilm d'action"					 => $ADVENTURE ,
    "Péplum"                            => $HISTORICAL ,
	"Film historique"					=> $HISTORICAL ,
	"téléfilm historique"					=> $HISTORICAL ,
    "Magazine d'actualité"              => $NEWS_MAGAZINE ,
    "Magazine d'information"            => $NEWS_MAGAZINE ,
    "Magazine de l'automobile"          => $MOTORING , 
    "Magazine de l'économie"            => $ECONOMIC ,
    "série d'animation"                 => $CARTOON ,
    "Animation"                         => $CARTOON ,
	"jeunesse : dessin animé"           => $CARTOON ,
    "Téléfilm d'animation"              => $CARTOON ,
    "Court métrage d'animation"         => $CARTOON ,
    "Film d'animation"                  => $CARTOON ,
    "Dessin animé manga"                => $CARTOON ,
    "Dessin animé jeunesse"             => $CARTOON ,
    "Dessin animé Dessin animé"         => $CARTOON ,
    "Série d'action"         			=> $ADVENTURE ,
    "film de guerre"                    => $ADVENTURE ,
	"Guerre"							=> $ADVENTURE ,
    "Film d'aventures"                  => $ADVENTURE ,
	"Aventure"							 => $ADVENTURE ,
    "Film de suspense"                  => $THRILLER ,
    "Comédie noire"                     => $THRILLER ,
    "Thriller"                          => $THRILLER ,
    "Film policier"                     => $THRILLER ,
    "Thriller politique"                => $THRILLER ,
    "Magazine de l'art de vivre"        => $TRAVEL ,
    "Magazine de l'environnement"       => $NATURE ,
	"documentaire : nature"       => $NATURE ,
    "Téléfilm d'horreur"          		=> $SF ,
    "Série d'horreur"          			=> $SF ,
	"téléfilm de science-fiction"		=> $SF ,
    "Film de science-fiction"           => $SF ,
    "Film fantastique"                  => $SF ,
    "Film d'horreur"                    => $SF ,
	"Téléfilm fantastique"				=> $SF ,
	"Film d'épouvante"					=> $SF ,
	"série fantastique"					=> $SF ,
	"film de science-fiction"					=> $SF ,
	"Téléfilm d'action"					=> $ADVENTURE ,
    "Film d'action"					    => $ADVENTURE ,
    "Western"                           => $ADVENTURE ,
	"Téléfilm"							=> $MOVIE ,
	"SERIAL"							=> $MOVIE ,
	"Série de science-fiction"			=> $SF ,
	"Série historique"					=> $HISTORICAL ,
    "Biographie"                        => $HISTORICAL ,
    "Civilisations"                     => $HISTORICAL ,
    "Histoire"                          => $HISTORICAL ,
	"Téléfilm historique"				=> $HISTORICAL ,
	"Téléfilm biographique"				=> $HISTORICAL ,
	"film historique"				=> $HISTORICAL ,
    "Société"                           => $SOCIAL , 
    "Magazine de l'emploi"              => $SOCIAL , 
    "Justice"                           => $SOCIAL , 
    "Conférence"                        => $DEBATE ,
    "variétés"                          => $VARIETY ,
    "Emission du bien-être"             => $FITNESS ,
    "Magazine de la nature"             => $NATURE , 
    "Magazine de la pêche"              => $NATURE , 
	"Pêche"								=> $NATURE , 
    "Magazine des loisirs"              => $HOBBIES ,
    "Voyance"                           => $SPIRITUAL ,
    "Médias"                            => $BROADCASTING ,    
	"documentaire : beaux-arts"			=> $FINE_ARTS  ,
	"magazine des beaux-arts"			=> $FINE_ARTS  ,
	"jazz"								=> $JAZZ  ,
 ) ; 

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

sub myfilter {
  my ($a) = @_;
  if ( exists $REPLACE{$a} ) {     
      return $REPLACE{$a} ;
  } else {
      print STDERR "Warning: Unmanaged category: '$a'\n" ;
      return $a ;
  }
}

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

