Skip to content

Commit 9065e18

Browse files
Remove YOUTUBE_PLAYLIST_URL config
Co-authored-by: Kent C. Dodds <me+github@kentcdodds.com>
1 parent 8ded19b commit 9065e18

File tree

5 files changed

+17
-45
lines changed

5 files changed

+17
-45
lines changed

.env.example

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ R2_SECRET_ACCESS_KEY=MOCK_R2_SECRET_ACCESS_KEY
121121
SEMANTIC_SEARCH_IGNORE_LIST_KEY=manifests/ignore-list.json
122122

123123
# Feature: YouTube playlist semantic indexing + /youtube route
124-
# Optional: set either playlist URL or playlist ID.
125-
YOUTUBE_PLAYLIST_URL=https://www.youtube.com/watch?v=wSEUlS8WcQs&list=PLV5CVI1eNcJgNqzNwcs4UKrlJdhfDjshf
124+
# Optional: set playlist ID.
126125
YOUTUBE_PLAYLIST_ID=PLV5CVI1eNcJgNqzNwcs4UKrlJdhfDjshf
127126
# Optional: helps bypass YouTube anti-bot checks for captions in some envs.
128127
YOUTUBE_COOKIE=MOCK_YOUTUBE_COOKIE

.github/workflows/index-semantic-youtube.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,9 @@ jobs:
4747
${{ secrets.CLOUDFLARE_AI_EMBEDDING_MODEL }}
4848
R2_BUCKET: ${{ secrets.R2_BUCKET }}
4949

50-
# Prefer setting one of these as repository variables.
51-
# If neither is set, the script uses a built-in default playlist ID.
52-
YOUTUBE_PLAYLIST_URL: ${{ vars.YOUTUBE_PLAYLIST_URL }}
53-
YOUTUBE_PLAYLIST_ID: ${{ vars.YOUTUBE_PLAYLIST_ID }}
50+
# Prefer setting as a repository variable (or secret).
51+
# If not set, the script uses a built-in default playlist ID.
52+
YOUTUBE_PLAYLIST_ID: ${{ vars.YOUTUBE_PLAYLIST_ID || secrets.YOUTUBE_PLAYLIST_ID }}
5453

5554
# Optional: force-index specific videos. Can be set either as a
5655
# workflow_dispatch input or as a repository variable.

app/routes/youtube.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ function parsePlaylistId(value: string | undefined) {
4646
}
4747

4848
export async function loader() {
49-
const playlistInput =
50-
process.env.YOUTUBE_PLAYLIST_URL ?? process.env.YOUTUBE_PLAYLIST_ID
49+
const playlistInput = process.env.YOUTUBE_PLAYLIST_ID
5150
const configuredPlaylistId =
5251
parsePlaylistId(playlistInput) ?? DEFAULT_PLAYLIST_ID
5352
return json({

other/semantic-search/index-youtube-playlist.ts

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -292,15 +292,10 @@ function collectObjectsByKey(
292292
return result
293293
}
294294

295-
function firstNonEmptyTrimmed(
296-
...values: Array<string | undefined | null>
297-
): string | undefined {
298-
for (const value of values) {
299-
if (typeof value !== 'string') continue
300-
const trimmed = value.trim()
301-
if (trimmed) return trimmed
302-
}
303-
return undefined
295+
function nonEmptyTrimmed(value: string | undefined | null): string | undefined {
296+
if (typeof value !== 'string') return undefined
297+
const trimmed = value.trim()
298+
return trimmed ? trimmed : undefined
304299
}
305300

306301
/**
@@ -321,23 +316,6 @@ function getYouTubePlaylistId(input: string | undefined | null): string | null {
321316
}
322317
}
323318

324-
function resolveYouTubePlaylistInput({
325-
playlistArg,
326-
playlistUrlEnv,
327-
playlistIdEnv,
328-
defaultPlaylistId,
329-
}: {
330-
playlistArg?: string | undefined
331-
playlistUrlEnv?: string | undefined
332-
playlistIdEnv?: string | undefined
333-
defaultPlaylistId: string
334-
}): string {
335-
return (
336-
firstNonEmptyTrimmed(playlistArg, playlistUrlEnv, playlistIdEnv) ??
337-
defaultPlaylistId
338-
)
339-
}
340-
341319
function extractYoutubeVideoId(rawUrl: string) {
342320
let parsed: URL
343321
try {
@@ -1229,16 +1207,14 @@ async function main() {
12291207
prune,
12301208
dryRun,
12311209
} = parseArgs()
1232-
const playlistInput = resolveYouTubePlaylistInput({
1233-
playlistArg,
1234-
playlistUrlEnv: process.env.YOUTUBE_PLAYLIST_URL,
1235-
playlistIdEnv: process.env.YOUTUBE_PLAYLIST_ID,
1236-
defaultPlaylistId: DEFAULT_PLAYLIST_ID,
1237-
})
1210+
const playlistInput =
1211+
nonEmptyTrimmed(playlistArg) ??
1212+
nonEmptyTrimmed(process.env.YOUTUBE_PLAYLIST_ID) ??
1213+
DEFAULT_PLAYLIST_ID
12381214
const playlistId = getYouTubePlaylistId(playlistInput)
12391215
if (!playlistId) {
12401216
throw new Error(
1241-
`Invalid YouTube playlist input: "${playlistInput}". Use --playlist with a playlist URL or ID.`,
1217+
`Invalid YouTube playlist input: "${playlistInput}". Use --playlist with a playlist URL or ID, or set YOUTUBE_PLAYLIST_ID.`,
12421218
)
12431219
}
12441220

other/semantic-search/readme.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ For podcast indexing:
3535

3636
For YouTube playlist indexing (optional but recommended as repo variables):
3737

38-
- `YOUTUBE_PLAYLIST_URL` (full URL with `list=...`) **or**
39-
- `YOUTUBE_PLAYLIST_ID` (playlist ID only)
38+
- `YOUTUBE_PLAYLIST_ID` (playlist ID)
4039
- Optional (helps when YouTube returns anti-bot `LOGIN_REQUIRED`):
4140
- `YOUTUBE_COOKIE` (cookie header value from a logged-in browser session)
4241
- `YOUTUBE_USER_AGENT`
@@ -89,8 +88,8 @@ Script:
8988

9089
Optional flags:
9190

92-
- `--playlist "<url-or-id>"` (defaults to `YOUTUBE_PLAYLIST_URL`,
93-
`YOUTUBE_PLAYLIST_ID`, or a built-in default playlist ID)
91+
- `--playlist "<url-or-id>"` (defaults to `YOUTUBE_PLAYLIST_ID` or a built-in
92+
default playlist ID)
9493
- `--max-videos 50` (helpful for staged/backfill runs)
9594
- `--include-auto-captions false` (manual captions only)
9695
- `--manifest-key manifests/youtube-my-playlist.json`

0 commit comments

Comments
 (0)