apix/lib/crawler.ts
KV-Pix Bot 6bf9f6e39c
Some checks failed
CI / build (18.x) (push) Has been cancelled
CI / build (20.x) (push) Has been cancelled
release: v2.5.0 - UI enhancements, pagination, and security
2026-01-16 22:08:26 +07:00

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 [];
}
}