support thumbnail pregen for all output formats

This commit is contained in:
ed 2025-11-23 21:43:55 +09:00
parent 77f74ddb2f
commit a359b89edd

View file

@ -124,7 +124,17 @@ from .util import (
if True: # pylint: disable=using-constant-test if True: # pylint: disable=using-constant-test
import typing 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: if TYPE_CHECKING:
from .httpconn import HttpConn 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): class HttpCli(object):
""" """
Spawned by HttpConn to process one http transaction 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"]})) # for f in fgen: print(repr({k: f[k] for k in ["vp", "ap"]}))
cfmt = "" cfmt = ""
if self.thumbcli and not self.args.no_bacode: if self.thumbcli and not self.args.no_bacode:
for zs in ("opus", "mp3", "flac", "wav", "w", "j", "p"): if uarg in ZIP_XCODE_S:
if zs in self.ouparam or uarg == zs: cfmt = uarg
cfmt = zs else:
for zs in ZIP_XCODE_L:
if zs in self.ouparam:
cfmt = zs
if cfmt: if cfmt:
self.log("transcoding to [{}]".format(cfmt)) self.log("transcoding to [{}]".format(cfmt))