Created
March 24, 2022 22:02
-
-
Save rodrigo-x/cb968335bd96cfac5328ce49a2bb657a to your computer and use it in GitHub Desktop.
tv_prog
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Dependencies: | |
# sudo apt install golang whiptail | |
# export GOPATH=$HOME/go | |
# export PATH=$PATH:$GOROOT/bin:$GOPATH/bin | |
# go get github.com/ericchiang/pup | |
############# | |
install_whiptail() { | |
if [ -f /etc/apt/sources.list ]; then | |
sudo apt install whiptail | |
fi | |
} | |
check_dependencies() { | |
status="$(dpkg-query -W --showformat='${db:Status-Status}' whiptail 2>&1)" | |
if [ ! "$status" = installed ]; then | |
clear | |
echo -e "\n Uma dependência não está instalada." | |
read -rp " Dejesa instalar? [s/n]: " resposta | |
if [ "$resposta" == "s" ]; then | |
clear | |
install_whiptail | |
else | |
exit 0 | |
fi | |
fi | |
} | |
check_dependencies | |
get_channel() { | |
CANAL=$(whiptail --inputbox "Quer saber a programacao de que canal?" 10 80 "globo" --title "Digite o canal com letras minúsculas:" 3>&1 1>&2 2>&3) | |
case $CANAL in | |
globo) CANAL=https://meuguia.tv/programacao/canal/GRD ;; | |
band) CANAL=https://meuguia.tv/programacao/canal/BAN ;; | |
mtv) CANAL=https://meuguia.tv/programacao/canal/MTV ;; | |
record) CANAL=https://meuguia.tv/programacao/canal/REC ;; | |
redetv) CANAL=https://meuguia.tv/programacao/canal/RTV ;; | |
tve) CANAL=https://meuguia.tv/programacao/canal/CUL ;; | |
gazeta) CANAL=https://meuguia.tv/programacao/canal/GAZ ;; | |
redevida) CANAL=https://meuguia.tv/programacao/canal/VDA ;; | |
sbt) CANAL=https://meuguia.tv/programacao/canal/SBT ;; | |
cnt) CANAL=https://meuguia.tv/programacao/canal/CNT ;; | |
telecine_premium) CANAL=https://meuguia.tv/programacao/canal/TC1 ;; | |
*) clear | |
echo -e "\n Canal não cadastrado ou escrito com letras maiúsculas." | |
exit 0 | |
;; | |
esac | |
} | |
get_channel | |
set_txt() { | |
curl -s "$CANAL" | pup '.lileft text{}' > horarios.txt | |
curl -s "$CANAL" | pup 'h2 text{}' > filmes.txt | |
paste horarios.txt filmes.txt > horarios_filmes.txt | |
rm -rf horarios.txt filmes.txt | |
if [ -f horarios_filmes.txt ]; then | |
clear | |
echo -e "\n Arquivo criado com sucesso." | |
fi | |
} | |
set_txt | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment