Skip to content

Instantly share code, notes, and snippets.

@rodrigo-x
Last active March 3, 2021 18:16
Show Gist options
  • Save rodrigo-x/1ef3a3b5052cda9faa85fac08e0dfd0f to your computer and use it in GitHub Desktop.
Save rodrigo-x/1ef3a3b5052cda9faa85fac08e0dfd0f to your computer and use it in GitHub Desktop.
programação da TV
#!/usr/bin/env bash
clear
echo -e "\n\t Programação atual de um canal de TV"
echo -e "\n\t Obs: Globo = GRD, CNN, MTV, HBO\n"
read -p " Digite um canal com 3 letras: " canal
verificarResp() {
if [ -z "$canal" ]; then
clear
echo -e "\n\tDigite um canal.\n"
exit 0
fi
}
verificarResp
verificarWord() {
sizeCanal=${#canal}
if [[ "$sizeCanal" -ge "4" ]]; then
clear
echo -e "\n\tDigite somente 3 letras\n"
exit 0
fi
}
verificarWord
fazaLogica() {
programa=$(curl -s -X GET https://meuguia.tv/programacao/canal/$canal |
grep 'h2' | head -1 | tr -d '</h2>' | sed s'/^\t*//g')
horario=$(curl -s -X GET https://meuguia.tv/programacao/canal/$canal |
grep 'time' | head -1 | tr -d 'class=lleft tme</div>' | sed s'/^\t*..//g')
}
fazaLogica
msgbox() {
clear
echo -e "\n\tPassando agora o programa: $programa \n"
echo -e "\tHorário de início: $horario \n"
}
msgbox
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment