MCPcopy Create free account
hub / github.com/simstudioai/sim / itemToStub

Function itemToStub

apps/sim/connectors/youtube/youtube.ts:196–217  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

194 * publish time only, so it is identical between this stub and the hydrated document.
195 */
196function 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`.

Callers 1

youtube.tsFile · 0.70

Calls 2

getVideoIdFunction · 0.85
buildContentHashFunction · 0.70

Tested by

no test coverage detected