refactor: use unique ID for audio file and episode
This commit is contained in:
		@@ -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,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user