* Resolves the effective playlist ID to sync from sourceConfig, and whether the source * is a channel's reverse-chronological uploads playlist (which enables early-stop for * the `publishedAfter` filter). A `playlistId` takes precedence over a `channelId`.
( apiKey: string, sourceConfig: Record<string, unknown>, retryOptions?: Parameters<typeof fetchWithRetry>[2] )
| 151 | * the `publishedAfter` filter). A `playlistId` takes precedence over a `channelId`. |
| 152 | */ |
| 153 | async function resolvePlaylistId( |
| 154 | apiKey: string, |
| 155 | sourceConfig: Record<string, unknown>, |
| 156 | retryOptions?: Parameters<typeof fetchWithRetry>[2] |
| 157 | ): Promise<{ playlistId: string | null; isUploadsPlaylist: boolean }> { |
| 158 | const playlistId = (sourceConfig.playlistId as string | undefined)?.trim() |
| 159 | if (playlistId) return { playlistId, isUploadsPlaylist: false } |
| 160 | |
| 161 | const channelId = (sourceConfig.channelId as string | undefined)?.trim() |
| 162 | if (channelId) { |
| 163 | const resolved = await resolveUploadsPlaylistId(apiKey, channelId, retryOptions) |
| 164 | return { playlistId: resolved, isUploadsPlaylist: resolved != null } |
| 165 | } |
| 166 | |
| 167 | return { playlistId: null, isUploadsPlaylist: false } |
| 168 | } |
| 169 | |
| 170 | /** |
| 171 | * Extracts the video ID from a playlist item, preferring the stable |
no test coverage detected