update gen script for json format
This commit is contained in:
parent
18fe9ab90a
commit
f734c2a639
@ -22,31 +22,34 @@ src=$1
|
||||
listDate=$(date +%Y-%m-%d)
|
||||
|
||||
trunk="/playlists/$(date +%Y)/$(date +%m)/"
|
||||
playlist="$listDate.xml"
|
||||
|
||||
# start time in seconds
|
||||
listStart="21600"
|
||||
playlist="$listDate.json"
|
||||
|
||||
[[ -d "$trunk" ]] || mkdir -p "$trunk"
|
||||
|
||||
c="0"
|
||||
count=$( find "$src" -name "*.mp4" | WC -l )
|
||||
|
||||
# build Head for playlist
|
||||
printf '<playlist>\n\t<head>
|
||||
<meta name="author" content="example"/>
|
||||
<meta name="title" content="Live Stream"/>
|
||||
<meta name="copyright" content="(c)%s example.org"/>
|
||||
<meta name="date" content="%s"/>
|
||||
</head>\n\t<body>\n' $(date +%Y) $listDate > "$trunk/$playlist"
|
||||
printf '{
|
||||
"channel": "Test 1",
|
||||
"date": "%s",
|
||||
"program": [{\n' $listDate > "$trunk/$playlist"
|
||||
|
||||
# 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 }' )
|
||||
|
||||
printf '\t\t<video src="%s" begin="%s" dur="%s" in="%s" out="%s"/>\n' "$clipPath" "$listStart" "$clipDuration" "0.0" "$clipDuration" >> "$trunk/$playlist"
|
||||
c=$((c + 1))
|
||||
|
||||
# add start time
|
||||
listStart="$( awk -v lS="$listStart" -v cD="$clipDuration" 'BEGIN{ print lS + cD }' )"
|
||||
if (( c < count )); then
|
||||
last="}, {"
|
||||
else
|
||||
last="}]"
|
||||
fi
|
||||
|
||||
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"
|
||||
|
||||
done < <( find "$src" -name "*.mp4" )
|
||||
|
||||
printf "\t</body>\n</playlist>\n" >> "$trunk/$playlist"
|
||||
printf "}\n" >> "$trunk/$playlist"
|
||||
|
Loading…
Reference in New Issue
Block a user