From: Paul Hänsch Date: Wed, 20 Oct 2021 18:59:04 +0000 (+0200) Subject: separated data layer X-Git-Url: https://git.plutz.net/?p=rawnet;a=commitdiff_plain;h=31def066aaf71b5a2f5184335e16c461f1a12401 separated data layer --- diff --git a/db_channel.sh b/db_channel.sh new file mode 100755 index 0000000..9c7372d --- /dev/null +++ b/db_channel.sh @@ -0,0 +1,98 @@ +#!/bin/sh + +[ "$include_dbchannel" ] && return 0 +include_dbchannel="$0" + +# == FILE FORMAT == +# ID NAME DESCRIPTION LOGO THEME AUTHORS DESCR_CACHE FUTUREUSE + +# == GLOBALS == +unset CHANNEL_ID CHANNEL_NAME CHANNEL_DESCRIPTION CHANNEL_LOGO CHANNEL_THEME \ + CHANNEL_AUTHORS CHANNEL_DESCR_CACHE CHANNEL_FUTUREUSE + +chan_db="$_DATA/channels.db" + +read_channel() { + local channel="$1" + + # Global exports + CHANNEL_ID='' CHANNEL_NAME='' CHANNEL_DESCRIPTION='' CHANNEL_LOGO='' + CHANNEL_THEME='' CHANNEL_AUTHORS='' CHANNEL_DESCR_CACHE='' + CHANNEL_FUTUREUSE='' + + if [ $# -eq 0 ]; then + read -r CHANNEL_ID CHANNEL_NAME CHANNEL_DESCRIPTION CHANNEL_LOGO \ + CHANNEL_THEME CHANNEL_AUTHORS CHANNEL_DESCR_CACHE \ + CHANNEL_FUTUREUSE + elif [ "$channel" -a -f "$chan_db" -a -r "$chan_db" ]; then + read -r CHANNEL_ID CHANNEL_NAME CHANNEL_DESCRIPTION CHANNEL_LOGO \ + CHANNEL_THEME CHANNEL_AUTHORS CHANNEL_DESCR_CACHE \ + CHANNEL_FUTUREUSE <<-EOF + $(grep "^${channel} " "${chan_db}") + EOF + fi + if [ "$CHANNEL_ID" ]; then + CHANNEL_NAME="$(UNSTRING "${CHANNEL_NAME}")" + CHANNEL_DESCRIPTION="$(UNSTRING "$CHANNEL_DESCRIPTION")" + CHANNEL_AUTHORS="$(UNSTRING "$CHANNEL_AUTHORS")" + CHANNEL_DESCR_CACHE="$(UNSTRING "$CHANNEL_DESCR_CACHE")" + else + unset CHANNEL_ID CHANNEL_NAME CHANNEL_DESCRIPTION CHANNEL_LOGO \ + CHANNEL_THEME CHANNEL_AUTHORS CHANNEL_DESCR_CACHE \ + CHANNEL_FUTUREUSE + return 1 + fi +} + +update_channel(){ + local id="${1}" name description logo theme authors descr_cache futureuse + local ID NAME DESCRIPTION LOGO THEME AUTHORS DESCR_CACHE FUTUREUSE + local arg + + for arg in "$@"; do case $arg in + name=*) name="${arg#*=}";; + description=*) description="${arg#*=}";; + logo=*) logo="${arg#*=}";; + theme=*) theme="${arg#*=}";; + authors=*) authors="${arg#*=}";; + esac; done + + if LOCK "$chan_db"; then + while read -r ID NAME DESCRIPTION LOGO THEME AUTHORS DESCR_CACHE FUTUREUSE; do + if [ "$id" = "$ID" ]; then + printf '%s %s %s %s %s %s %s %s\n' \ + "$id" "$(STRING "${name-$(UNSTRING "$NAME")}")" \ + "$(STRING "${description-$(UNSTRING "$DESCRIPTION")}")" \ + "${logo:-${logo-${LOGO}}${logo+\\}}" \ + "${theme:-${theme-${THEME}}${theme+\\}}" \ + "$(STRING "${authors-$(UNSTRING "${AUTHORS}")}")" \ + "$(printf %s "${description-$(UNSTRING "$DESCRIPTION")}" |markdown |STRING)" \ + "${FUTUREUSE:-\\}" + else + printf '%s %s %s %s %s %s %s %s\n' \ + "$ID" "$NAME" "$DESCRIPTION" "$LOGO" "$THEME" "$AUTHORS" \ + "$DESCR_CACHE" "$FUTUREUSE" + fi + done <"$chan_db" >"${chan_db}.$$" + mv -- "${chan_db}.$$" "${chan_db}" + RELEASE "$chan_db" + else + return 1 + fi +} + +new_channel(){ + local channel="${1:-$(randomid)}" + + if LOCK "$chan_db"; then + if grep -q "^${channel} " "$chan_db"; then + RELEASE "$chan_db" + return 1 + fi + printf '%s \\ \\ \\ \\ %s \\ \\\n' \ + "$channel" "$(STRING "$USER_ID")" >>"$chan_db" + RELEASE "$chan_db" + else + return 1 + fi +} diff --git a/db_video.sh b/db_video.sh new file mode 100644 index 0000000..86163a2 --- /dev/null +++ b/db_video.sh @@ -0,0 +1,143 @@ +#!/bin/sh + +[ "$include_dbvideo" ] && return 0 +include_dbvideo="$0" + +# == FILE FORMAT == +# ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS UPLOADER HITS DESCR_CACHE FUTUREUSE +# (void|private|hidden|public) + +# == GLOBALS == +unset 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 + +[ "$CHANNEL_ID" ] && vid_db="$_DATA/$CHANNEL_ID/videos.db" + +read_video() { + local video="$1" + + # Global exports + 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='' + + if [ $# -eq 0 ]; then + 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 + elif [ "$video" -a -f "$vid_db" -a -r "$vid_db" ]; then + 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 + fi + if [ "$VIDEO_ID" ]; then + VIDEO_NAME="$(UNSTRING "$VIDEO_NAME")" + VIDEO_DESCRIPTION="$(UNSTRING "$VIDEO_DESCRIPTION")" + VIDEO_COVER="$(UNSTRING "$VIDEO_COVER")" + VIDEO_DESCR_CACHE="$(UNSTRING "$VIDEO_DESCR_CACHE")" + else + unset 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 + return 1 + fi +} + +update_video(){ + local id="${1}" name description resx resy length cover status uploader \ + hits descr_cache futureuse + local ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS UPLOADER HITS \ + DESCR_CACHE FUTUREUSE + local arg video thumb cnt + video="${_DATA}/${CHANNEL_ID}/${VIDEO_ID}.mp4" + thumb="${_DATA}/${CHANNEL_ID}/${VIDEO_ID}_thumb.jpg" + + for arg in "$@"; do case $arg in + name=*) name="${arg#*=}";; + description=*) description="${arg#*=}";; + cover=*) cover="${arg#*=}";; + status=*) status="${arg#*=}";; + uploader=*) uploader="${arg#*=}";; + hits=*) hits="${arg#*=}";; + esac; done + + if [ -f "$video" -a -r "$video" ]; then + arg="$(echo; ffprobe -show_entries format=duration:stream=width,height "$video" 2>&-)" + resx="${arg#*width=}"; resx="${resx%%${BR}*}" + resy="${arg#*height=}"; resy="${resy%%${BR}*}" + length="${arg#*duration=}"; length="${length%%${BR}*}" + fi + if [ "${length%.*}" -a ! "${thumb}" -nt "${video}" ]; then + for cnt in 1 2 3 4 5 6 7 8 9 10; do + ffmpeg -nostdin -y -ss "$((cnt * ${length%.*} / 11))" -i "$video" \ + -frames 1 "${thumb%.jpg}_$((cnt - 1)).jpg" + done 2>&- + montage "${thumb%.jpg}"_[0-9].jpg \ + -background "#000000" \ + -tile 10x1 -geometry 320x180+0+0 \ + -interlace line -quality 85 "${thumb}" + rm -- "${thumb%.jpg}"_[0-9].jpg + fi + + if LOCK "$vid_db"; then + while read -r ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS UPLOADER HITS \ + DESCR_CACHE FUTUREUSE; do + if [ "$id" = "$ID" ]; then + printf '%s %s %s %i %i %f %s %s %s %i %s %s\n' \ + "$id" "$(STRING "${name-$(UNSTRING "$NAME")}")" \ + "$(STRING "${description-$(UNSTRING "$DESCRIPTION")}")" \ + "${resx:-${resx-${RESX}}${resx+0}}" \ + "${resy:-${resy-${RESY}}${resy+0}}" \ + "${length:-${length-${LENGTH}}${length+0}}" \ + "$(STRING "${cover-$(UNSTRING "$COVER")}")" \ + "${status:-${status-${STATUS}}${status+void}}" \ + "${uploader:-${uploader-${UPLOADER}}${uploader+\\}}" \ + "${hits:-${hits-${HITS}}${hits+0}}" \ + "$(printf %s "${description-$(UNSTRING "$DESCRIPTION")}" |markdown |STRING)" \ + "${FUTUREUSE:-\\}" + else + printf '%s %s %s %i %i %f %s %s %s %i %s %s\n' \ + "$ID" "$NAME" "$DESCRIPTION" "$RESX" "$RESY" "$LENGTH" \ + "$COVER" "$STATUS" "$UPLOADER" "$HITS" "$DESCR_CACHE" \ + "$FUTUREUSE" + fi + done <"$vid_db" >"${vid_db}.$$" + mv -- "${vid_db}.$$" "${vid_db}" + RELEASE "$vid_db" + else + return 1 + fi +} + +new_video(){ + local video="${1:-$(randomid)}" + + if LOCK "$vid_db"; then + if grep -q "^${video} " "$vid_db"; then + RELEASE "$vid_db" + return 1 + fi + # ID NAME DESC RESX RESY LENGTH COVER STATUS UPLDR HITS FUTUREUSE + printf '%s \\ \\ 0 0 0 \\ void %s 0 \\\n' \ + "$video" "$(STRING "$USER_ID")" >>"$vid_db" + RELEASE "$vid_db" + else + return 1 + fi +} + +delete_video() { + local video="$1" + + if LOCK "$vid_db"; then + grep -v "^${video} " <"$vid_db" >"${vid_db}.$$" + mv -- "${vid_db}.$$" "$vid_db" + rm -- "${_DATA}/${CHANNEL_ID}/${video}.mp4" "${_DATA}/${CHANNEL_ID}/${video}_thumb.jpg" + RELEASE "$vid_db" + else + return 1 + fi +} diff --git a/page_channel.sh b/page_channel.sh index bc87076..09fae09 100755 --- a/page_channel.sh +++ b/page_channel.sh @@ -1,6 +1,7 @@ #!/bin/sh -chan_db="$_DATA/channels.db" +. "$_EXEC/db_channel.sh" +. "$_EXEC/db_video.sh" channel='' video='' action='' path_info="$PATH_INFO" @@ -16,62 +17,8 @@ fi action="${path_info}" unset path_info -# Channel -# ID NAME DESCRIPTION LOGO THEME AUTHORS DESCR_CACHE FUTUREUSE - -if [ "$channel" -a -f "$chan_db" -a -r "$chan_db" ]; then - read -r CHANNEL_ID CHANNEL_NAME CHANNEL_DESCRIPTION CHANNEL_LOGO \ - CHANNEL_THEME CHANNEL_AUTHORS CHANNEL_DESCR_CACHE \ - CHANNEL_FUTUREUSE <<-EOF - $(grep "^${channel} " "${chan_db}") - EOF - if [ "$CHANNEL_ID" ]; then - CHANNEL_NAME="$(UNSTRING "${CHANNEL_NAME}")" - CHANNEL_DESCRIPTION="$(UNSTRING "$CHANNEL_DESCRIPTION")" - CHANNEL_AUTHORS="$(UNSTRING "$CHANNEL_AUTHORS")" - CHANNEL_DESCR_CACHE="$(UNSTRING "$CHANNEL_DESCR_CACHE")" - vid_db="${_DATA}/${CHANNEL_ID}/videos.db" - else - channel='' - fi -fi - -update_channel(){ - local id="${1}" name description logo theme authors descr_cache futureuse - local ID NAME DESCRIPTION LOGO THEME AUTHORS DESCR_CACHE FUTUREUSE - local arg - - for arg in "$@"; do case $arg in - name=*) name="${arg#*=}";; - description=*) description="${arg#*=}";; - logo=*) logo="${arg#*=}";; - theme=*) theme="${arg#*=}";; - authors=*) authors="${arg#*=}";; - esac; done - - if LOCK "$chan_db"; then - while read -r ID NAME DESCRIPTION LOGO THEME AUTHORS DESCR_CACHE FUTUREUSE; do - if [ "$id" = "$ID" ]; then - printf '%s %s %s %s %s %s %s %s\n' \ - "$id" "$(STRING "${name-$(UNSTRING "$NAME")}")" \ - "$(STRING "${description-$(UNSTRING "$DESCRIPTION")}")" \ - "${logo:-${logo-${LOGO}}${logo+\\}}" \ - "${theme:-${theme-${THEME}}${theme+\\}}" \ - "$(STRING "${authors-$(UNSTRING "${AUTHORS}")}")" \ - "$(printf %s "${description-$(UNSTRING "$DESCRIPTION")}" |markdown |STRING)" \ - "${FUTUREUSE:-\\}" - else - printf '%s %s %s %s %s %s %s %s\n' \ - "$ID" "$NAME" "$DESCRIPTION" "$LOGO" "$THEME" "$AUTHORS" \ - "$DESCR_CACHE" "$FUTUREUSE" - fi - done <"$chan_db" >"${chan_db}.$$" - mv -- "${chan_db}.$$" "${chan_db}" - RELEASE "$chan_db" - else - return 1 - fi -} +read_channel "$channel" \ +&& vid_db="${_DATA}/${CHANNEL_ID}/videos.db" AUTHOR(){ if [ "$CHANNEL_ID" -a "$USER_ID" -a ! "${CHANNEL_AUTHORS##*${USER_ID}*}" ]; then @@ -89,17 +36,8 @@ AUTHOR(){ channel="$(POST channel |checkid)" if [ ! "$USER_ID" ]; then REDIRECT "${_BASE}/channel/#ERROR_NEWCHANNEL_NOTALLOWED" - elif LOCK "$chan_db"; then - if grep -q '^${channel} ' "$chan_db"; then - RELEASE "$chan_db" - REDIRECT "${_BASE}/channel/#ERROR_NEWCHANNEL_EXISTS" - else - printf '%s \\ \\ \\ \\ %s \\ \\\n' \ - "$channel" "$(STRING "$USER_ID")" \ - >>"$chan_db" - RELEASE "$chan_db" - REDIRECT "${_BASE}/channel/${channel}/edit" - fi + elif new_channel "$channel"; then + REDIRECT "${_BASE}/channel/${channel}/edit" else REDIRECT "${_BASE}/channel/#ERROR_NEWCHANNEL_NOLOCK" fi @@ -136,18 +74,8 @@ AUTHOR(){ REDIRECT "${_BASE}/channel/${channel}/#ERROR_NOTLOGGEDIN" elif ! AUTHOR; then REDIRECT "${_BASE}/channel/${channel}/#ERROR_UPDATE_NOTALLOWED" - elif LOCK "$vid_db"; then - if grep -q "^${video} " "$vid_db"; then - RELEASE "$vid_db" - REDIRECT "${_BASE}/channel/${channel}/#ERROR_NEWVIDEO_EXISTS" - else - # ID NAME DESC RESX RESY LENGTH COVER STATUS UPLOADER HITS FUTUREUSE - printf '%s \\ \\ 0 0 0 \\ void %s \\ \\\n' \ - "$video" "$(STRING "$USER_ID")" \ - >>"$vid_db" - RELEASE "$vid_db" - REDIRECT "${_BASE}/channel/${channel}/${video}/edit" - fi + elif new_video "$video"; then + REDIRECT "${_BASE}/channel/${channel}/${video}/edit" else REDIRECT "${_BASE}/channel/${channel}/#ERROR_NEWVIDEO_NOLOCK" fi @@ -160,14 +88,8 @@ w_video(){ VIDEO_LENGTH VIDEO_COVER VIDEO_STATUS VIDEO_UPLOADER VIDEO_HITS \ VIDEO_DESCR_CACHE VIDEO_FUTUREUSE - if 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; then - VIDEO_NAME="$(UNSTRING "$VIDEO_NAME")" - VIDEO_DESCRIPTION="$(UNSTRING "$VIDEO_DESCRIPTION")" - VIDEO_DESCR_CACHE="$(UNSTRING "$VIDEO_DESCR_CACHE")" - VIDEO_LENGTH="$(printf %i "$VIDEO_LENGTH" 2>&-)" - + if read_video; then + VIDEO_LENGTH="${VIDEO_LENGTH%.*}" [ "${VIDEO_STATUS}" = public ] || AUTHOR || return 0 thumb="${_BASE}/video/${CHANNEL_ID}/${VIDEO_ID}_thumb.jpg" @@ -189,20 +111,22 @@ w_video(){ fi } -w_channel(){ +w_channel_list(){ local vid_db local CHANNEL_ID CHANNEL_NAME CHANNEL_DESCRIPTION CHANNEL_LOGO \ CHANNEL_THEME CHANNEL_AUTHORS CHANNEL_DESCR_CACHE CHANNEL_FUTUREUSE - if read -r CHANNEL_ID CHANNEL_NAME CHANNEL_DESCRIPTION CHANNEL_LOGO \ - CHANNEL_THEME CHANNEL_AUTHORS CHANNEL_DESCR_CACHE \ - CHANNEL_FUTUREUSE; then - CHANNEL_NAME="$(UNSTRING "$CHANNEL_NAME")" - CHANNEL_DESCRIPTION="$(UNSTRING "$CHANNEL_DESCRIPTION")" - CHANNEL_AUTHORS="$(UNSTRING "$CHANNEL_AUTHORS")" - CHANNEL_DESCR_CACHE="$(UNSTRING "$CHANNEL_DESCR_CACHE")" + [ "$USER_ID" ] && cat <<-EOF + [form .channel .newchannel method=POST + [hidden "channel" "$(timeid)"] + [submit "action" "newchannel" New Channel] + ] + EOF + [ -f "$chan_db" -a -r "$chan_db" ] \ + && while read_channel; do vid_db="${_DATA}/${CHANNEL_ID}/videos.db" + cat <<-EOF [div .channel [div .description @@ -214,21 +138,7 @@ w_channel(){ ) ] EOF - else - return 1 - fi -} - -w_channel_list(){ - if [ $USER_ID ]; then - printf ' - [form .channel .newchannel method=POST - [hidden "channel" "%s"] - [submit "action" "newchannel" New Channel] - ]' "$(timeid)" - fi - [ -f "$chan_db" -a -r "$chan_db" ] \ - && while w_channel; do :; done <"$chan_db" + done <"$chan_db" } if [ "$channel" -a "$video" ]; then diff --git a/page_video.sh b/page_video.sh index a1416d3..587ee52 100644 --- a/page_video.sh +++ b/page_video.sh @@ -1,88 +1,8 @@ #!/bin/sh -# ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS (void|private|hidden|public) UPLOADER HITS DESCR_CACHE FUTUREUSE +. "$_EXEC/db_video.sh" -if [ "$video" -a -f "$vid_db" -a -r "$vid_db" ]; then - 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 - if [ "$VIDEO_ID" ]; then - VIDEO_NAME="$(UNSTRING "$VIDEO_NAME")" - VIDEO_DESCRIPTION="$(UNSTRING "$VIDEO_DESCRIPTION")" - VIDEO_COVER="$(UNSTRING "$VIDEO_COVER")" - VIDEO_DESCR_CACHE="$(UNSTRING "$VIDEO_DESCR_CACHE")" - else - video='' - fi -fi - -update_video(){ - local id="${1}" name description resx resy length cover status uploader \ - hits descr_cache futureuse - local ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS UPLOADER HITS \ - DESCR_CACHE FUTUREUSE - local arg video thumb cnt - video="${_DATA}/${CHANNEL_ID}/${VIDEO_ID}.mp4" - thumb="${_DATA}/${CHANNEL_ID}/${VIDEO_ID}_thumb.jpg" - - for arg in "$@"; do case $arg in - name=*) name="${arg#*=}";; - description=*) description="${arg#*=}";; - cover=*) cover="${arg#*=}";; - status=*) status="${arg#*=}";; - uploader=*) uploader="${arg#*=}";; - hits=*) hits="${arg#*=}";; - esac; done - - if [ -f "$video" -a -r "$video" ]; then - arg="$(echo; ffprobe -show_entries format=duration:stream=width,height "$video" 2>&-)" - resx="${arg#*width=}"; resx="${resx%%${BR}*}" - resy="${arg#*height=}"; resy="${resy%%${BR}*}" - length="${arg#*duration=}"; length="${length%%${BR}*}" - fi - if [ "${length%.*}" -a ! "${thumb}" -nt "${video}" ]; then - for cnt in 1 2 3 4 5 6 7 8 9 10; do - ffmpeg -nostdin -y -ss "$((cnt * ${length%.*} / 11))" -i "$video" \ - -frames 1 "${thumb%.jpg}_$((cnt - 1)).jpg" - done 2>&- - montage "${thumb%.jpg}"_[0-9].jpg \ - -background "#000000" \ - -tile 10x1 -geometry 320x180+0+0 \ - -interlace line -quality 85 "${thumb}" - rm -- "${thumb%.jpg}"_[0-9].jpg - fi - - if LOCK "$vid_db"; then - while read -r ID NAME DESCRIPTION RESX RESY LENGTH COVER STATUS UPLOADER HITS \ - DESCR_CACHE FUTUREUSE; do - if [ "$id" = "$ID" ]; then - printf '%s %s %s %i %i %f %s %s %s %i %s %s\n' \ - "$id" "$(STRING "${name-$(UNSTRING "$NAME")}")" \ - "$(STRING "${description-$(UNSTRING "$DESCRIPTION")}")" \ - "${resx:-${resx-${RESX}}${resx+0}}" \ - "${resy:-${resy-${RESY}}${resy+0}}" \ - "${length:-${length-${LENGTH}}${length+0}}" \ - "$(STRING "${cover-$(UNSTRING "$COVER")}")" \ - "${status:-${status-${STATUS}}${status+void}}" \ - "${uploader:-${uploader-${UPLOADER}}${uploader+\\}}" \ - "${hits:-${hits-${HITS}}${hits+0}}" \ - "$(printf %s "${description-$(UNSTRING "$DESCRIPTION")}" |markdown |STRING)" \ - "${FUTUREUSE:-\\}" - else - printf '%s %s %s %i %i %f %s %s %s %i %s %s\n' \ - "$ID" "$NAME" "$DESCRIPTION" "$RESX" "$RESY" "$LENGTH" \ - "$COVER" "$STATUS" "$UPLOADER" "$HITS" "$DESCR_CACHE" \ - "$FUTUREUSE" - fi - done <"$vid_db" >"${vid_db}.$$" - mv -- "${vid_db}.$$" "${vid_db}" - RELEASE "$vid_db" - else - return 1 - fi -} +read_video "$video" UPLOAD(){ local file="$1" @@ -141,13 +61,7 @@ UPLOAD(){ REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOTALLOWED" elif [ "$(POST delconfirm)" != confirm ]; then REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_NOT_CONFIRMED" - elif LOCK "$vid_db"; then - while read -r id tail; do - [ "$id" != "$video" ] && printf '%s %s\n' "$id" "$tail" - done <"$vid_db" >"${vid_db}.$$" - mv -- "${vid_db}.$$" "$vid_db" - rm -- "${_DATA}/${channel}/${video}.mp4" "${_DATA}/${channel}/${video}_thumb.jpg" - RELEASE "$vid_db" + elif delete_video "$video"; then REDIRECT "${_BASE}/channel/${channel}/#DELETE_CONFIRM" else REDIRECT "${_BASE}/channel/${channel}/${video}/#ERROR_UPDATE_NOLOCK"