72 lines
1.6 KiB
Plaintext
72 lines
1.6 KiB
Plaintext
|
#!/bin/bash
|
||
|
#
|
||
|
#
|
||
|
####################################################################################
|
||
|
# script che recupera l'ultimo podcast del gr2
|
||
|
#
|
||
|
#v:1.0 Novembre 2020
|
||
|
#
|
||
|
# dipendenze: curl,jq,cat,wget,ffmpeg
|
||
|
#
|
||
|
#
|
||
|
####################################################################################
|
||
|
|
||
|
# set global variable
|
||
|
|
||
|
gr2api="https://www.raiplayradio.it/programmi/gr2/?json"
|
||
|
grbase="https://www.raiplayradio.it"
|
||
|
ag="Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/56.0"
|
||
|
|
||
|
|
||
|
# remove old jason data
|
||
|
rm ./data/gr2.json
|
||
|
rm ./data/Lgr2.json
|
||
|
|
||
|
|
||
|
# get jason data
|
||
|
curl -A "$ag" "$gr2api" -o data/gr2.json
|
||
|
echo " "
|
||
|
echo "get data api... done!"
|
||
|
echo " "
|
||
|
|
||
|
|
||
|
# extract jason data of the last podcast
|
||
|
|
||
|
dataL=`cat ./data/gr2.json | jq -r ."pathFirstItem"`
|
||
|
|
||
|
echo " "
|
||
|
echo log: $dataL
|
||
|
echo " "
|
||
|
|
||
|
curl -A "$ag" "$grbase$dataL" -o data/Lgr2.json
|
||
|
|
||
|
Lpodcast=`cat ./data/Lgr2.json | jq -r '.["audio"] | .contentUrl'`
|
||
|
|
||
|
echo " "
|
||
|
echo log: $Lpodcast
|
||
|
echo " "
|
||
|
|
||
|
|
||
|
# extract time and date onair podcast
|
||
|
|
||
|
ora=`cat ./data/Lgr2.json | jq -r ."timePublished"`
|
||
|
Ora=`echo $ora | sed -e 's/\ /\n/g' | grep ":"| sed -e 's/\:/\_/g'`
|
||
|
|
||
|
data=`cat ./data/Lgr2.json | jq -r ."datePublished"`
|
||
|
Data=`echo $data | sed -e 's/\//\-/g'`
|
||
|
|
||
|
echo " "
|
||
|
echo log: $Data $Ora
|
||
|
echo " "
|
||
|
echo " "
|
||
|
|
||
|
|
||
|
# download podcast
|
||
|
|
||
|
wget -d -c -U "$ag" "$Lpodcast" -O gr2_"$Data"_"$Ora".mp3
|
||
|
|
||
|
# encode audio data... small file
|
||
|
|
||
|
#ffmpeg -i gr2_"$Data"_"$Ora".mp3 -vn -acodec aac -ab 80k gr2_"$Data"_"$Ora".m4a
|
||
|
ffmpeg -i gr2_"$Data"_"$Ora".mp3 -acodec libopus -b:a 64k gr2_"$Data"_"$Ora".opus
|
||
|
rm gr2_"$Data"_"$Ora".mp3
|