gr_podcast/grr_sardegna

83 lines
2.3 KiB
Plaintext
Raw Normal View History

2020-11-20 13:54:00 +01:00
#!/bin/bash
#
#
####################################################################################
2022-02-12 09:38:33 +01:00
# script che recupera i podcast del radio giornale sardo
2020-11-20 13:54:00 +01:00
#
2022-02-12 09:38:33 +01:00
# v:2.0 alpha 12 Gennaio 2022
2020-11-20 13:54:00 +01:00
#
# dipendenze: curl,jq,cat,wget
#
#
####################################################################################
# set global variable
grrAPI="https://www.rainews.it/dl/rai24/tgr/basic/archivio/ContentSet-49e9a5dc-a10a-47ee-bb5c-42c3879c2e71.json"
ag="Mozilla/5.0 (Windows NT 10.0; WOW64; rv:40.0) Gecko/20100101 Firefox/56.0"
# remove old jason data
2022-02-12 09:38:33 +01:00
rm ./data/data.json
2020-11-20 13:54:00 +01:00
# get jason data
2022-02-12 09:38:33 +01:00
curl -A "$ag" "$grrAPI" -o data/data.json
2020-11-20 13:54:00 +01:00
echo " "
echo "get data api... done!"
echo " "
# extract jason data of the 2 last podcast stored
2022-02-12 09:38:33 +01:00
data0=`cat ./data/data.json | jq -r '.items[0]|.date'`
Media0=`cat ./data/data.json | jq -r '.items[0]|.mediaUrl'`
ora0=`cat ./data/data.json | jq -r '.items[0]|.title'`
2020-11-20 13:54:00 +01:00
2022-02-12 09:38:33 +01:00
data1=`cat ./data/data.json | jq -r '.items[1]|.date'`
Media1=`cat ./data/data.json | jq -r '.items[1]|.mediaUrl'`
ora1=`cat ./data/data.json | jq -r '.items[1]|.title'`
2020-11-20 13:54:00 +01:00
# extract time onair podcast "h_m"
Ora0=`echo $ora0 | sed -e 's/\ /\n/g' | grep ":"| sed -e 's/\:/\_/g'`
Ora1=`echo $ora1 | sed -e 's/\ /\n/g' | grep ":"| sed -e 's/\:/\_/g'`
# extract date onair podcast "type 10-10-2020"
Data0=`echo $data0 | sed -e 's/\//\-/g'`
Data1=`echo $data1 | sed -e 's/\//\-/g'`
echo " "
echo "extract data... done!"
echo " "
2022-02-12 09:38:33 +01:00
# patch 404 relinker old api legacy
echo " "
echo "patch 404 relinker... debug mode.."
echo " "
echo $Media0
echo $Media1
Media_0=`echo $Media0 | sed -e 's/http/https/g'`
Media_1=`echo $Media1 | sed -e 's/http/https/g'`
echo " "
echo "apply patch 404.. to https relinker..debug "
echo " "
echo "link_fix: "$Media_0
echo "link_fix: "$Media_1
2020-11-20 13:54:00 +01:00
# download podcast
2022-02-12 09:38:33 +01:00
wget -d -c -U "$ag" "$Media_0" -O GRR_"$Data0"_"$Ora0".mp3
wget -d -c -U "$ag" "$Media_1" -O GRR_"$Data1"_"$Ora1".mp3
# encode audio data... small file
#ffmpeg -i GRR_"$Data"_"$Ora".mp3 -vn -acodec aac -ab 80k GRR_"$Data"_"$Ora".m4a
ffmpeg -n -i GRR_"$Data0"_"$Ora0".mp3 -acodec libopus -b:a 56k -ac 1 GRR_"$Data0"_"$Ora0".opus
ffmpeg -n -i GRR_"$Data1"_"$Ora1".mp3 -acodec libopus -b:a 56k -ac 1 GRR_"$Data1"_"$Ora1".opus
rm GRR_"$Data0"_"$Ora0".mp3
rm GRR_"$Data1"_"$Ora1".mp3