#!/bin/sh
+[ "$includepage_video" ] && return 0
+includepage_video="$0"
+
+. "$_EXEC/db_channel.sh"
. "$_EXEC/db_video.sh"
. "$_EXEC/upload.sh"
+. "$_EXEC/transcoding.sh"
+read_channel "$channel"
read_video "$video"
[ "$REQUEST_METHOD" = POST ] && case "$(POST action)" in
REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_NOTLOGGEDIN"
elif ! AUTHOR; then
REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_UPDATE_NOTALLOWED"
- elif update_video "$video" "name=$(POST name)" \
+ elif update_video "$VIDEO_ID" "name=$(POST name)" \
"description=$(POST description)" \
- "status=$(POST status |grep -m1 -xE 'void|private|hidden|public')" \
+ "status=$(POST status |grep -m1 -xE 'private|hidden|public')" \
"uploader=$USER_ID"; then
REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#UPDATE_SUCCESS"
else
REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_UPDATE_NOTALLOWED"
elif [ "$(POST delconfirm)" != confirm ]; then
REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_NOT_CONFIRMED"
- elif delete_video "$video"; then
- rm -f -- "$_DATA/$CHANNEL_ID/$VIDEO_ID.upload.mp4" \
- "$_DATA/$CHANNEL_ID/$VIDEO_ID.mp4" \
- "$_DATA/$CHANNEL_ID/$VIDEO_ID.webm" \
- "$_DATA/$CHANNEL_ID/$VIDEO_ID.thumb.jpg"
+ elif delete_video "$VIDEO_ID"; then
+ rm -f -- "$VIDEO_FILE" "$VIDEO_THUMB" "$VIDEO_MP4" "$VIDEO_WEBM" \
+ "${VIDEO_MP4%.mp4}".*.mp4 "${VIDEO_WEBM%.webm}".*.webm
REDIRECT "${_BASE}/channel/$CHANNEL_ID/#DELETE_CONFIRM"
else
REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_UPDATE_NOLOCK"
;;
esac
-if [ "$REQUEST_METHOD" = POST -a "$channel" -a "$video" ]; then
+if [ "$REQUEST_METHOD" = POST -a "$CHANNEL_ID" -a "$VIDEO_ID" ]; then
if ! AUTHOR; then
head -c "$CONTENT_LENGTH" >/dev/null
REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_UPLOAD_NOTALLOWED"
- elif [ "$VIDEO_STATUS" != void ]; then
+ elif [ -f "$VIDEO_FILE" ]; then
head -c "$CONTENT_LENGTH" >/dev/null
REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_UPLOAD_NOCLOBBER"
- elif UPLOAD "$_DATA/$CHANNEL_ID/$VIDEO_ID.upload.mp4"; then
- update_video "$video" status=private
- VIDEO_STATUS=private
+ elif UPLOAD "$VIDEO_FILE"; then
+ transcode "$VIDEO_FILE"
REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/edit"
fi
fi
-if [ "$channel" -a "$video" -a "$action" = edit ]; then
- AUTHOR || REDIRECT "$_BASE/$channel/$video/#ERROR_EDIT_NOTALLOWED"
+if [ "$CHANNEL_ID" -a "$VIDEO_ID" -a "$action" = edit ]; then
+ AUTHOR || REDIRECT "$_BASE/$CHANNEL_ID/$VIDEO_ID/#ERROR_EDIT_NOTALLOWED"
yield_page "$VIDEO_NAME - Edit" "video edit" <<-EOF
[form .video .edit method=POST
[input name="name" value="$(HTML "$VIDEO_NAME")" placeholder="Video Name" autocomplete=off]
- [fieldset .status $([ $VIDEO_STATUS = void ] && printf "disabled=disabled")
- [radio "status" "private" #status_private $(checked $VIDEO_STATUS private void)]
+ [fieldset .status $([ ! -f "$VIDEO_FILE" ] && printf "disabled=disabled")
+ [radio "status" "private" #status_private $(checked $VIDEO_STATUS private)]
[label for=status_private tooltip="Video is only visible to channel authors" Private]
[radio "status" "hidden" #status_hidden $(checked $VIDEO_STATUS hidden)]
[label for=status_hidden tooltip="Video will not be listed but can be viewed by anyone knowing the URL" Hidden]
]
EOF
-elif [ "$channel" -a "$video" -a "$action" = frameuploadprogress ]; then
- AUTHOR || REDIRECT "$_BASE/$channel/$video/#ERROR_EDIT_NOTALLOWED"
+elif [ "$CHANNEL_ID" -a "$VIDEO_ID" -a "$action" = frameuploadprogress ]; then
+ AUTHOR || REDIRECT "$_BASE/$CHANNEL_ID/$VIDEO_ID/#ERROR_EDIT_NOTALLOWED"
printf '%s\r\n' 'Content-Type: text/html' 'Connection: close' ''
frame_uploadprogress
-elif [ "$channel" -a "$video" -a "$VIDEO_STATUS" = void ]; then
- [ $VIDEO_STATUS = public -o $VIDEO_STATUS = hidden ] || AUTHOR || { . ${_EXEC}/page_404.sh; exit 0; }
-
+elif [ "$CHANNEL_ID" -a "$VIDEO_ID" -a ! -f "$VIDEO_FILE" ] && AUTHOR; then
yield_page "$VIDEO_NAME" "video" <<-EOF
[nav [a href="../../" Channels] - [a href="../" $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")] - [span $(HTML "${VIDEO_NAME:-(Unnamed Video)}")]]
- $( AUTHOR && [ $VIDEO_STATUS = void ] && printf '
[iframe src="frameuploadprogress" width="100%%" height="50"
[a href="freameuploadprogress" Iframe: Upload progress]
]
[form .upload method=POST enctype="multipart/form-data"
[input type=file name=upload]
[submit "action" "video_upload" Upload]
- ]')
- $(AUTHOR && printf '[a .button href="edit" edit]')
+ ]
+ [a .button href="edit" edit]
[h1 .name $(HTML "$VIDEO_NAME")]
[div .description . ${VIDEO_DESCR_CACHE}]
EOF
-elif [ "$channel" -a "$video" -a "$VIDEO_STATUS" != void ]; then
- [ $VIDEO_STATUS = public -o $VIDEO_STATUS = hidden ] || AUTHOR || { . ${_EXEC}/page_404.sh; exit 0; }
+elif [ "$CHANNEL_ID" -a "$VIDEO_ID" -a -f "$VIDEO_FILE" ]; then
+ [ "$VIDEO_STATUS" = public -o "$VIDEO_STATUS" = hidden ] || AUTHOR || { . ${_EXEC}/page_404.sh; exit 0; }
yield_page "$VIDEO_NAME" "video" <<-EOF
[nav [a href="../../" Channels] - [a href="../" $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")] - [span $(HTML "${VIDEO_NAME:-(Unnamed Video)}")]]
[video preload=none controls=controls width="$VIDEO_RESX" height="$VIDEO_RESY"
- $([ -f "${_DATA}/${CHANNEL_ID}/${VIDEO_ID}.mp4" ] \
+ $([ -f "$VIDEO_MP4" ] \
&& printf '[source src="%s/video/%s/%s.mp4" type="video/mp4"]' \
"$_BASE" "$CHANNEL_ID" "$VIDEO_ID"
- [ -f "${_DATA}/${CHANNEL_ID}/${VIDEO_ID}.webm" ] \
+ [ -f "$VIDEO_WEBM" ] \
&& printf '[source src="%s/video/%s/%s.webm" type="video/webm"]' \
"$_BASE" "$CHANNEL_ID" "$VIDEO_ID"
- [ ! -f "${_DATA}/${CHANNEL_ID}/${VIDEO_ID}.mp4" \
- -a ! -f "${_DATA}/${CHANNEL_ID}/${VIDEO_ID}.webm" ] \
- && printf '[source src="%s/video/%s/%s.upload.mp4" type="video/mp4"]\nThe video has not yet been transcoded and may not be displayed correctly.' \
- "$_BASE" "$CHANNEL_ID" "$VIDEO_ID"
+ [ ! -f "$VIDEO_MP4" -a ! -f "$VIDEO_WEBM" ] \
+ && printf '[source src="%s/video/%s/%s.upload.mp4" type="video/mp4"] %s' \
+ "$_BASE" "$CHANNEL_ID" "$VIDEO_ID" \
+ "The video has not yet been transcoded and may not be displayed correctly."
)]
+ $([ ! -f "$VIDEO_MP4" -a ! -f "$VIDEO_WEBM" ] && {
+ read file <"$_DATA/transcoding.queue"
+ if [ "$file" = "$VIDEO_FILE" ]; then
+ printf '[div .transcoding . This video is currently being
+ converted to various publishing formats. It may not be
+ rendered correctly until the conversion is finished.]'
+ elif grep -qFx "$VIDEO_FILE" "${_DATA}/transcoding.queue"; then
+ printf '[div .transcoding . This video is not yet converted to a
+ suitable publishing format. It may not be rendered
+ correctly until the conversion is finished. The conversion
+ will start automatically once previous jobs have been
+ finished.]'
+ else
+ printf '[div .transcoding Publishing formats do not seem to be
+ available for this video. It may be possible that the
+ uploaded file is broken and cannot be transcoded.]'
+ fi
+ })
$(AUTHOR && printf '[a .button href="edit" edit]')
[h1 .name $(HTML "$VIDEO_NAME")]
[div .description . ${VIDEO_DESCR_CACHE}]