skingrapher.legtux.org

Ce site a été codé en PHP et construit en un seul fichier, qui pèse seulement 15k. Les données sont enregistrées au format XML dans un second fichier. Il ne contient aucun script javascript. Les sources sont disponibles ici.

Lire des flux radio avec mplayer

J'ai un fichier contenant une liste de flux de radios en ligne, placé dans $HOME et nommé radios-web. La liste contient 3 colonnes : le nom de la radio, son URL et un mot-clef.

Radio-yéyé http://listen.radionomy.com/radio-yeye.m3u rock
FeelingFloyd http://listen.radionomy.com/feelingfloyd.m3u pop psychedelic
Cathedral13 http://listen.radionomy.com/cathedral13.m3u punk
Always-80s http://listen.radionomy.com/always-80s.m3u punk
Peace-radio http://listen.radionomy.com/peace-radio.m3u psychedelic

J'ai créé un script qui me liste l'intégralité du fichier ou qui me ressort uniquement les radios selon un mot-clef choisi. Je peux ensuite, via ce script choisir une radio et l'écouter à travers mplayer ou un autre lecteur de son choix.

#!/usr/bin/zsh
#
# WR
#
# a script to choose web radio station in a list
# and play it in your fav media player
# (mplayer by default)
#
#=========================================================
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# Version 2, December 2004
#
# Copyright (C) 2004 Sam Hocevar
#
# Everyone is permitted to copy and distribute verbatim
# or modified copies of this license document, and
# changing it is allowed as long as the name is changed.
#
# DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
# TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION
# AND MODIFICATION.
# You just DO WHAT THE FUCK YOU WANT TO.
#
# This program is free software. It comes without
# any warranty, to the extent permitted by applicable law.
# You can redistribute it and/or modify it under the terms
# of the Do What The Fuck You Want To Public License,
# Version 2, as published by Sam Hocevar.
# See http://sam.zoy.org/wtfpl/COPYING for more details.
#==========================================================
#
# SYNOPSIS wr <string> [media player]
# argument 1 : string is a searched chain of characters
# in the list of webradios. 'all' or let it empty to see all webradios
# argument 2 : media player to use to play the web radio,
# if different from mplayer which is used by default
#

WR_LIST=$HOME/radios-web

if [[ $2 = '' ]]; then
IS_MPLAYER=$(which mplayer)
if [[ $IS_MPLAYER = 'mplayer not found' ]]; then
echo "Mplayer n'est pas installé.\n \
Veuillez spécifier un lecteur audio ou installez mplayer."
exit 0
else
PLAYR=mplayer
fi

else
PLAYR=$2

fi

if [[ $1 = 'all' || $1 == '' ]]; then
cat -n $WR_LIST
echo "tapez le numéro de ligne correspondant au lien désiré :"
read LIGNE
URL=$(\grep -n -e '' $WR_LIST | \grep -e "^$LIGNE:" | awk {'print $2'})
echo $URL
$PLAYR -playlist $URL

else
\grep -e $1 $WR_LIST | cat -n | awk {'print $1" "$2'}
echo "tapez le numéro de ligne correspondant au lien désiré :"
read LIGNE
URL=$(\grep -n -e '' $WR_LIST | \grep -e "^$LIGNE:" | awk {'print $2'})
$PLAYR -playlist $URL

fi

exit 0

Penser à rendre le script exécutable.

Édité le 14 août 2011

CLI - mplayer - script - zsh