- fix: resolve TypeScript errors in EpisodePlayer and podcast service
This commit is contained in:
@ -14,7 +14,6 @@ export default function EpisodePlayer() {
|
|||||||
const [audioUrl, setAudioUrl] = useState<string | null>(null);
|
const [audioUrl, setAudioUrl] = useState<string | null>(null);
|
||||||
const [loading, setLoading] = useState(true);
|
const [loading, setLoading] = useState(true);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
const [isPlaying, setIsPlaying] = useState(false);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchEpisodes();
|
fetchEpisodes();
|
||||||
|
@ -1,24 +1,29 @@
|
|||||||
import { promises as fs } from "fs";
|
import { promises as fs } from "fs";
|
||||||
import { join, dirname } from "path";
|
import { join, dirname } from "path";
|
||||||
import { Episode, fetchAllEpisodes } from "./database";
|
import { Episode, fetchAllEpisodes } from "./database";
|
||||||
|
import path from "node:path";
|
||||||
|
import fsSync from "node:fs";
|
||||||
|
|
||||||
export async function updatePodcastRSS() {
|
export async function updatePodcastRSS() {
|
||||||
const episodes: Episode[] = await fetchAllEpisodes();
|
const episodes: Episode[] = await fetchAllEpisodes();
|
||||||
|
|
||||||
const channelTitle = process.env.PODCAST_TITLE ?? "自動生成ポッドキャスト";
|
const channelTitle = process.env["PODCAST_TITLE"] ?? "自動生成ポッドキャスト";
|
||||||
const channelLink = process.env.PODCAST_LINK ?? "https://your-domain.com/podcast";
|
const channelLink =
|
||||||
|
process.env["PODCAST_LINK"] ?? "https://your-domain.com/podcast";
|
||||||
const channelDescription =
|
const channelDescription =
|
||||||
process.env.PODCAST_DESCRIPTION ?? "RSSフィードから自動生成された音声ポッドキャスト";
|
process.env["PODCAST_DESCRIPTION"] ??
|
||||||
const channelLanguage = process.env.PODCAST_LANGUAGE ?? "ja";
|
"RSSフィードから自動生成された音声ポッドキャスト";
|
||||||
const channelAuthor = process.env.PODCAST_AUTHOR ?? "管理者";
|
const channelLanguage = process.env["PODCAST_LANGUAGE"] ?? "ja";
|
||||||
const channelCategories = process.env.PODCAST_CATEGORIES ?? "Technology";
|
const channelAuthor = process.env["PODCAST_AUTHOR"] ?? "管理者";
|
||||||
const channelTTL = process.env.PODCAST_TTL ?? "60";
|
const channelCategories = process.env["PODCAST_CATEGORIES"] ?? "Technology";
|
||||||
|
const channelTTL = process.env["PODCAST_TTL"] ?? "60";
|
||||||
const lastBuildDate = new Date().toUTCString();
|
const lastBuildDate = new Date().toUTCString();
|
||||||
|
|
||||||
let itemsXml = "";
|
let itemsXml = "";
|
||||||
for (const ep of episodes) {
|
for (const ep of episodes) {
|
||||||
const fileUrl = `https://your-domain.com/podcast_audio/${path.basename(ep.audioPath)}`;
|
const fileUrl = `https://your-domain.com/podcast_audio/${path.basename(ep.audioPath)}`;
|
||||||
const pubDate = new Date(ep.pubDate).toUTCString();
|
const pubDate = new Date(ep.pubDate).toUTCString();
|
||||||
|
const fileSize = fsSync.statSync(ep.audioPath).size;
|
||||||
itemsXml += `
|
itemsXml += `
|
||||||
<item>
|
<item>
|
||||||
<title><![CDATA[${ep.title}]]></title>
|
<title><![CDATA[${ep.title}]]></title>
|
||||||
@ -27,7 +32,7 @@ export async function updatePodcastRSS() {
|
|||||||
<category>${channelCategories}</category>
|
<category>${channelCategories}</category>
|
||||||
<language>${channelLanguage}</language>
|
<language>${channelLanguage}</language>
|
||||||
<ttl>${channelTTL}</ttl>
|
<ttl>${channelTTL}</ttl>
|
||||||
<enclosure url="${fileUrl}" length="${fs.statSync(ep.audioPath).size}" type="audio/mpeg" />
|
<enclosure url="${fileUrl}" length="${fileSize}" type="audio/mpeg" />
|
||||||
<guid>${fileUrl}</guid>
|
<guid>${fileUrl}</guid>
|
||||||
<pubDate>${pubDate}</pubDate>
|
<pubDate>${pubDate}</pubDate>
|
||||||
</item>
|
</item>
|
||||||
|
Reference in New Issue
Block a user