2018-01-07 07:58:45 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This file is part of ffplayout.
|
|
|
|
#
|
|
|
|
# ffplayout is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# ffplayout is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with ffplayout. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
src=$1
|
|
|
|
|
|
|
|
listDate=$(date +%Y-%m-%d)
|
|
|
|
|
|
|
|
trunk="/playlists/$(date +%Y)/$(date +%m)/"
|
2019-03-06 14:27:04 -05:00
|
|
|
playlist="$listDate.json"
|
2018-01-07 07:58:45 -05:00
|
|
|
|
2018-02-03 14:46:39 -05:00
|
|
|
[[ -d "$trunk" ]] || mkdir -p "$trunk"
|
|
|
|
|
2019-03-06 14:27:04 -05:00
|
|
|
c="0"
|
2019-03-08 03:34:30 -05:00
|
|
|
count=$( find "$src" -name "*.mp4" | wc -l )
|
2019-03-06 14:27:04 -05:00
|
|
|
|
2018-01-07 07:58:45 -05:00
|
|
|
# build Head for playlist
|
2019-03-06 14:27:04 -05:00
|
|
|
printf '{
|
|
|
|
"channel": "Test 1",
|
|
|
|
"date": "%s",
|
|
|
|
"program": [{\n' $listDate > "$trunk/$playlist"
|
2018-01-07 07:58:45 -05:00
|
|
|
|
|
|
|
# read playlist
|
|
|
|
while read -r line; do
|
|
|
|
clipPath=$(echo "$line" | sed 's/&/&/g')
|
|
|
|
clipDuration=$( ffprobe -v error -show_format "$line" | awk -F= '/duration/{ print $2 }' )
|
|
|
|
|
2019-03-06 14:27:04 -05:00
|
|
|
c=$((c + 1))
|
|
|
|
|
|
|
|
if (( c < count )); then
|
|
|
|
last="}, {"
|
|
|
|
else
|
|
|
|
last="}]"
|
|
|
|
fi
|
2018-01-07 07:58:45 -05:00
|
|
|
|
2019-03-06 14:27:04 -05:00
|
|
|
printf '\t\t"in": 0,\n\t\t"out": %s,\n\t\t"duration": %s,\n\t\t"source": "%s"\n\t%s\n' "$clipDuration" "$clipDuration" "$clipPath" "$last" >> "$trunk/$playlist"
|
2018-01-07 07:58:45 -05:00
|
|
|
|
2019-08-19 14:27:20 -04:00
|
|
|
done < <( find "$src" -name "*.mp4" | sort -R)
|
2018-01-07 07:58:45 -05:00
|
|
|
|
2019-03-06 14:27:04 -05:00
|
|
|
printf "}\n" >> "$trunk/$playlist"
|