Add adjustable Max cap (default 30), allow up to 320
Browse files
src/lib/grabber/search.functions.ts
CHANGED
|
@@ -35,7 +35,7 @@ const InputSchema = z.object({
|
|
| 35 |
site: SiteSchema,
|
| 36 |
tags: z.string().default(""),
|
| 37 |
page: z.number().int().min(1).default(1),
|
| 38 |
-
limit: z.number().int().min(1).max(
|
| 39 |
login: z.string().optional(),
|
| 40 |
apiKey: z.string().optional(),
|
| 41 |
});
|
|
|
|
| 35 |
site: SiteSchema,
|
| 36 |
tags: z.string().default(""),
|
| 37 |
page: z.number().int().min(1).default(1),
|
| 38 |
+
limit: z.number().int().min(1).max(320).default(40),
|
| 39 |
login: z.string().optional(),
|
| 40 |
apiKey: z.string().optional(),
|
| 41 |
});
|
src/routes/api/download-zip.ts
CHANGED
|
@@ -23,7 +23,7 @@ const PostSchema = z.object({
|
|
| 23 |
|
| 24 |
const BodySchema = z.object({
|
| 25 |
siteName: z.string().default("grabber"),
|
| 26 |
-
posts: z.array(PostSchema).min(1).max(
|
| 27 |
excludeTags: z.array(z.string()).default([]),
|
| 28 |
zipName: z.string().optional(),
|
| 29 |
downloadType: z.enum(["original", "sample"]).default("original"),
|
|
|
|
| 23 |
|
| 24 |
const BodySchema = z.object({
|
| 25 |
siteName: z.string().default("grabber"),
|
| 26 |
+
posts: z.array(PostSchema).min(1).max(320),
|
| 27 |
excludeTags: z.array(z.string()).default([]),
|
| 28 |
zipName: z.string().optional(),
|
| 29 |
downloadType: z.enum(["original", "sample"]).default("original"),
|
src/routes/api/upload-to-dataset.ts
CHANGED
|
@@ -25,7 +25,7 @@ const PostSchema = z.object({
|
|
| 25 |
|
| 26 |
const BodySchema = z.object({
|
| 27 |
siteName: z.string().default("grabber"),
|
| 28 |
-
posts: z.array(PostSchema).min(1).max(
|
| 29 |
excludeTags: z.array(z.string()).default([]),
|
| 30 |
hfToken: z.string().min(1, "HF token is required"),
|
| 31 |
datasetName: z.string().min(1, "Dataset name is required"),
|
|
|
|
| 25 |
|
| 26 |
const BodySchema = z.object({
|
| 27 |
siteName: z.string().default("grabber"),
|
| 28 |
+
posts: z.array(PostSchema).min(1).max(320),
|
| 29 |
excludeTags: z.array(z.string()).default([]),
|
| 30 |
hfToken: z.string().min(1, "HF token is required"),
|
| 31 |
datasetName: z.string().min(1, "Dataset name is required"),
|
src/routes/index.tsx
CHANGED
|
@@ -41,7 +41,21 @@ function Grabber() {
|
|
| 41 |
const { sites, custom, addSite, removeSite, hydrated } = useSites();
|
| 42 |
const [siteId, setSiteId] = useState("e621");
|
| 43 |
const [tags, setTags] = useState("");
|
| 44 |
-
const [
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
const [page, setPage] = useState(1);
|
| 46 |
const [selected, setSelected] = useState<Set<string>>(new Set());
|
| 47 |
const [addOpen, setAddOpen] = useState(false);
|
|
@@ -234,7 +248,7 @@ function Grabber() {
|
|
| 234 |
site,
|
| 235 |
tags,
|
| 236 |
page: vars.page,
|
| 237 |
-
limit,
|
| 238 |
login: site.id === "e621" ? e621Username : undefined,
|
| 239 |
apiKey: site.id === "e621" ? e621ApiKey : undefined,
|
| 240 |
},
|
|
@@ -440,11 +454,24 @@ function Grabber() {
|
|
| 440 |
<Input
|
| 441 |
type="number"
|
| 442 |
min={1}
|
| 443 |
-
max={
|
| 444 |
value={limit}
|
| 445 |
-
onChange={(e) => setLimit(Number(e.target.value) ||
|
| 446 |
className="w-24"
|
|
|
|
| 447 |
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 448 |
<Button onClick={() => runSearch(1)} disabled={searchMut.isPending}>
|
| 449 |
{searchMut.isPending ? (
|
| 450 |
<Loader2 className="w-4 h-4 mr-1 animate-spin" />
|
|
|
|
| 41 |
const { sites, custom, addSite, removeSite, hydrated } = useSites();
|
| 42 |
const [siteId, setSiteId] = useState("e621");
|
| 43 |
const [tags, setTags] = useState("");
|
| 44 |
+
const [hardCap, setHardCapState] = useState(30);
|
| 45 |
+
const [limit, setLimit] = useState(30);
|
| 46 |
+
useEffect(() => {
|
| 47 |
+
try {
|
| 48 |
+
const v = Number(localStorage.getItem("grabber.hardCap"));
|
| 49 |
+
if (v >= 1) { setHardCapState(Math.min(320, v)); setLimit((l) => Math.min(l, v)); }
|
| 50 |
+
} catch (e) { console.warn("[hardCap] load failed", e); }
|
| 51 |
+
}, []);
|
| 52 |
+
const setHardCap = (n: number) => {
|
| 53 |
+
const v = Math.max(1, Math.min(320, Math.floor(n) || 30));
|
| 54 |
+
setHardCapState(v);
|
| 55 |
+
setLimit((l) => Math.min(l, v));
|
| 56 |
+
try { localStorage.setItem("grabber.hardCap", String(v)); } catch {}
|
| 57 |
+
console.log("[hardCap] set to", v);
|
| 58 |
+
};
|
| 59 |
const [page, setPage] = useState(1);
|
| 60 |
const [selected, setSelected] = useState<Set<string>>(new Set());
|
| 61 |
const [addOpen, setAddOpen] = useState(false);
|
|
|
|
| 248 |
site,
|
| 249 |
tags,
|
| 250 |
page: vars.page,
|
| 251 |
+
limit: Math.min(limit, hardCap),
|
| 252 |
login: site.id === "e621" ? e621Username : undefined,
|
| 253 |
apiKey: site.id === "e621" ? e621ApiKey : undefined,
|
| 254 |
},
|
|
|
|
| 454 |
<Input
|
| 455 |
type="number"
|
| 456 |
min={1}
|
| 457 |
+
max={hardCap}
|
| 458 |
value={limit}
|
| 459 |
+
onChange={(e) => setLimit(Math.min(hardCap, Math.max(1, Number(e.target.value) || 1)))}
|
| 460 |
className="w-24"
|
| 461 |
+
title="Images per search"
|
| 462 |
/>
|
| 463 |
+
<label className="flex items-center gap-1 text-xs text-muted-foreground">
|
| 464 |
+
Max cap
|
| 465 |
+
<Input
|
| 466 |
+
type="number"
|
| 467 |
+
min={1}
|
| 468 |
+
max={320}
|
| 469 |
+
value={hardCap}
|
| 470 |
+
onChange={(e) => setHardCap(Number(e.target.value))}
|
| 471 |
+
className="w-20"
|
| 472 |
+
aria-label="Max cap"
|
| 473 |
+
/>
|
| 474 |
+
</label>
|
| 475 |
<Button onClick={() => runSearch(1)} disabled={searchMut.isPending}>
|
| 476 |
{searchMut.isPending ? (
|
| 477 |
<Loader2 className="w-4 h-4 mr-1 animate-spin" />
|