54 lines
1.8 KiB
TypeScript
54 lines
1.8 KiB
TypeScript
import { Prompt } from '@/lib/types';
|
|
import fs from 'fs/promises';
|
|
import path from 'path';
|
|
|
|
export class HabuCrawler {
|
|
async crawl(): Promise<Prompt[]> {
|
|
console.log("[HabuCrawler] Reading from local data...");
|
|
const filePath = path.join(process.cwd(), 'data', 'habu_prompts.json');
|
|
try {
|
|
const data = await fs.readFile(filePath, 'utf-8');
|
|
const habuPrompts = JSON.parse(data);
|
|
|
|
return habuPrompts.map((p: any) => ({
|
|
id: 0, // Will be overwritten by sync service
|
|
title: p.name || 'Untitled Habu Prompt',
|
|
prompt: p.prompt,
|
|
category: 'Habu', // Default category since mapping is unknown
|
|
category_type: 'style',
|
|
description: p.prompt ? (p.prompt.substring(0, 150) + (p.prompt.length > 150 ? '...' : '')) : '',
|
|
images: p.imageUrl ? [p.imageUrl] : [],
|
|
author: 'Habu',
|
|
source: 'habu',
|
|
source_url: `https://taoanhez.com/#/prompt-library/${p.id}`,
|
|
createdAt: p.createdAt ? new Date(p.createdAt).getTime() : Date.now(),
|
|
useCount: 0
|
|
}));
|
|
} catch (e) {
|
|
console.error("[HabuCrawler] Error reading habu data", e);
|
|
return [];
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
export class JimmyLvCrawler {
|
|
async crawl(): Promise<Prompt[]> {
|
|
console.log("[JimmyLvCrawler] Crawling not implemented");
|
|
return [];
|
|
}
|
|
}
|
|
|
|
export class YouMindCrawler {
|
|
async crawl(): Promise<Prompt[]> {
|
|
console.log("[YouMindCrawler] Crawling not implemented");
|
|
return [];
|
|
}
|
|
}
|
|
|
|
export class ZeroLuCrawler {
|
|
async crawl(): Promise<Prompt[]> {
|
|
console.log("[ZeroLuCrawler] Crawling not implemented");
|
|
return [];
|
|
}
|
|
}
|