Skip to content

Commit

Permalink
Fix: create correct json for status file and validate it
Browse files Browse the repository at this point in the history
  • Loading branch information
jcorporation committed Dec 19, 2024
1 parent cae12f6 commit 96ec93f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
12 changes: 9 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,7 @@ check_stream_all_json() {
local rc=0
exec 3<> "${STATUSFILE}.tmp"
printf "{" >&3
local ENTRY_COUNT=0
local PRINT_COMMA=0
local F
for F in "$PLS_DIR/"*
do
Expand Down Expand Up @@ -1348,7 +1348,7 @@ check_stream_all_json() {
then
if [ $RETRY_COUNT -eq 5 ]
then
[ "$ENTRY_COUNT" -gt 0 ] && printf "," >&3
[ "$PRINT_COMMA" -eq 1 ] && printf "," >&3
OUT=$(jq -n --arg value "$OUT" '$value')
local DATE
DATE=$(date +%Y-%m-%d)
Expand All @@ -1359,9 +1359,10 @@ check_stream_all_json() {
echo ""
echo "Error count too high, removing $M3U_NAME"
delete_radio_by_m3u "$M3U_NAME"
PRINT_COMMA=0
else
printf "\"%s\":{\"date\":\"%s\",\"count\":%s,\"error\":%s}" "$M3U" "$DATE" "$ERROR_COUNT" "$OUT" >&3
ENTRY_COUNT=$((ENTRY_COUNT+1))
PRINT_COMMA=1
fi
echo ""
echo "Error getting streaminfo for \"$F\" ($ERROR_COUNT): $OUT"
Expand All @@ -1379,6 +1380,11 @@ check_stream_all_json() {
done
printf "}" >&3
exec 3>&-
if ! jq < "${STATUSFILE}" > /dev/null
then
echo "Invalid statusfile: ${STATUSFILE}"
exit 1
fi
if move_compress_changed "${STATUSFILE}"
then
echo "Streamstatus updated"
Expand Down
13 changes: 12 additions & 1 deletion docs/db/index/status.min.json
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
{"https___82722d_ha_azioncdn_net_ebc_radionacionalriodejaneiro_chunks_m3u8.m3u":{"date":"2024-12-19","count":8,"error":"https://82722d.ha.azioncdn.net/ebc/radionacionalriodejaneiro/chunks.m3u8: Server returned 404 Not Found"},,,,"https___edge56_live-sm_absolutradio_de_absolut-relax_stream_mp3.m3u":{"date":"2024-12-19","count":8,"error":"https://edge56.live-sm.absolutradio.de/absolut-relax/stream/mp3: Server returned 404 Not Found"},}
{
"https___82722d_ha_azioncdn_net_ebc_radionacionalriodejaneiro_chunks_m3u8.m3u": {
"date": "2024-12-19",
"count": 8,
"error": "https://82722d.ha.azioncdn.net/ebc/radionacionalriodejaneiro/chunks.m3u8: Server returned 404 Not Found"
},
"https___edge56_live-sm_absolutradio_de_absolut-relax_stream_mp3.m3u": {
"date": "2024-12-19",
"count": 8,
"error": "https://edge56.live-sm.absolutradio.de/absolut-relax/stream/mp3: Server returned 404 Not Found"
}
}

0 comments on commit 96ec93f

Please sign in to comment.