le script affiche les chaines disponibles et autorise le filtrage du non de la chaine :
$ tv "france 2"
recherche des chaines: france 2
--------------------
France 24 Arab (standard) rtsp://mafreebox.freebox.fr/fbxtv_pub/stream?namespace=1&service=741&flavour=sd
France 2 HD (TNT) rtsp://192.168.0.12/fbxdvb/stream?tsid=5&nid=8442&sid=1282&frontend=1
France 2 (auto) rtsp://mafreebox.freebox.fr/fbxtv_pub/stream?namespace=1&service=201
France 2 (bas débit) rtsp://mafreebox.freebox.fr/fbxtv_pub/stream?namespace=1&service=201&flavour=ld
France 24 (standard) rtsp://mafreebox.freebox.fr/fbxtv_pub/stream?namespace=1&service=739&flavour=sd
France 2 (standard) rtsp://mafreebox.freebox.fr/fbxtv_pub/stream?namespace=1&service=201&flavour=sd
France 2 (HD) rtsp://mafreebox.freebox.fr/fbxtv_pub/stream?namespace=1&service=201&flavour=hd
France 2 (TNT) rtsp://192.168.0.12/fbxdvb/stream?tsid=1&nid=8442&sid=257&frontend=1
France 24 English (standard) rtsp://mafreebox.freebox.fr/fbxtv_pub/stream?namespace=1&service=740&flavour=sd
si le copier coller l'url n'est pas bon, lorsque qu'il n'y a plus qu'une seule réponse , il lance automatiquement le player :
$ tv "france 2 (TNT)"
recherche des chaines: france 2 (TNT)
--------------------
France 2 (TNT) rtsp://192.168.0.12/fbxdvb/stream?tsid=1&nid=8442&sid=257&frontend=1
--------------------
lancer le player France 2 (TNT)
VLC media player 2.2.1 Terry Pratchett (Weatherwax) (revision 2.2.1-0-ga425c42)
source du fichier script "tv" (mettre droits executable)
#!/usr/bin/env bash
# lancer une chaine de télévision FreeBox
player='vlc' # ou mplayer ...
filtre="$1"
echo "recherche des chaines: ${cBOLD}${filtre}${cNULL}"
fdatas='/tmp/tv.m3u'
declare -A chaines
cGREEN="\\033[0;32m"
cBOLD="\\033[1m"
cNULL="\\033[0m"
# recuperer les chaines
curl -s "http://mafreebox.freebox.fr/freeboxtv/playlist.m3u" | sed 1d | grep -i "$filtre" -A 2 | while read n ; do read v; echo -e "$n-$v"; done > "$fdatas"
#mettre les chaines dans un tableau
function readtvlist {
local fdatas="$1"
chaines=()
if [ ! -f "$fdatas" ]; then
echo "ERREUR: fichier "$fdatas" des chaines inexistant"
exit 1
fi
while read line; do
label=$(echo "$line" |cut -d '-' -f2 |sed "s/ //")
url=$(echo "$line" |cut -d '-' -f3 | grep "^rtsp:")
[[ -n "$url" && -n "label" ]] && chaines["${label}"]="$url"
done <"${fdatas}"
}
readtvlist "$fdatas"
echo "--------------------"
for chaine in "${!chaines[@]}"; do
echo -e "${cBOLD}$chaine${cNULL}\t ${chaines[$chaine]}"
done
echo "--------------------"
if [ "${#chaines[*]}" -eq 1 ]; then
for chaine in "${!chaines[@]}"; do
echo "lancer le player $chaine"
$player "${chaines[$chaine]}" &
done
fi