feat: use audio path for episode player and tts file name
This commit is contained in:
@ -36,7 +36,7 @@ export default function EpisodePlayer() {
|
|||||||
|
|
||||||
const handlePlay = (episode: Episode) => {
|
const handlePlay = (episode: Episode) => {
|
||||||
setSelectedEpisode(episode);
|
setSelectedEpisode(episode);
|
||||||
setAudioUrl(`/podcast_audio/${episode.id}.mp3`);
|
setAudioUrl(`/podcast_audio/${episode.audioPath}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
if (loading) return <div>読み込み中...</div>;
|
if (loading) return <div>読み込み中...</div>;
|
||||||
@ -68,11 +68,7 @@ export default function EpisodePlayer() {
|
|||||||
再生中: {selectedEpisode.title}
|
再生中: {selectedEpisode.title}
|
||||||
</h4>
|
</h4>
|
||||||
{audioUrl ? (
|
{audioUrl ? (
|
||||||
<audio
|
<audio src={audioUrl} controls className="w-full" />
|
||||||
src={audioUrl}
|
|
||||||
controls
|
|
||||||
className="w-full"
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<div>音声ファイルを読み込み中...</div>
|
<div>音声ファイルを読み込み中...</div>
|
||||||
)}
|
)}
|
||||||
|
@ -56,10 +56,12 @@ export async function updatePodcastRSS() {
|
|||||||
|
|
||||||
if (existingXml) {
|
if (existingXml) {
|
||||||
// 既存のitem部分を抽出
|
// 既存のitem部分を抽出
|
||||||
const existingItemsMatch = existingXml.match(/<channel>([\s\S]*?)<\/channel>/);
|
const existingItemsMatch = existingXml.match(
|
||||||
|
/<channel>([\s\S]*?)<\/channel>/,
|
||||||
|
);
|
||||||
if (existingItemsMatch) {
|
if (existingItemsMatch) {
|
||||||
const existingItems = existingItemsMatch[1];
|
const existingItems = existingItemsMatch[1];
|
||||||
const newItemStartIndex = existingItems.lastIndexOf("<item>");
|
const newItemStartIndex = existingItems!.lastIndexOf("<item>");
|
||||||
|
|
||||||
// 新しいitemを追加
|
// 新しいitemを追加
|
||||||
const updatedItems = existingItems + itemsXml;
|
const updatedItems = existingItems + itemsXml;
|
||||||
@ -67,13 +69,13 @@ export async function updatePodcastRSS() {
|
|||||||
// lastBuildDateを更新
|
// lastBuildDateを更新
|
||||||
const updatedXml = existingXml.replace(
|
const updatedXml = existingXml.replace(
|
||||||
/<lastBuildDate>.*?<\/lastBuildDate>/,
|
/<lastBuildDate>.*?<\/lastBuildDate>/,
|
||||||
`<lastBuildDate>${lastBuildDate}</lastBuildDate>`
|
`<lastBuildDate>${lastBuildDate}</lastBuildDate>`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// items部分を置き換え
|
// items部分を置き換え
|
||||||
const finalXml = updatedXml.replace(
|
const finalXml = updatedXml.replace(
|
||||||
/<channel>[\s\S]*?<\/channel>/,
|
/<channel>[\s\S]*?<\/channel>/,
|
||||||
`<channel>${updatedItems}</channel>`
|
`<channel>${updatedItems}</channel>`,
|
||||||
);
|
);
|
||||||
|
|
||||||
// ファイルに書き込み
|
// ファイルに書き込み
|
||||||
|
@ -66,5 +66,5 @@ export async function generateTTS(
|
|||||||
fs.writeFileSync(filePath, audioBuffer);
|
fs.writeFileSync(filePath, audioBuffer);
|
||||||
console.log(`音声ファイル保存完了: ${filePath}`);
|
console.log(`音声ファイル保存完了: ${filePath}`);
|
||||||
|
|
||||||
return filePath;
|
return path.basename(filePath);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user