refactor: use unique ID for audio file and episode

This commit is contained in:
2025-06-04 14:32:07 +09:00
committed by Satsuki Akiba (aider)
parent 1d6a6e1ee6
commit 93d87c5997
2 changed files with 4 additions and 4 deletions

View File

@ -82,9 +82,9 @@ async function main() {
.createHash("md5") .createHash("md5")
.update(category) .update(category)
.digest("hex"); .digest("hex");
const uniqueFilename = `${feedUrlHash}-${categoryHash}.wav`; const uniqueId = `${feedUrlHash}-${categoryHash}.wav`;
const audioFilePath = await generateTTS(uniqueFilename, podcastContent); const audioFilePath = await generateTTS(uniqueId, podcastContent);
console.log(`音声ファイル生成完了: ${audioFilePath}`); console.log(`音声ファイル生成完了: ${audioFilePath}`);
// エピソードとして保存各フィードにつき1つの統合エピソード // エピソードとして保存各フィードにつき1つの統合エピソード
@ -96,7 +96,7 @@ async function main() {
const pub = new Date(firstItem.pubDate || ""); const pub = new Date(firstItem.pubDate || "");
await saveEpisode({ await saveEpisode({
id: `topic-${categoryHash}`, id: uniqueId,
title: `${category}: ${feedTitle}`, title: `${category}: ${feedTitle}`,
pubDate: pub.toISOString(), pubDate: pub.toISOString(),
audioPath: audioFilePath, audioPath: audioFilePath,

View File

@ -63,7 +63,7 @@ export async function generateTTS(
const filePath = path.resolve(outputDir, itemId); // Use the provided filename directly const filePath = path.resolve(outputDir, itemId); // Use the provided filename directly
console.log(`音声ファイル保存開始: ${filePath}`); console.log(`音声ファイル保存開始: ${filePath}`);
fs.writeFileSync(filePath, audioBuffer); fs.writeFileSync(`${filePath}.wav`, audioBuffer);
console.log(`音声ファイル保存完了: ${filePath}`); console.log(`音声ファイル保存完了: ${filePath}`);
return path.basename(filePath); return path.basename(filePath);