option to disable thumbnails per volume

This commit is contained in:
ed 2022-04-14 17:11:26 +02:00
parent 2dbed4500a
commit 9697fb3d84
4 changed files with 20 additions and 7 deletions

View file

@ -405,6 +405,7 @@ press `g` to toggle grid-view instead of the file listing, and `t` toggles icon
it does static images with Pillow / pyvips / FFmpeg, and uses FFmpeg for video files, so you may want to `--no-thumb` or maybe just `--no-vthumb` depending on how dangerous your users are
* pyvips is 3x faster than Pillow, Pillow is 3x faster than FFmpeg
* disable thumbnails for specific volumes with volflag `dthumb` for all, or `dvthumb` / `dathumb` / `dithumb` for video/audio/images only
audio files are covnerted into spectrograms using FFmpeg unless you `--no-athumb` (and some FFmpeg builds may need `--th-ff-swr`)

View file

@ -875,6 +875,17 @@ class AuthSrv(object):
vol.flags["html_head"] = "\n".join([x for x in h if x])
for vol in vfs.all_vols.values():
if self.args.no_vthumb:
vol.flags["dvthumb"] = True
if self.args.no_athumb:
vol.flags["dathumb"] = True
if self.args.no_thumb or vol.flags.get("dthumb", False):
vol.flags["dthumb"] = True
vol.flags["dvthumb"] = True
vol.flags["dathumb"] = True
vol.flags["dithumb"] = True
for vol in vfs.all_vols.values():
fk = vol.flags.get("fk")
if fk:

View file

@ -2097,9 +2097,7 @@ class HttpCli(object):
thp = None
if self.thumbcli:
thp = self.thumbcli.get(
dbv.realpath, vrem, int(st.st_mtime), th_fmt
)
thp = self.thumbcli.get(dbv, vrem, int(st.st_mtime), th_fmt)
if thp:
return self.tx_file(thp)

View file

@ -37,13 +37,14 @@ class ThumbCli(object):
def log(self, msg, c=0):
self.log_func("thumbcli", msg, c)
def get(self, ptop, rem, mtime, fmt):
def get(self, dbv, rem, mtime, fmt):
ptop = dbv.realpath
ext = rem.rsplit(".")[-1].lower()
if ext not in self.thumbable:
if ext not in self.thumbable or "dthumb" in dbv.flags:
return None
is_vid = ext in self.fmt_ffv
if is_vid and self.args.no_vthumb:
if is_vid and "dvthumb" in dbv.flags:
return None
want_opus = fmt in ("opus", "caf")
@ -53,12 +54,14 @@ class ThumbCli(object):
if self.args.no_acode:
return None
else:
if self.args.no_athumb:
if "dathumb" in dbv.flags:
return None
elif want_opus:
return None
is_img = not is_vid and not is_au
if is_img and "dithumb" in dbv.flags:
return None
preferred = self.args.th_dec[0] if self.args.th_dec else ""