mirror of
https://github.com/fenix-soft/gr_podcast.git
synced 2024-12-28 08:00:55 +01:00
77 lines
1.9 KiB
Bash
77 lines
1.9 KiB
Bash
#!/bin/bash
|
|
#
|
|
#
|
|
####################################################################################
|
|
# script che recupera l'ultimo podcast del gr2
|
|
#
|
|
#V:2.1 alpha_debug_mode 15 FEBBRAIO 2022
|
|
#
|
|
# dipendenze: curl,jq,cat,wget
|
|
#
|
|
# log: cambio api rai e dominio
|
|
####################################################################################
|
|
|
|
# set global variable
|
|
|
|
gr2api="https://www.raiplaysound.it/programmi/gr2.json"
|
|
grbase="https://www.raiplaysound.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 " "
|
|
echo "get data api... done!"
|
|
echo " "
|
|
|
|
|
|
# extract jason data of the last podcast
|
|
|
|
dataT=`cat ./data/gr2.json | jq -r '."block" | ."cards" | .[0] | ."downloadable_audio" | ."title"'`
|
|
|
|
echo " "
|
|
echo "extract data... find.."
|
|
echo " "
|
|
echo " "
|
|
echo podcast_title: $dataT
|
|
echo " "
|
|
|
|
|
|
|
|
Lpodcast=`cat ./data/gr2.json | jq -r '."block" | ."cards" | .[0] | ."downloadable_audio" | ."url"'`
|
|
|
|
echo " "
|
|
echo podcast_url: $Lpodcast
|
|
echo " "
|
|
|
|
|
|
# extract time and date onair podcast
|
|
|
|
ora=`cat ./data/gr2.json | jq -r '."block" | ."cards" | .[0] | ."create_time"'`
|
|
Ora=`echo $ora | sed -e 's/\ /\n/g' | grep ":"| sed -e 's/\:/\_/g'`
|
|
|
|
data=`cat ./data/gr2.json | jq -r '."block" | ."cards" | .[0] | ."create_date"'`
|
|
Data=`echo $data | sed -e 's/\//\-/g'`
|
|
|
|
echo " "
|
|
echo log_podcast_creation: $Data $Ora
|
|
echo " "
|
|
echo " "
|
|
|
|
# download podcast
|
|
echo " download podcast.. opus_encode.."
|
|
echo " "
|
|
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 70k -ac 1 gr2_"$Data"_"$Ora".m4a
|
|
ffmpeg -i gr2_"$Data"_"$Ora".mp3 -acodec libopus -b:a 48k -ac 1 gr2_"$Data"_"$Ora".opus
|
|
rm gr2_"$Data"_"$Ora".mp3
|