#!/bin/bash
RADIO_GROUP=$1
RADIO_CHANNEL=$2
RADIO_INPUT_PORT=$3
RADIO_INPUT_HTTP=$4
RADIO_FILE_LOCATION="/storage/dockerCommands/jellyfin/config/data/tv/"$RADIO_GROUP"/"$RADIO_CHANNEL"/"$RADIO_CHANNEL".m3u8"

rm /storage/dockerCommands/jellyfin/config/data/tv/$RADIO_GROUP/$RADIO_CHANNEL/*

ffmpeg \
-i $RADIO_INPUT_PORT \
-f hls \
-c:a aac \
-hls_time 6 \
-hls_list_size 4 \
-hls_flags +delete_segments \
-hls_segment_type fmp4 \
$RADIO_FILE_LOCATION \
2>&1 | stdbuf -oL sed 's/^/[Tv-'$RADIO_GROUP'-'$RADIO_CHANNEL'] /'
