From: Paul Hänsch Date: Sat, 11 Aug 2018 13:32:27 +0000 (+0200) Subject: Enable 480p display (if transcoded file is found) X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=1bac890e2bd4a6998794f0fcb3b02409279389c2;p=serve0 Enable 480p display (if transcoded file is found) --- diff --git a/cgilite b/cgilite index b7003c3..3a49d64 160000 --- a/cgilite +++ b/cgilite @@ -1 +1 @@ -Subproject commit b7003c3323ad0881d744f491c77e2de234545a7c +Subproject commit 3a49d642c02f8577096cfd31a89cb07714a95215 diff --git a/index.cgi b/index.cgi index 4d7e8aa..eebe106 100755 --- a/index.cgi +++ b/index.cgi @@ -22,9 +22,10 @@ ACTION="$(GET a)" 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) @@ -69,9 +70,16 @@ elif [ -f "$_DATA/$ITEM" ]; then ;; 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 diff --git a/widgets.sh b/widgets.sh index 916f1d7..3e77017 100644 --- a/widgets.sh +++ b/widgets.sh @@ -125,10 +125,11 @@ w_search(){ } 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" @@ -138,12 +139,13 @@ w_prefs(){ [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(){