#!/bin/bash
#writen by guigoz

function choix_chaine {
	choix=`zenity --list --width=350 --height=340 \
		--title "Magneto Freebox" \
		--text="Choisir une chaine"\
		--column $"Chaine" \
		$"France 2" \
		$"France 3 national"\
		$"France 5" \
		$"Euronews" \
		$"Arte" \
		$"Direct 8" \
		$"W9" \
		$"NT1" \
		$"NRJ 12 5.1" \
		$"NRJ 12 Stéréo" \
		$"La Chaîne Parlementaire" \
		$"France 4" \
		$"BFM TV" \
		$"i>TELE" \
		$"Europe 2 TV" \
		$"Gulli" \
		$"RTL9" \
		$"AB 1" \
		$"TV5" \
		$"France ô" \
		$"Game One" \
		$"MTV France" \
		$"ZIK" \
		$"L'Equipe TV" \
		$"AB Moteurs" \
		$"Motors TV" \
		$"Bloomberg TV" \
		$"CNBC" \
		$"Sky News International" \
		$"KTO" \
		$"TFJ" \
		$"Beur TV" \
		$"Demain !" \
		$"Fashion TV" \
		$"Teleplaisance.org" \
		$"Liberty TV.com" \
		$"Freenews TV" \
		$"Best of Shopping" \
		$"M6 Boutique" \
		$"Astro Center TV" \
		$"TLM" \
		$"TLT" \
		$"TV7 Bordeaux" \
		$"TV8 Mont-Blanc" \
		$"TéléGrenoble" \
		$"Telif" \
		$"La Locale" \
		$"Normandie TV" \
		$"Télénantes/Nantes 7" \
		$"La Chaîne Marseille" \
		$"T.TV" \
		$"God TV" \
		$"Arte Allemand" \
		$"DW-TV" \
		$"ETB Sat" \
		$"Real Madrid TV" \
		$"RTPi" \
		$"Rai Uno" \
		$"Rai Due" \
		$"Rai Tre" \
		$"TV Polonia" \
		$"Bulgaria TV" \
		$"TV Romania" \
		$"RTR Planeta" \
		$"Adjara TV" \
		$"2M Maroc" \
		$"RTM Maroc" \
		$"Canal Algérie" \
		$"TV7 Tunisia" \
		$"TRT INT" \
		$"Kanal 7 INT" \
		$"Samanyolu TV" \
		$"Armenia TV" \
		$"Al Masriya" \
		$"Al jazeera" \
		$"Al Jazeera Children" \
		$"Phoenix Chinese News and Entertainment" \
		$"CCTV 4"`

	if echo "$choix" | grep $"France 2"; then
		chaine=201
		
	fi
	if echo "$choix" | grep $"France 3 national"; then
		chaine=202
		
	fi
	if echo "$choix" | grep $"France 5"; then
		chaine=203
		
	fi
	if echo "$choix" | grep $"Euronews"; then
		chaine=205
		
	fi
	if echo "$choix" | grep $"Arte"; then
		chaine=204
		
	fi
	if echo "$choix" | grep $"Direct 8"; then
		chaine=372
		
	fi
	if echo "$choix" | grep $"W9"; then
		chaine=373
		
	fi
	if echo "$choix" | grep $"NT1"; then
		chaine=374
		
	fi
	if echo "$choix" | grep $"NRJ 12 5.1"; then
		chaine=381
		
	fi
	if echo "$choix" | grep $"NRJ 12 Stéréo"; then
		chaine=382
		
	fi
	if echo "$choix" | grep $"La Chaîne Parlementaire"; then
		chaine=226
		
	fi
	if echo "$choix" | grep $"France 4"; then
		chaine=376
		
	fi
	if echo "$choix" | grep $"BFM TV"; then
		chaine=418
		
	fi
	if echo "$choix" | grep $"i>TELE"; then
		chaine=417
		
	fi
	if echo "$choix" | grep $"Europe 2 TV"; then
		chaine=416
		
	fi
	if echo "$choix" | grep $"Gulli"; then
		chaine=419
		
	fi
	if echo "$choix" | grep $"RTL9"; then
		chaine=210
		
	fi
	if echo "$choix" | grep $"AB 1"; then
		chaine=211
		
	fi
	if echo "$choix" | grep $"TV5"; then
		chaine=206
		
	fi
	if echo "$choix" | grep $"France ô"; then
		chaine=238
		
	fi
	if echo "$choix" | grep $"Game One"; then
		chaine=220
		
	fi
	if echo "$choix" | grep $"MTV France"; then
		chaine=219
		
	fi
	if echo "$choix" | grep $"ZIK"; then
		chaine=218
		
	fi
	if echo "$choix" | grep $"L'Equipe TV"; then
		chaine=209
		
	fi
	if echo "$choix" | grep $"AB Moteurs"; then
		chaine=222
		
	fi
	if echo "$choix" | grep $"Motors TV"; then
		chaine=216
		
	fi
	if echo "$choix" | grep $"Bloomberg TV"; then
		chaine=207
		
	fi
	if echo "$choix" | grep $"CNBC"; then
		chaine=208
		
	fi
	if echo "$choix" | grep $"Sky News International"; then
		chaine=355
		
	fi
	if echo "$choix" | grep $"KTO"; then
		chaine=223
		
	fi
	if echo "$choix" | grep $"TFJ"; then
		chaine=224
		
	fi
	if echo "$choix" | grep $"Beur TV"; then
		chaine=225
		
	fi
	if echo "$choix" | grep $"Demain !"; then
		chaine=227
		
	fi
	if echo "$choix" | grep $"Fashion TV"; then
		chaine=221
		
	fi
	if echo "$choix" | grep $"Teleplaisance.org"; then
		chaine=320
		
	fi
	if echo "$choix" | grep $"Liberty TV.com"; then
		chaine=215
		
	fi
	if echo "$choix" | grep $"Freenews TV"; then
		chaine=428
		
	fi
	if echo "$choix" | grep $"Best of Shopping"; then
		chaine=358
		
	fi
	if echo "$choix" | grep $"M6 Boutique"; then
		chaine=359
		
	fi
	if echo "$choix" | grep $"Astro Center TV"; then
		chaine=415
	fi

	if echo "$choix" | grep $"TLM"; then
		chaine=267
	fi

	if echo "$choix" | grep $"TLT"; then
		chaine=281
	fi

	if echo "$choix" | grep $"TV7"; then
		chaine=268
	fi

	if echo "$choix" | grep $"TV8 Mont-Blanc"; then
		chaine=319
	fi

	if echo "$choix" | grep $"TéléGrenoble"; then
		chaine=423
	fi

	if echo "$choix" | grep $"Telif"; then
		chaine=360
	fi
	if echo "$choix" | grep $"La Locale"; then
		chaine=363
	fi

	if echo "$choix" | grep $"Normandie TV"; then
		chaine=383
	fi

	if echo "$choix" | grep $"Télénantes/Nantes 7"; then
		chaine=389
	fi

	if echo "$choix" | grep $"La Chaîne Marseille"; then
		chaine=414
	fi

	if echo "$choix" | grep $"T.TV"; then
		chaine=385
	fi

	if echo "$choix" | grep $"God TV"; then
		chaine=386
	fi

	if echo "$choix" | grep $"Arte Allemand"; then
		chaine=270
	fi

	if echo "$choix" | grep $"DW-TV"; then
		chaine=312
	fi

	if echo "$choix" | grep $"ETB Sat"; then
		chaine=371
	fi

	if echo "$choix" | grep $"Real Madrid TV"; then
		chaine=387
	fi

	if echo "$choix" | grep $"RTPi"; then
		chaine=388
	fi

	if echo "$choix" | grep $"Rai Uno"; then
		chaine=309
	fi

	if echo "$choix" | grep $"Rai Due"; then
		chaine=314
	fi

	if echo "$choix" | grep $"Rai Tre"; then
		chaine=315
	fi

	if echo "$choix" | grep $"TV Polonia"; then
		chaine=278
	fi

	if echo "$choix" | grep $"Bulgaria TV"; then
		chaine=321
	fi

	if echo "$choix" | grep $"TV Romania"; then
		chaine=318
	fi

	if echo "$choix" | grep $"RTR Planeta"; then
		chaine=317
	fi

	if echo "$choix" | grep $"Adjara TV"; then
		chaine=316
	fi

	if echo "$choix" | grep $"2M Maroc"; then
		chaine=272
	fi

	if echo "$choix" | grep $"RTM Maroc"; then
		chaine=273
	fi

	if echo "$choix" | grep $"Canal Algérie"; then
		chaine=274
	fi

	if echo "$choix" | grep $"TV7 Tunisia"; then
		chaine=277
	fi

	if echo "$choix" | grep $"TRT INT"; then
		chaine=369
	fi

	if echo "$choix" | grep $"Kanal 7 INT"; then
		chaine=370
	fi

	if echo "$choix" | grep $"Samanyolu TV"; then
		chaine=391
	fi

	if echo "$choix" | grep $"Armenia TV"; then
		chaine=380
	fi

	if echo "$choix" | grep $"Al Masriya"; then
		chaine=275
	fi

	if echo "$choix" | grep $"Al jazeera"; then
		chaine=276
	fi

	if echo "$choix" | grep $"Al Jazeera Children"; then
		chaine=412
	fi

	if echo "$choix" | grep $"Phoenix Chinese News and Entertainment"; then
		chaine=266
	fi

	if echo "$choix" | grep $"CCTV 4"; then
		chaine=271
	fi

}

function path_select {
	path=`zenity --title="selectionner un repertoire de sauvegarde" --file-selection --directory`
        nom=`zenity --entry  --title "Magneto freebox" --text "Choisir le nom du fichier"`
}

choix_chaine
path_select
cd $path
zenity --progress --pulsate --auto-close --title "Magneto Freebox" --text $"Enregistrement en cours"&
vlc rtsp://mafreebox.freebox.fr/freeboxtv/$chaine  --intf dummy --sout file/ts:$nom.mpg 
killall zenity
killall vlc

