From a359b89edda5186d2f825767170a27345159adfb Mon Sep 17 00:00:00 2001 From: ed Date: Sun, 23 Nov 2025 21:43:55 +0900 Subject: [PATCH] support thumbnail pregen for all output formats --- copyparty/httpcli.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/copyparty/httpcli.py b/copyparty/httpcli.py index 3ad430c0..6e547863 100644 --- a/copyparty/httpcli.py +++ b/copyparty/httpcli.py @@ -124,7 +124,17 @@ from .util import ( if True: # pylint: disable=using-constant-test import typing - from typing import Any, Generator, Iterable, Match, Optional, Pattern, Type, Union + from typing import ( + Any, + Generator, + Iterable, + Match, + Optional, + Pattern, + Sequence, + Type, + Union, + ) if TYPE_CHECKING: from .httpconn import HttpConn @@ -172,6 +182,18 @@ PERMS_rwh = [ ] +def _build_zip_xcode() -> Sequence[str]: + ret = "opus mp3 flac wav p".split() + for codec in ("w", "j"): + for suf in ("", "f", "f3", "3"): + ret.append("%s%s" % (codec, suf)) + return ret + + +ZIP_XCODE_L = _build_zip_xcode() +ZIP_XCODE_S = set(ZIP_XCODE_L) + + class HttpCli(object): """ Spawned by HttpConn to process one http transaction @@ -4942,9 +4964,12 @@ class HttpCli(object): # for f in fgen: print(repr({k: f[k] for k in ["vp", "ap"]})) cfmt = "" if self.thumbcli and not self.args.no_bacode: - for zs in ("opus", "mp3", "flac", "wav", "w", "j", "p"): - if zs in self.ouparam or uarg == zs: - cfmt = zs + if uarg in ZIP_XCODE_S: + cfmt = uarg + else: + for zs in ZIP_XCODE_L: + if zs in self.ouparam: + cfmt = zs if cfmt: self.log("transcoding to [{}]".format(cfmt))