if [ ! "$USER_ID" ]; then
REDIRECT "${_BASE}/channel/#ERROR_NEWCHANNEL_NOTALLOWED"
elif new_channel "$channel"; then
- REDIRECT "${_BASE}/channel/${channel}/edit"
+ REDIRECT "${_BASE}/channel/$channel/edit"
else
REDIRECT "${_BASE}/channel/#ERROR_NEWCHANNEL_NOLOCK"
fi
if [ ! "$channel" ]; then
REDIRECT "${_BASE}/channel/#ERROR_NOCHANNEL"
elif [ ! "$USER_ID" ]; then
- REDIRECT "${_BASE}/channel/${channel}/#ERROR_NOTLOGGEDIN"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_NOTLOGGEDIN"
elif ! AUTHOR; then
- REDIRECT "${_BASE}/channel/${channel}/#ERROR_UPDATE_NOTALLOWED"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_UPDATE_NOTALLOWED"
elif update_channel "$channel" "name=$(POST name)" \
"description=$(POST description)" \
"authors=$USER_ID"; then
- REDIRECT "${_BASE}/channel/${channel}/"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/"
else
- REDIRECT "${_BASE}/channel/${channel}/#ERROR_UPDATE_NOLOCK"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_UPDATE_NOLOCK"
fi
;;
update_channel_cancel)
- REDIRECT "${_BASE}/channel/${channel}/"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/"
;;
newvideo)
video="$(POST video |checkid)"
AUTHOR \
- && mkdir -p -- "${_DATA}/${channel}/"
+ && mkdir -p -- "${_DATA}/$CHANNEL_ID/"
if [ ! "$video" ]; then
- REDIRECT "${_BASE}/channel/${channel}/#ERROR_INVALID_ID"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_INVALID_ID"
elif [ ! "$channel" ]; then
REDIRECT "${_BASE}/channel/#ERROR_NOCHANNEL"
elif [ ! "$USER_ID" ]; then
- REDIRECT "${_BASE}/channel/${channel}/#ERROR_NOTLOGGEDIN"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_NOTLOGGEDIN"
elif ! AUTHOR; then
- REDIRECT "${_BASE}/channel/${channel}/#ERROR_UPDATE_NOTALLOWED"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_UPDATE_NOTALLOWED"
elif new_video "$video"; then
- REDIRECT "${_BASE}/channel/${channel}/${video}/"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/${video}/"
else
- REDIRECT "${_BASE}/channel/${channel}/#ERROR_NEWVIDEO_NOLOCK"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/#ERROR_NEWVIDEO_NOLOCK"
fi
;;
esac
VIDEO_LENGTH="${VIDEO_LENGTH%.*}"
[ "${VIDEO_STATUS}" = public ] || AUTHOR || return 0
- thumb="${_BASE}/video/${CHANNEL_ID}/${VIDEO_ID}_thumb.jpg"
+ thumb="${_BASE}/video/${CHANNEL_ID}/${VIDEO_ID}.thumb.jpg"
[ "$NAME" = \\ ] && NAME="(Unnamed Video)"
printf '[div .video .thumb
[a href="%s/channel/%s/%s/"
if [ "$channel" -a "$video" ]; then
. ${_EXEC}/page_video.sh
elif [ "$channel" -a "$action" = edit ]; then
- AUTHOR || REDIRECT "${_BASE}/${channel}/#ERROR_EDIT_NOTALLOWED"
+ AUTHOR || REDIRECT "${_BASE}/$CHANNEL_ID/#ERROR_EDIT_NOTALLOWED"
yield_page "$CHANNEL_NAME - Edit" "channel edit" <<-EOF
[form .channel .edit method=POST
- [input name="name" value="$(HTML "$CHANNEL_NAME")" placeholder="Channel Name"]
+ [input name="name" value="$(HTML "$CHANNEL_NAME")" placeholder="Channel Name" autocomplete=off]
[textarea name="description" placeholder="Description" . $(HTML "$CHANNEL_DESCRIPTION")]
[submit "action" "update_channel" . Update]
[submit "action" "update_channel_cancel" . Cancel]
[ "$REQUEST_METHOD" = POST ] && case "$(POST action)" in
update_video)
if [ ! "$USER_ID" ]; then
- REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_NOTLOGGEDIN"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_NOTLOGGEDIN"
elif ! AUTHOR; then
- REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOTALLOWED"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_UPDATE_NOTALLOWED"
elif update_video "$video" "name=$(POST name)" \
"description=$(POST description)" \
"status=$(POST status |grep -m1 -xE 'void|private|hidden|public')" \
"uploader=$USER_ID"; then
- REDIRECT "${_BASE}/channel/${channel}/${video}/#UPDATE_SUCCESS"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#UPDATE_SUCCESS"
else
- REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOLOCK"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_UPDATE_NOLOCK"
fi
;;
update_video_cancel)
- REDIRECT "${_BASE}/channel/${channel}/${video}/#CANCELED"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#CANCELED"
;;
delete)
if [ ! "$USER_ID" ]; then
- REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_NOTLOGGEDIN"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_NOTLOGGEDIN"
elif ! AUTHOR; then
- REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOTALLOWED"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_UPDATE_NOTALLOWED"
elif [ "$(POST delconfirm)" != confirm ]; then
- REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_NOT_CONFIRMED"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_NOT_CONFIRMED"
elif delete_video "$video"; then
- REDIRECT "${_BASE}/channel/${channel}/#DELETE_CONFIRM"
+ 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"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/#DELETE_CONFIRM"
else
- REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOLOCK"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_UPDATE_NOLOCK"
fi
;;
esac
if [ "$REQUEST_METHOD" = POST -a "$channel" -a "$video" ]; then
if ! AUTHOR; then
head -c "$CONTENT_LENGTH" >/dev/null
- REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPLOAD_NOTALLOWED"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/#ERROR_UPLOAD_NOTALLOWED"
elif [ "$VIDEO_STATUS" != void ]; then
head -c "$CONTENT_LENGTH" >/dev/null
- REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPLOAD_NOCLOBBER"
- elif UPLOAD "$_DATA/$channel/$video.mp4"; then
+ 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
- REDIRECT "${_BASE}/channel/${channel}/${video}/edit"
+ REDIRECT "${_BASE}/channel/$CHANNEL_ID/$VIDEO_ID/edit"
fi
fi
yield_page "$VIDEO_NAME - Edit" "video edit" <<-EOF
[form .video .edit method=POST
- [input name="name" value="$(HTML "$VIDEO_NAME")" placeholder="Video Name"]
+ [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)]
[label for=status_private tooltip="Video is only visible to channel authors" Private]
printf '%s\r\n' 'Content-Type: text/html' 'Connection: close' ''
frame_uploadprogress
-elif [ "$channel" -a "$video" ]; then
+elif [ "$channel" -a "$video" -a "$VIDEO_STATUS" = void ]; then
[ $VIDEO_STATUS = public -o $VIDEO_STATUS = hidden ] || AUTHOR || { . ${_EXEC}/page_404.sh; exit 0; }
yield_page "$VIDEO_NAME" "video" <<-EOF
[input type=file name=upload]
[submit "action" "video_upload" Upload]
]')
- $( [ $VIDEO_STATUS != void ] && printf '
- [video preload=none controls=controls width=%i height=%i
- [source src="%s/video/%s/%s.mp4" type="video/mp4"]
- ]' "$VIDEO_RESX" "$VIDEO_RESY" "$_BASE" "$channel" "$video"
- )
+ $(AUTHOR && printf '[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; }
+
+ 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" ] \
+ && printf '[source src="%s/video/%s/%s.mp4" type="video/mp4"]' \
+ "$_BASE" "$CHANNEL_ID" "$VIDEO_ID"
+ [ -f "${_DATA}/${CHANNEL_ID}/${VIDEO_ID}.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"
+ )]
$(AUTHOR && printf '[a .button href="edit" edit]')
[h1 .name $(HTML "$VIDEO_NAME")]
[div .description . ${VIDEO_DESCR_CACHE}]