* Builds a metadata-only stub from a playlist item. * * Duration/tags/category are not available on `playlistItems.list` — they are populated * during hydration in `getDocument` via `videos.list`. The content hash uses the video's * publish time only, so it is identical between this stub and the
(item: PlaylistItem)
| 194 | * publish time only, so it is identical between this stub and the hydrated document. |
| 195 | */ |
| 196 | function itemToStub(item: PlaylistItem): ExternalDocument | null { |
| 197 | const videoId = getVideoId(item) |
| 198 | if (!videoId) return null |
| 199 | |
| 200 | const snippet = item.snippet ?? {} |
| 201 | const videoPublishedAt = item.contentDetails?.videoPublishedAt ?? '' |
| 202 | const channelTitle = snippet.videoOwnerChannelTitle ?? snippet.channelTitle ?? '' |
| 203 | |
| 204 | return { |
| 205 | externalId: videoId, |
| 206 | title: snippet.title || 'Untitled', |
| 207 | content: '', |
| 208 | contentDeferred: true, |
| 209 | mimeType: 'text/plain', |
| 210 | sourceUrl: `https://www.youtube.com/watch?v=${videoId}`, |
| 211 | contentHash: buildContentHash(videoId, videoPublishedAt), |
| 212 | metadata: { |
| 213 | channelTitle, |
| 214 | publishedAt: videoPublishedAt, |
| 215 | }, |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | /** |
| 220 | * Batch-fetches full video resources for the given IDs via `videos.list`. |
no test coverage detected