feat: migrate to bun runtime and update dependencies

This commit is contained in:
2025-06-04 08:41:53 +09:00
committed by Satsuki Akiba (aider)
parent bfb6367a56
commit 4db363068d
7 changed files with 61 additions and 32 deletions

View File

@ -1,4 +1,4 @@
import Database from "better-sqlite3";
import { Database } from "bun:sqlite";
import path from "path";
const dbPath = path.join(__dirname, "../data/podcast.db");
@ -28,17 +28,26 @@ export interface Episode {
sourceLink: string;
}
export async function markAsProcessed(feedUrl: string, itemId: string): Promise<boolean> {
const stmt = db.prepare("SELECT 1 FROM processed_feed_items WHERE feed_url = ? AND item_id = ?");
export async function markAsProcessed(
feedUrl: string,
itemId: string,
): Promise<boolean> {
const stmt = db.prepare(
"SELECT 1 FROM processed_feed_items WHERE feed_url = ? AND item_id = ?",
);
const row = stmt.get(feedUrl, itemId);
if (row) return true;
const insert = db.prepare("INSERT INTO processed_feed_items (feed_url, item_id, processed_at) VALUES (?, ?, ?)");
const insert = db.prepare(
"INSERT INTO processed_feed_items (feed_url, item_id, processed_at) VALUES (?, ?, ?)",
);
insert.run(feedUrl, itemId, new Date().toISOString());
return false;
}
export async function saveEpisode(ep: Episode): Promise<void> {
const stmt = db.prepare("INSERT OR IGNORE INTO episodes (id, title, pubDate, audioPath, sourceLink) VALUES (?, ?, ?, ?, ?)");
const stmt = db.prepare(
"INSERT OR IGNORE INTO episodes (id, title, pubDate, audioPath, sourceLink) VALUES (?, ?, ?, ?, ?)",
);
stmt.run(ep.id, ep.title, ep.pubDate, ep.audioPath, ep.sourceLink);
}

View File

@ -7,13 +7,14 @@ export async function updatePodcastRSS() {
const channelTitle = "自動生成ポッドキャスト";
const channelLink = "https://your-domain.com/podcast";
const channelDescription = "RSSフィードから自動生成されたポッドキャストです。";
const channelDescription =
"RSSフィードから自動生成されたポッドキャストです。";
const lastBuildDate = new Date().toUTCString();
let itemsXml = "";
for (const ep of episodes) {
const fileUrl = `https://your-domain.com/podcast_audio/${path.basename(
ep.audioPath
ep.audioPath,
)}`;
const pubDate = new Date(ep.pubDate).toUTCString();
itemsXml += `

View File

@ -1,15 +1,12 @@
import fs from "fs";
import path from "path";
import {
PollyClient,
SynthesizeSpeechCommand,
} from "@aws-sdk/client-polly";
import { PollyClient, SynthesizeSpeechCommand } from "@aws-sdk/client-polly";
const polly = new PollyClient({ region: "ap-northeast-1" });
export async function generateTTS(
itemId: string,
scriptText: string
scriptText: string,
): Promise<string> {
const params = {
OutputFormat: "mp3",