File size: 919 Bytes
f1ee3c6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
deb99bf
f1ee3c6
 
 
 
 
 
 
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
#!/bin/bash

echo "Starting the video collection stream for channel 3.."
echo "listing files in $WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3*.mp4"
current_count=0

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

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

        echo "Updating playlist for channel 3.."
        current_count=$new_count
        files=($WEBTV_VIDEO_STORAGE_PATH_CHANNEL_3*.mp4)

        echo "ffconcat version 1.0" > channel_3_video_tmp.txt
        for (( i=0; i<${#files[@]}; i++ )); do
            echo "file '${files[$i]}'" >> channel_3_video_tmp.txt
        done
        rm -f channel_3_video.txt
        mv channel_3_video_tmp.txt channel_3_video.txt
    fi

    # the new playlist will only be updated after the current playlist ended
    # so there is no emergency here
    sleep 60
done