Update category management and RSS endpoint handling

This commit is contained in:
2025-06-08 21:50:31 +09:00
parent 4aa1b5c56a
commit cd0e4065fc
13 changed files with 1171 additions and 70 deletions

View File

@ -14,6 +14,7 @@ import {
} from "../services/database.js";
import {
openAI_ClassifyFeed,
openAI_ClassifyEpisode,
openAI_GeneratePodcastContent,
} from "../services/llm.js";
import { updatePodcastRSS } from "../services/podcast.js";
@ -352,7 +353,7 @@ async function processRetryQueue(abortSignal?: AbortSignal): Promise<void> {
await updateQueueItemStatus(item.id, "processing");
// Attempt TTS generation without re-queuing on failure
const audioFilePath = await generateTTSWithoutQueue(
await generateTTSWithoutQueue(
item.itemId,
item.scriptText,
item.retryCount,
@ -448,25 +449,13 @@ async function generatePodcastForArticle(
}
// Get feed information for context
const feed = await getFeedById(article.feedId);
const feedTitle = feed?.title || "Unknown Feed";
await getFeedById(article.feedId);
// Check for cancellation before classification
if (abortSignal?.aborted) {
throw new Error("Podcast generation was cancelled");
}
// Classify the article/feed
const category = await openAI_ClassifyFeed(
`${feedTitle}: ${article.title}`,
);
console.log(`🏷️ Article classified as: ${category}`);
// Check for cancellation before content generation
if (abortSignal?.aborted) {
throw new Error("Podcast generation was cancelled");
}
// Enhance article content with web scraping if needed
console.log(`🔍 Enhancing content for: ${article.title}`);
const enhancedContent = await enhanceArticleContent(
@ -476,6 +465,11 @@ async function generatePodcastForArticle(
article.description,
);
// Check for cancellation before content generation
if (abortSignal?.aborted) {
throw new Error("Podcast generation was cancelled");
}
// Generate podcast content for this single article
const podcastContent = await openAI_GeneratePodcastContent(article.title, [
{
@ -486,6 +480,15 @@ async function generatePodcastForArticle(
},
]);
// Classify the episode based on the podcast content
console.log(`🏷️ Classifying episode content for: ${article.title}`);
const episodeCategory = await openAI_ClassifyEpisode(
article.title,
enhancedContent.description,
enhancedContent.content,
);
console.log(`🏷️ Episode classified as: ${episodeCategory}`);
// Check for cancellation before TTS
if (abortSignal?.aborted) {
throw new Error("Podcast generation was cancelled");
@ -544,12 +547,13 @@ async function generatePodcastForArticle(
try {
await saveEpisode({
articleId: article.id,
title: `${category}: ${article.title}`,
title: article.title,
description:
article.description || `Podcast episode for: ${article.title}`,
audioPath: audioFilePath,
duration: audioStats.duration,
fileSize: audioStats.size,
category: episodeCategory,
});
console.log(`💾 Episode saved for article: ${article.title}`);