Skip to content

Commit 3aee602

Browse files
authored
Merge pull request #216 from GalvinPython/copilot/create-youtube-update-script
feat: standalone YouTube DB update script
2 parents fae2820 + 42574d5 commit 3aee602

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"web:build": "cd web && bun build",
4040
"start:api": "echo 'Cannot start API without cargo. Reserved for future use' && exit 1",
4141
"start:bot": "bun run src/bot.ts",
42-
"start:web": "cd web && bun start"
42+
"start:web": "cd web && bun start",
43+
"update:youtube": "bun src/updateYouTube.ts"
4344
},
4445
"dependencies": {
4546
"cron": "^4.3.0",

src/updateYouTube.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { env } from "./config.ts";
2+
import fetchLatestUploads from "./utils/youtube/fetchLatestUploads.ts";
3+
4+
if (!env.youtubeApiKey || env.youtubeApiKey === "YOUR_YOUTUBE_API_KEY") {
5+
throw new Error("You MUST provide a YouTube API key in .env!");
6+
}
7+
8+
console.log("Starting standalone YouTube database update...");
9+
10+
const updateSucceeded = await fetchLatestUploads();
11+
12+
if (updateSucceeded === true) {
13+
console.log("YouTube database update complete.");
14+
process.exit(0);
15+
}
16+
17+
console.error("YouTube database update failed.");
18+
process.exit(1);

0 commit comments

Comments
 (0)