This commit is contained in:
2025-06-07 13:45:48 +09:00
parent d642b913ab
commit 9580740398
18 changed files with 936 additions and 1669 deletions

View File

@ -45,9 +45,22 @@ function createItemXml(episode: Episode): string {
export async function updatePodcastRSS(): Promise<void> {
try {
const episodes: Episode[] = await fetchAllEpisodes();
const lastBuildDate = new Date().toUTCString();
// Filter episodes to only include those with valid audio files
const validEpisodes = episodes.filter(episode => {
try {
const audioPath = path.join(config.paths.podcastAudioDir, episode.audioPath);
return fsSync.existsSync(audioPath);
} catch (error) {
console.warn(`Audio file not found for episode: ${episode.title}`);
return false;
}
});
const itemsXml = episodes.map(createItemXml).join("\n");
console.log(`Found ${episodes.length} episodes, ${validEpisodes.length} with valid audio files`);
const lastBuildDate = new Date().toUTCString();
const itemsXml = validEpisodes.map(createItemXml).join("\n");
const outputPath = path.join(config.paths.publicDir, "podcast.xml");
// Create RSS XML content
@ -69,7 +82,7 @@ export async function updatePodcastRSS(): Promise<void> {
await fs.mkdir(dirname(outputPath), { recursive: true });
await fs.writeFile(outputPath, rssXml);
console.log(`RSS feed updated with ${episodes.length} episodes`);
console.log(`RSS feed updated with ${validEpisodes.length} episodes (audio files verified)`);
} catch (error) {
console.error("Error updating podcast RSS:", error);
throw error;