File size: 1,080 Bytes
0b2f8ce
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

echo "Starting the audio collection stream for channel 2.."
current_count=0

while true; do
    new_count=$(ls $WEBTV_AUDIO_STORAGE_PATH_CHANNEL_2*.mp3 2> /dev/null | wc -l)

    if [ $new_count -ne $current_count ]; then
        echo "there are $new_count audio files for channel 2"

        echo "Updating audio playlists for channel 2..."
        current_count=$new_count
        files=($WEBTV_AUDIO_STORAGE_PATH_CHANNEL_2*.mp3)
        
        # Re-create the audio playlists
        echo "ffconcat version 1.0" > channel_2_audio_list_a.txt
        echo "ffconcat version 1.0" > channel_2_audio_list_b.txt
        for (( i=0; i<${#files[@]}; i++ )); do
            if (( i%2 == 0 )); then
                echo "file '${files[$i]}'" >> channel_2_audio_list_a.txt
            else
                echo "file '${files[$i]}'" >> channel_2_audio_list_b.txt
            fi
        done
        echo "file 'channel_2_audio_list_b.txt'" >> channel_2_audio_list_a.txt
        echo "file 'channel_2_audio_list_a.txt'" >> channel_2_audio_list_b.txt
    fi

    sleep 1
done