1
0
mirror of https://github.com/fenix-soft/gr_podcast.git synced 2024-12-27 15:42:43 +01:00
gr_podcast/gr3

77 lines
1.9 KiB
Plaintext
Raw Normal View History

2020-11-10 14:44:22 +01:00
#!/bin/bash
#
#
####################################################################################
2021-12-19 17:40:16 +01:00
# script che recupera l'ultimo podcast del gr3
2020-11-10 14:44:22 +01:00
#
2022-02-15 14:25:02 +01:00
#V:2.1 alpha_debug_mode 15 FEBBRAIO 2022
2020-11-10 14:44:22 +01:00
#
2021-12-19 17:40:16 +01:00
# dipendenze: curl,jq,cat,wget
2020-11-10 14:44:22 +01:00
#
2021-12-19 17:40:16 +01:00
# log: cambio api rai e dominio
2020-11-10 14:44:22 +01:00
####################################################################################
# set global variable
2021-12-19 17:40:16 +01:00
gr3api="https://www.raiplaysound.it/programmi/gr3.json"
grbase="https://www.raiplaysound.it"
2020-11-10 14:44:22 +01:00
ag="Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/56.0"
# remove old jason data
rm ./data/gr3.json
2021-12-19 17:40:16 +01:00
#rm ./data/Lgr3.json
2020-11-10 14:44:22 +01:00
# get jason data
curl -A "$ag" "$gr3api" -o data/gr3.json
echo " "
2021-12-19 17:40:16 +01:00
echo " "
2020-11-10 14:44:22 +01:00
echo "get data api... done!"
echo " "
# extract jason data of the last podcast
2021-12-19 17:40:16 +01:00
dataT=`cat ./data/gr3.json | jq -r '."block" | ."cards" | .[0] | ."downloadable_audio" | ."title"'`
2020-11-10 14:44:22 +01:00
echo " "
2021-12-19 17:40:16 +01:00
echo "extract data... find.."
echo " "
echo " "
echo podcast_title: $dataT
2020-11-10 14:44:22 +01:00
echo " "
2021-12-19 17:40:16 +01:00
Lpodcast=`cat ./data/gr3.json | jq -r '."block" | ."cards" | .[0] | ."downloadable_audio" | ."url"'`
2020-11-10 14:44:22 +01:00
echo " "
2021-12-19 17:40:16 +01:00
echo podcast_url: $Lpodcast
2020-11-10 14:44:22 +01:00
echo " "
# extract time and date onair podcast
2021-12-19 17:40:16 +01:00
ora=`cat ./data/gr3.json | jq -r '."block" | ."cards" | .[0] | ."create_time"'`
2020-11-10 14:44:22 +01:00
Ora=`echo $ora | sed -e 's/\ /\n/g' | grep ":"| sed -e 's/\:/\_/g'`
2021-12-19 17:40:16 +01:00
data=`cat ./data/gr3.json | jq -r '."block" | ."cards" | .[0] | ."create_date"'`
2020-11-10 14:44:22 +01:00
Data=`echo $data | sed -e 's/\//\-/g'`
echo " "
2021-12-19 17:40:16 +01:00
echo log_podcast_creation: $Data $Ora
2020-11-10 14:44:22 +01:00
echo " "
echo " "
# download podcast
2021-12-19 17:40:16 +01:00
echo " download podcast.. opus_encode.."
echo " "
2020-11-10 14:44:22 +01:00
wget -d -c -U "$ag" "$Lpodcast" -O gr3_"$Data"_"$Ora".mp3
# encode audio data... small file
2022-02-15 14:25:02 +01:00
#ffmpeg -i gr3_"$Data"_"$Ora".mp3 -vn -acodec aac -ab 70k -ac 1 gr3_"$Data"_"$Ora".m4a
ffmpeg -i gr3_"$Data"_"$Ora".mp3 -acodec libopus -b:a 48k -ac 1 gr3_"$Data"_"$Ora".opus
2021-12-19 17:40:16 +01:00
rm gr3_"$Data"_"$Ora".mp3