Skip to content

Commit 2cb5747

Browse files
Fix YouTube playlist ID env handling (#667)
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 302f753 commit 2cb5747

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

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

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

50-
# Prefer setting this as a repository variable.
50+
# Prefer setting this as a repository variable (or secret).
5151
# If it is not set, the script uses a built-in default playlist ID.
52-
YOUTUBE_PLAYLIST_ID: ${{ vars.YOUTUBE_PLAYLIST_ID }}
52+
YOUTUBE_PLAYLIST_ID:
53+
${{ vars.YOUTUBE_PLAYLIST_ID || secrets.YOUTUBE_PLAYLIST_ID }}
5354

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

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

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

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
299+
}
300+
295301
function getPlaylistId(input: string | undefined) {
296302
if (!input) return null
297303
const trimmed = input.trim()
@@ -1196,11 +1202,13 @@ async function main() {
11961202
dryRun,
11971203
} = parseArgs()
11981204
const playlistInput =
1199-
playlistArg ?? process.env.YOUTUBE_PLAYLIST_ID ?? DEFAULT_PLAYLIST_ID
1205+
nonEmptyTrimmed(playlistArg) ??
1206+
nonEmptyTrimmed(process.env.YOUTUBE_PLAYLIST_ID) ??
1207+
DEFAULT_PLAYLIST_ID
12001208
const playlistId = getPlaylistId(playlistInput)
12011209
if (!playlistId) {
12021210
throw new Error(
1203-
`Invalid YouTube playlist input: "${playlistInput}". Use --playlist with a playlist URL or ID.`,
1211+
`Invalid YouTube playlist input: "${playlistInput}". Use --playlist with a playlist URL or ID, or set YOUTUBE_PLAYLIST_ID.`,
12041212
)
12051213
}
12061214

other/semantic-search/readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ For podcast indexing:
3333
- `SIMPLECAST_KEY`
3434
- `CHATS_WITH_KENT_PODCAST_ID`
3535

36-
For YouTube playlist indexing (optional but recommended as repo variables):
36+
For YouTube playlist indexing (optional but recommended as repo variables or secrets):
3737

3838
- `YOUTUBE_PLAYLIST_ID` (playlist ID only)
3939
- Optional (helps when YouTube returns anti-bot `LOGIN_REQUIRED`):

0 commit comments

Comments
 (0)