8 [ "$REQUEST_METHOD" = POST ] && case "$(POST action)" in
10 if [ ! "$USER_ID" ]; then
11 REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_NOTLOGGEDIN"
13 REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOTALLOWED"
14 elif update_video "$video" "name=$(POST name)" \
15 "description=$(POST description)" \
16 "status=$(POST status |grep -m1 -xE 'void|private|hidden|public')" \
17 "uploader=$USER_ID"; then
18 REDIRECT "${_BASE}/channel/${channel}/${video}/#UPDATE_SUCCESS"
20 REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOLOCK"
24 REDIRECT "${_BASE}/channel/${channel}/${video}/#CANCELED"
27 if [ ! "$USER_ID" ]; then
28 REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_NOTLOGGEDIN"
30 REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOTALLOWED"
31 elif [ "$(POST delconfirm)" != confirm ]; then
32 REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_NOT_CONFIRMED"
33 elif delete_video "$video"; then
34 REDIRECT "${_BASE}/channel/${channel}/#DELETE_CONFIRM"
36 REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOLOCK"
41 if [ "$REQUEST_METHOD" = POST -a "$channel" -a "$video" ]; then
43 head -c "$CONTENT_LENGTH" >/dev/null
44 REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPLOAD_NOTALLOWED"
45 elif [ "$VIDEO_STATUS" != void ]; then
46 head -c "$CONTENT_LENGTH" >/dev/null
47 REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPLOAD_NOCLOBBER"
48 elif UPLOAD "$_DATA/$channel/$video.mp4"; then
49 update_video "$video" status=private
51 REDIRECT "${_BASE}/channel/${channel}/${video}/edit"
55 if [ "$channel" -a "$video" -a "$action" = edit ]; then
56 AUTHOR || REDIRECT "$_BASE/$channel/$video/#ERROR_EDIT_NOTALLOWED"
58 yield_page "$VIDEO_NAME - Edit" "video edit" <<-EOF
59 [form .video .edit method=POST
60 [input name="name" value="$(HTML "$VIDEO_NAME")" placeholder="Video Name"]
61 [fieldset .status $([ $VIDEO_STATUS = void ] && printf "disabled=disabled")
62 [radio "status" "private" #status_private $(checked $VIDEO_STATUS private void)]
63 [label for=status_private tooltip="Video is only visible to channel authors" Private]
64 [radio "status" "hidden" #status_hidden $(checked $VIDEO_STATUS hidden)]
65 [label for=status_hidden tooltip="Video will not be listed but can be viewed by anyone knowing the URL" Hidden]
66 [radio "status" "public" #status_public $(checked $VIDEO_STATUS public)]
67 [label for=status_public tooltip="Video will be listed publicly" Public]
69 [textarea name="description" placeholder="Description" . $(HTML "$VIDEO_DESCRIPTION")]
70 [submit "action" "update_video" . Update]
71 [submit "action" "update_video_cancel" . Cancel]
73 [checkbox "delconfirm" "confirm" id="delconfirm"]
74 [label for=delconfirm Delete Video]
75 [submit "action" "delete" Delete Video]
80 elif [ "$channel" -a "$video" -a "$action" = frameuploadprogress ]; then
81 AUTHOR || REDIRECT "$_BASE/$channel/$video/#ERROR_EDIT_NOTALLOWED"
82 printf '%s\r\n' 'Content-Type: text/html' 'Connection: close' ''
85 elif [ "$channel" -a "$video" ]; then
86 [ $VIDEO_STATUS = public -o $VIDEO_STATUS = hidden ] || AUTHOR || { . ${_EXEC}/page_404.sh; exit 0; }
88 yield_page "$VIDEO_NAME" "video" <<-EOF
89 [nav [a href="../../" Channels] - [a href="../" $(HTML "${CHANNEL_NAME:-(Unnamed Channel)}")] - [span $(HTML "${VIDEO_NAME:-(Unnamed Video)}")]]
90 $( AUTHOR && [ $VIDEO_STATUS = void ] && printf '
91 [iframe src="frameuploadprogress" width="100%%" height="50"
92 [a href="freameuploadprogress" Iframe: Upload progress]
94 [form .upload method=POST enctype="multipart/form-data"
95 [input type=file name=upload]
96 [submit "action" "video_upload" Upload]
98 $( [ $VIDEO_STATUS != void ] && printf '
99 [video preload=none controls=controls width=%i height=%i
100 [source src="%s/video/%s/%s.mp4" type="video/mp4"]
101 ]' "$VIDEO_RESX" "$VIDEO_RESY" "$_BASE" "$channel" "$video"
103 $(AUTHOR && printf '[a .button href="edit" edit]')
104 [h1 .name $(HTML "$VIDEO_NAME")]
105 [div .description . ${VIDEO_DESCR_CACHE}]
109 . "$_EXEC/page_404.sh"