(loomVideoId: string)
| 218 | } |
| 219 | |
| 220 | async function getLoomDownloadUrl(loomVideoId: string): Promise<string | null> { |
| 221 | const requestVariants: Array<{ endpoint: string; includeBody: boolean }> = [ |
| 222 | { endpoint: "transcoded-url", includeBody: true }, |
| 223 | { endpoint: "raw-url", includeBody: true }, |
| 224 | { endpoint: "transcoded-url", includeBody: false }, |
| 225 | { endpoint: "raw-url", includeBody: false }, |
| 226 | ]; |
| 227 | |
| 228 | let fallbackStreamingUrl: string | null = null; |
| 229 | |
| 230 | for (const { endpoint, includeBody } of requestVariants) { |
| 231 | const url = await fetchLoomEndpoint(loomVideoId, endpoint, includeBody); |
| 232 | if (!url) continue; |
| 233 | |
| 234 | if (!isStreamingUrl(url)) return url; |
| 235 | |
| 236 | if (!fallbackStreamingUrl) fallbackStreamingUrl = url; |
| 237 | } |
| 238 | |
| 239 | return fallbackStreamingUrl; |
| 240 | } |
| 241 | |
| 242 | async function fetchLoomOEmbed( |
| 243 | loomVideoId: string, |
no test coverage detected