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)
|
listDate=$(date +%Y-%m-%d)
|
||||||
|
|
||||||
trunk="/playlists/$(date +%Y)/$(date +%m)/"
|
trunk="/playlists/$(date +%Y)/$(date +%m)/"
|
||||||
playlist="$listDate.xml"
|
playlist="$listDate.json"
|
||||||
|
|
||||||
# start time in seconds
|
|
||||||
listStart="21600"
|
|
||||||
|
|
||||||
[[ -d "$trunk" ]] || mkdir -p "$trunk"
|
[[ -d "$trunk" ]] || mkdir -p "$trunk"
|
||||||
|
|
||||||
|
c="0"
|
||||||
|
count=$( find "$src" -name "*.mp4" | WC -l )
|
||||||
|
|
||||||
# build Head for playlist
|
# build Head for playlist
|
||||||
printf '<playlist>\n\t<head>
|
printf '{
|
||||||
<meta name="author" content="example"/>
|
"channel": "Test 1",
|
||||||
<meta name="title" content="Live Stream"/>
|
"date": "%s",
|
||||||
<meta name="copyright" content="(c)%s example.org"/>
|
"program": [{\n' $listDate > "$trunk/$playlist"
|
||||||
<meta name="date" content="%s"/>
|
|
||||||
</head>\n\t<body>\n' $(date +%Y) $listDate > "$trunk/$playlist"
|
|
||||||
|
|
||||||
# read playlist
|
# read playlist
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
clipPath=$(echo "$line" | sed 's/&/&/g')
|
clipPath=$(echo "$line" | sed 's/&/&/g')
|
||||||
clipDuration=$( ffprobe -v error -show_format "$line" | awk -F= '/duration/{ print $2 }' )
|
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
|
if (( c < count )); then
|
||||||
listStart="$( awk -v lS="$listStart" -v cD="$clipDuration" 'BEGIN{ print lS + cD }' )"
|
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" )
|
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