save latest changes

This commit is contained in:
2025-08-27 11:17:34 +02:00
parent 3d239d039b
commit d4028e8f7f
3 changed files with 30 additions and 23 deletions

View File

@ -51,8 +51,8 @@ async function getPromptsForImage(imagePath: string, pinUrl: string, genre: stri
1. 'scene': A description of the image's environment.
2. 'action': A description of the main action occurring in the image.
3. 'camera': A description of the camera shot (e.g., 'close-up', 'wide-angle').
4. 'image_prompt': A highly detailed, creative, and artistic prompt for an image generation model, inspired by the original. This prompt should be around 200 words.
5. 'video_prompt': A prompt for an 8-second video, describing a creative and subtle movement of the main object. The camera should be static, but slight panning is acceptable.
4. 'image_prompt': A short and detailed prompt to generate this photo.
5. 'video_prompt': A prompt describing a creative and subtle movement of the main object. The camera should be slight panning or static.
Output should be in this JSON format:
---
@ -60,7 +60,7 @@ async function getPromptsForImage(imagePath: string, pinUrl: string, genre: stri
"scene": "{result comes here}",
"action": "{result comes here}",
"camera": "{result comes here}",
"image_prompt": "Ultra detailed illustration, {result comes here}",
"image_prompt": "{result comes here}",
"video_prompt": "{result comes here}"
}
---
@ -92,7 +92,7 @@ async function generateImageAndVideo(task: GenerationTask, server: { baseUrl: st
logger.info(`Copied ${renamedImagePath} to ${destPath}`);
const videoFileName = imageFileName.replace('.png', '.mp4');
await generateStyledVideo(
const { videoPath, imagePath } = await generateStyledVideo(
imagePrompt,
videoPrompt,
imageFileName,
@ -101,8 +101,8 @@ async function generateImageAndVideo(task: GenerationTask, server: { baseUrl: st
outputDir,
{ width: 720, height: 1280 }
);
const videoPath = path.join(outputDir, videoFileName);
return { imagePath: destPath, videoPath };
path.join(outputDir, videoFileName);
return { imagePath: imagePath, videoPath };
} catch (error) {
logger.error(`Failed to generate styled video for ${imageFileName} on server ${baseUrl}:`, error);
return null;
@ -196,16 +196,14 @@ async function getPinUrlFromPinterest(keyword: string): Promise<string | null> {
(async () => {
const keywords = [
{ genre: "fantasy", subGenre: "ethereal" },
{ genre: "fantasy", subGenre: "academia" },
{ genre: "fantasy", subGenre: "darkacademia" },
{ genre: "fantasy", subGenre: "illumication" },
{ genre: "fantasy", subGenre: "aesthetic" },
{ genre: "abstract", subGenre: "particle" },
{ genre: "abstract", subGenre: "space" },
{ genre: "abstract", subGenre: "science" },
{ genre: "abstract", subGenre: "sphere" },
{ genre: "abstract", subGenre: "cubic" },
{ genre: "fantasy", subGenre: "ethereal", pinId: "311311393008071543" },
{ genre: "fantasy", subGenre: "ethereal", pinId: "1688918605889326" },
{ genre: "fantasy", subGenre: "ethereal", pinId: "4925880837133615" },
{ genre: "fantasy", subGenre: "ethereal", pinId: "985231163711528" },
{ genre: "fantasy", subGenre: "dark ethereal", pinId: "768497123954670531" },
{ genre: "fantasy", subGenre: "dark ethereal", pinId: "5840674510388768" },
{ genre: "fantasy", subGenre: "dark ethereal", pinId: "281123201734741654" },
{ genre: "fantasy", subGenre: "dark ethereal", pinId: "41306521578186951" },
];
if (servers.length === 0) {
@ -219,12 +217,21 @@ async function getPinUrlFromPinterest(keyword: string): Promise<string | null> {
const { genre, subGenre } = genreSubGenre;
const keyword = `${genre} ${subGenre}`;
logger.info(`Searching for a pin with keyword: ${keyword}`);
const pin = await getPinUrlFromPinterest(keyword);
const pinId = (genreSubGenre as any).pinId;
let pin: string | null = null;
if (pinId) {
pin = `https://www.pinterest.com/pin/${pinId}/`;
logger.info(`Using direct pin URL for pinId: ${pinId}`);
} /* else {
// Uncomment the block below to enable searching by term instead of using pinId.
// const searchTerm = (genreSubGenre as any).search || `${genre} ${subGenre}`;
// logger.info(`Searching for a pin with search term: ${searchTerm}`);
// pin = await getPinUrlFromPinterest(searchTerm);
} */
if (!pin) {
logger.warn(`Could not find a pin for keyword: ${keyword}. Skipping.`);
logger.warn(`No pinId provided and search is disabled for genre: ${genre}, subGenre: ${subGenre}. Skipping.`);
continue;
}