case $ACTION in
setprefs)
- SET_COOKIE +$((86400 * 90)) pagesize="$(POST pagesize |grep -m1 -axE '[1-9][0-9]*' || printf 50)"
- SET_COOKIE +$((86400 * 90)) mode="$(POST mode |grep -m1 -axE 'browse|index' || printf browse)"
- SET_COOKIE +$((86400 * 90)) fakemp4="$(POST fakemp4 |grep -m1 -axE 'yes' || printf no)"
+ SET_COOKIE +$((86400 * 90)) pagesize="$(POST pagesize |grep -m1 -axE '[1-9][0-9]*' || printf 50)"
+ SET_COOKIE +$((86400 * 90)) mode="$(POST mode |grep -m1 -axE 'browse|index' || printf browse)"
+ SET_COOKIE +$((86400 * 90)) fakemp4="$(POST fakemp4 |grep -m1 -axE 'yes' || printf no)"
+ SET_COOKIE +$((86400 * 90)) downscale="$(POST downscale |grep -m1 -axE 'yes' || printf no)"
REDIRECT "$(POST ref)"
;;
bookmark)
;;
delete)
;;
- download) . "$_EXEC/cgilite/file.sh"
+ download)
+ . "$_EXEC/cgilite/file.sh"
fakemp4="$(COOKIE fakemp4)"
- FILE "$_DATA/$ITEM" "$([ "$fakemp4" = yes ] && printf 'video/mp4')"
+ downscale="$(COOKIE downscale)"
+ downfile="$_DATA/${ITEM%/*}/.transcode/${ITEM%.*}.480p.webm"
+ if [ "$downscale" = yes -a -f "$downfile" ]; then
+ FILE "$downfile" "$([ "$fakemp4" = yes ] && printf 'video/mp4')"
+ else
+ FILE "$_DATA/$ITEM" "$([ "$fakemp4" = yes ] && printf 'video/mp4')"
+ fi
;;
*) . "$_EXEC/view.sh"
esac
}
w_prefs(){
- local tm tf
+ local tm tf td
tm=''; [ "$(COOKIE mode)" = index ] && tm=' '
tf=''; [ "$(COOKIE fakemp4)" = yes ] && tf=checked
+ td=''; [ "$(COOKIE downscale)" = yes ] && td=checked
printf '
[form #prefs method="POST" action="?a=setprefs"
[input #prefs_ps type=number name=pagesize value="%s"][br]
[radio "mode" "browse" %s #prefs_modebrowse] [label for=prefs_modebrowse Browse Folders][br]
[radio "mode" "index" %s #prefs_modeindex ] [label for=prefs_modeindex View Full Index][br]
- [checkbox "fakemp4" "yes" %s #prefs_fmp4] [label for=prefs_fmp4 Fake .MP4 file ending][br]
+ [checkbox "fakemp4" "yes" %s #prefs_fmp4] [label for=prefs_fmp4 Fake .MP4 file type][br]
+ [checkbox "downscale" "yes" %s #prefs_downscale] [label for=prefs_downscale Prefer downscale to 480p][br]
[submit "store" "store" Set Cookie]
]
' \
"$w_refuri" "$LISTSIZE" \
- "${tm:-checked}" "${tm:+checked}" "$tf"
+ "${tm:-checked}" "${tm:+checked}" "$tf" "$td"
}
w_index(){