refactor: extract processFeedUrl function
This commit is contained in:
@ -24,7 +24,6 @@ const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
|
||||
async function main() {
|
||||
const parser = new Parser<FeedItem>();
|
||||
const feedUrlsFile = import.meta.env["FEED_URLS_FILE"] ?? "feed_urls.txt";
|
||||
const feedUrlsPath = path.resolve(__dirname, "..", feedUrlsFile);
|
||||
let feedUrls: string[];
|
||||
@ -41,6 +40,18 @@ async function main() {
|
||||
|
||||
// フィードごとに処理
|
||||
for (const url of feedUrls) {
|
||||
try {
|
||||
await processFeedUrl(url);
|
||||
} finally {
|
||||
await updatePodcastRSS();
|
||||
}
|
||||
}
|
||||
|
||||
console.log("処理完了:", new Date().toISOString());
|
||||
}
|
||||
|
||||
const processFeedUrl = async (url: string) => {
|
||||
const parser = new Parser<FeedItem>();
|
||||
const feed = await parser.parseURL(url);
|
||||
|
||||
// フィードのカテゴリ分類
|
||||
@ -78,10 +89,7 @@ async function main() {
|
||||
|
||||
// トピックごとの統合音声生成
|
||||
const feedUrlHash = crypto.createHash("md5").update(url).digest("hex");
|
||||
const categoryHash = crypto
|
||||
.createHash("md5")
|
||||
.update(category)
|
||||
.digest("hex");
|
||||
const categoryHash = crypto.createHash("md5").update(category).digest("hex");
|
||||
const uniqueId = `${feedUrlHash}-${categoryHash}`;
|
||||
|
||||
const audioFilePath = await generateTTS(uniqueId, podcastContent);
|
||||
@ -129,12 +137,7 @@ async function main() {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
await updatePodcastRSS();
|
||||
}
|
||||
|
||||
console.log("処理完了:", new Date().toISOString());
|
||||
}
|
||||
};
|
||||
|
||||
main().catch((err) => {
|
||||
console.error("エラー発生:", err);
|
||||
|
Reference in New Issue
Block a user