Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .github/workflows/index-semantic-youtube.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,10 @@ jobs:
${{ secrets.CLOUDFLARE_AI_EMBEDDING_MODEL }}
R2_BUCKET: ${{ secrets.R2_BUCKET }}

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

# Optional: force-index specific videos. Can be set either as a
# workflow_dispatch input or as a repository variable.
Expand Down
12 changes: 10 additions & 2 deletions other/semantic-search/index-youtube-playlist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,12 @@ function collectObjectsByKey(
return result
}

function nonEmptyTrimmed(value: string | undefined | null): string | undefined {
if (typeof value !== 'string') return undefined
const trimmed = value.trim()
return trimmed ? trimmed : undefined
}

function getPlaylistId(input: string | undefined) {
if (!input) return null
const trimmed = input.trim()
Expand Down Expand Up @@ -1196,11 +1202,13 @@ async function main() {
dryRun,
} = parseArgs()
const playlistInput =
playlistArg ?? process.env.YOUTUBE_PLAYLIST_ID ?? DEFAULT_PLAYLIST_ID
nonEmptyTrimmed(playlistArg) ??
nonEmptyTrimmed(process.env.YOUTUBE_PLAYLIST_ID) ??
DEFAULT_PLAYLIST_ID
const playlistId = getPlaylistId(playlistInput)
if (!playlistId) {
throw new Error(
`Invalid YouTube playlist input: "${playlistInput}". Use --playlist with a playlist URL or ID.`,
`Invalid YouTube playlist input: "${playlistInput}". Use --playlist with a playlist URL or ID, or set YOUTUBE_PLAYLIST_ID.`,
)
}

Expand Down
2 changes: 1 addition & 1 deletion other/semantic-search/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ For podcast indexing:
- `SIMPLECAST_KEY`
- `CHATS_WITH_KENT_PODCAST_ID`

For YouTube playlist indexing (optional but recommended as repo variables):
For YouTube playlist indexing (optional but recommended as repo variables or secrets):

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