save changes

This commit is contained in:
2025-09-25 21:49:44 +02:00
parent 39ea45fade
commit 28aa838937
2 changed files with 8 additions and 4 deletions

View File

@ -41,8 +41,8 @@ type ServerCfg = { baseUrl: string; outputDir: string; inputDir: string };
function getServerConfig(): ServerCfg { function getServerConfig(): ServerCfg {
const candidates = [ const candidates = [
{ baseUrl: process.env.SERVER1_COMFY_BASE_URL, outputDir: process.env.SERVER1_COMFY_OUTPUT_DIR }, //{ baseUrl: process.env.SERVER1_COMFY_BASE_URL, outputDir: process.env.SERVER1_COMFY_OUTPUT_DIR },
//{ baseUrl: process.env.SERVER2_COMFY_BASE_URL, outputDir: process.env.SERVER2_COMFY_OUTPUT_DIR }, { baseUrl: process.env.SERVER2_COMFY_BASE_URL, outputDir: process.env.SERVER2_COMFY_OUTPUT_DIR },
].filter((s): s is { baseUrl: string; outputDir: string } => !!s.baseUrl && !!s.outputDir); ].filter((s): s is { baseUrl: string; outputDir: string } => !!s.baseUrl && !!s.outputDir);
if (candidates.length === 0) { if (candidates.length === 0) {
@ -78,7 +78,7 @@ async function collectImages(keyword: string, total: number): Promise<string[]>
if (!pinUrl) { if (!pinUrl) {
logger.warn('No pin URL found, retrying...'); logger.warn('No pin URL found, retrying...');
await sleep(1500); await sleep(1500);
continue; return [];
} }
const remaining = total - results.length; const remaining = total - results.length;
// attempt to grab up to 5 per pin to reduce churn // attempt to grab up to 5 per pin to reduce churn
@ -146,6 +146,10 @@ async function main() {
try { try {
const images = await collectImages(KEYWORD, TARGET_COUNT); const images = await collectImages(KEYWORD, TARGET_COUNT);
logger.info(`Collected ${images.length} image(s). Starting conversion...`); logger.info(`Collected ${images.length} image(s). Starting conversion...`);
if (images.length == 0)
continue;
await processImages(images, server); await processImages(images, server);
logger.info('Iteration completed. Sleeping before next cycle...'); logger.info('Iteration completed. Sleeping before next cycle...');
} catch (err) { } catch (err) {

View File

@ -5,7 +5,7 @@ import path from 'path';
import puppeteer from 'puppeteer'; import puppeteer from 'puppeteer';
export async function getPinUrlFromPinterest(keyword: string): Promise<string | null> { export async function getPinUrlFromPinterest(keyword: string): Promise<string | null> {
const browser = await puppeteer.launch({ headless: true }); const browser = await puppeteer.launch({ headless: false });
const page = await browser.newPage(); const page = await browser.newPage();
await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36'); await page.setUserAgent('Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36');
await page.setViewport({ width: 1920, height: 1080 }); await page.setViewport({ width: 1920, height: 1080 });