Compare commits
2 Commits
4ccfd9ef3a
...
d362f9e0ca
| Author | SHA1 | Date | |
|---|---|---|---|
| d362f9e0ca | |||
| 28aa838937 |
@ -5,7 +5,7 @@ import path from 'path';
|
||||
import puppeteer from 'puppeteer';
|
||||
|
||||
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();
|
||||
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 });
|
||||
|
||||
@ -41,8 +41,8 @@ type ServerCfg = { baseUrl: string; outputDir: string; inputDir: string };
|
||||
|
||||
function getServerConfig(): ServerCfg {
|
||||
const candidates = [
|
||||
{ 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.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 },
|
||||
].filter((s): s is { baseUrl: string; outputDir: string } => !!s.baseUrl && !!s.outputDir);
|
||||
|
||||
if (candidates.length === 0) {
|
||||
@ -78,7 +78,7 @@ async function collectImages(keyword: string, total: number): Promise<string[]>
|
||||
if (!pinUrl) {
|
||||
logger.warn('No pin URL found, retrying...');
|
||||
await sleep(1500);
|
||||
continue;
|
||||
return [];
|
||||
}
|
||||
const remaining = total - results.length;
|
||||
// attempt to grab up to 5 per pin to reduce churn
|
||||
@ -146,6 +146,10 @@ async function main() {
|
||||
try {
|
||||
const images = await collectImages(KEYWORD, TARGET_COUNT);
|
||||
logger.info(`Collected ${images.length} image(s). Starting conversion...`);
|
||||
|
||||
if (images.length == 0)
|
||||
continue;
|
||||
|
||||
await processImages(images, server);
|
||||
logger.info('Iteration completed. Sleeping before next cycle...');
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user