From 18440366fe142acd1177e2fe4ef59ce26e748c38 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Paul=20H=C3=A4nsch?= Date: Thu, 14 Oct 2021 18:00:48 +0200 Subject: [PATCH] page_channel.sh --- page_video.sh | 56 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 40 insertions(+), 16 deletions(-) diff --git a/page_video.sh b/page_video.sh index fc1d358..a1416d3 100644 --- a/page_video.sh +++ b/page_video.sh @@ -86,19 +86,26 @@ update_video(){ UPLOAD(){ local file="$1" - local boundary line last + local boundary line length=0 [ ! "${CONTENT_TYPE}" -o "${CONTENT_TYPE##multipart/form-data;*}" ] && return 1 boundary="${CONTENT_TYPE#*; boundary=}" boundary="${boundary%%;*}" - head -c "$CONTENT_LENGTH" \ + while read -r line; do + length="$(( length + ${#line} + 1))" + [ "${line%${CR}}" = "--$boundary" ] && break + done + while read -r line; do + length="$(( length + ${#line} + 1))" + [ ! "${line%${CR}}" ] && break \ + || debug "$line" + done + + printf "%i\n" "$(( CONTENT_LENGTH - length ))" >"${file}.upload" + head -c "$(( CONTENT_LENGTH - length ))" \ | sed -nE ' - # discard lines prior to boundary - /^--'"${boundary}"'\r?$/!b; - # discard lines until first blank - :A; n; /^\r?$/!bA; n; # print lines until boundary ( = actual file upload) :FILE; p; n; /^--'"${boundary}"'(--)?\r?$/!bFILE; @@ -106,6 +113,7 @@ UPLOAD(){ :END; $q; n; bEND; ' >"$file" truncate -s $(( $(stat -c %s -- "$file") -2 )) -- "$file" + rm -- "${file}.upload" } [ "$REQUEST_METHOD" = POST ] && case "$(POST action)" in @@ -196,24 +204,40 @@ elif [ "$channel" -a "$video" -a "$action" = frameuploadprogress ]; then text-align: center; } .progress { - display: inline-block; - width: 20em; + display: block; position: absolute; + width: 20em; background-color: #FFF; + border: 1pt solid; + border-radius: 4pt; + height: 1.25em; + } + .progress .bar { + display: block; + position: absolute; + left: 0; top: 0; bottom: 0; + background-color: #666; + } + .progress .count { + display: block; + position: absolute; + left: 0; top: 0; right: 0; bottom: 0; + line-height: 1.375em; } --> ' - while [ "$VIDEO_STATUS" = void ]; do - printf '%i\n' "$(stat -c %s "$_DATA/$channel/$video.mp4" 2>&-)" + printf '
%i / %i
\n' 0 0 + while [ ! -f "$_DATA/$channel/$video.mp4" -a \ + ! -f "$_DATA/$channel/$video.mp4.upload" ]; do sleep 1; done + read size <"$_DATA/$channel/$video.mp4.upload" + while [ -f "$_DATA/$channel/$video.mp4.upload" ]; do + stat="$(stat -c %s "$_DATA/$channel/$video.mp4" 2>&-)" + printf '
%iMB / %iMB
\n' \ + "$(( stat * 100 / size ))" "$((stat / 1048576))" "$((size / 1048576))" sleep 1 - read -r VIDEO_ID VIDEO_NAME VIDEO_DESCRIPTION VIDEO_RESX VIDEO_RESY \ - VIDEO_LENGTH VIDEO_COVER VIDEO_STATUS VIDEO_UPLOADER VIDEO_HITS \ - VIDEO_DESCR_CACHE VIDEO_FUTUREUSE <<-EOF - $(grep "^${video} " "${vid_db}") - EOF done - printf 'Ready!\n' + printf '
Ready!
\n' printf '' elif [ "$channel" -a "$video" -a "$action" = frameupload ]; then -- 2.39.2