Add files via upload

fix new api
This commit is contained in:
fenix-soft 2021-12-19 17:39:06 +01:00 committed by GitHub
parent 9ac5ed04e8
commit 17e55b4817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 17 deletions

38
gr1
View File

@ -4,69 +4,73 @@
####################################################################################
# script che recupera l'ultimo podcast del gr1
#
#v:1.0 Novembre 2020
#
# dipendenze: curl,jq,cat,wget,ffmpeg
# V:2.0 alpha_debug_mode 18 DICEMBRE 2021
#
# dipendenze: curl,jq,cat,wget
#
# log: modifiche per cambio api e dominio rai
####################################################################################
# set global variable
gr1api="https://www.raiplayradio.it/programmi/gr1/?json"
grbase="https://www.raiplayradio.it"
gr1api="https://www.raiplaysound.it/programmi/gr1.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/gr1.json
rm ./data/Lgr1.json
#rm ./data/Lgr1.json
# get jason data
curl -A "$ag" "$gr1api" -o data/gr1.json
echo " "
echo " "
echo "get data api... done!"
echo " "
# extract jason data of the last podcast
dataL=`cat ./data/gr1.json | jq -r ."pathFirstItem"`
dataT=`cat ./data/gr1.json | jq -r '."block" | ."cards" | .[0] | ."downloadable_audio" | ."title"'`
echo " "
echo log: $dataL
echo "extract data... find.."
echo " "
echo " "
echo podcast_title: $dataT
echo " "
curl -A "$ag" "$grbase$dataL" -o data/Lgr1.json
Lpodcast=`cat ./data/Lgr1.json | jq -r '.["audio"] | .contentUrl'`
Lpodcast=`cat ./data/gr1.json | jq -r '."block" | ."cards" | .[0] | ."downloadable_audio" | ."url"'`
echo " "
echo log: $Lpodcast
echo podcast_url: $Lpodcast
echo " "
# extract time and date onair podcast
ora=`cat ./data/Lgr1.json | jq -r ."timePublished"`
ora=`cat ./data/gr1.json | jq -r '."block" | ."cards" | .[0] | ."create_time"'`
Ora=`echo $ora | sed -e 's/\ /\n/g' | grep ":"| sed -e 's/\:/\_/g'`
data=`cat ./data/Lgr1.json | jq -r ."datePublished"`
data=`cat ./data/gr1.json | jq -r '."block" | ."cards" | .[0] | ."create_date"'`
Data=`echo $data | sed -e 's/\//\-/g'`
echo " "
echo log: $Data $Ora
echo log_podcast_creation: $Data $Ora
echo " "
echo " "
# download podcast
echo " download podcast.. opus_encode.."
echo " "
wget -d -c -U "$ag" "$Lpodcast" -O gr1_"$Data"_"$Ora".mp3
# encode audio data... small file
#ffmpeg -i gr1_"$Data"_"$Ora".mp3 -vn -acodec aac -ab 80k gr1_"$Data"_"$Ora".m4a
ffmpeg -i gr1_"$Data"_"$Ora".mp3 -acodec libopus -b:a 64k gr1_"$Data"_"$Ora".opus
rm gr1_"$Data"_"$Ora".mp3
rm gr1_"$Data"_"$Ora".mp3