Added YouTube Creator scene building flow documentation

This commit is contained in:
ajaysi
2025-12-21 17:15:23 +05:30
parent 1d745c9bc8
commit 59913bffa9
51 changed files with 7478 additions and 631 deletions

View File

@@ -1,9 +1,33 @@
import { aiApiClient } from "../api/client";
// Optional token getter - will be set by the app
let authTokenGetter: (() => Promise<string | null>) | null = null;
export const setMediaAuthTokenGetter = (getter: (() => Promise<string | null>) | null) => {
authTokenGetter = getter;
};
export async function fetchMediaBlobUrl(pathOrUrl: string): Promise<string | null> {
try {
const rel = pathOrUrl.startsWith("/") ? pathOrUrl : `/${pathOrUrl}`;
const res = await aiApiClient.get(rel, { responseType: "blob" });
// Try to get token and add as query parameter as fallback for endpoints that support it
// This helps with endpoints that use get_current_user_with_query_token
let url = rel;
if (authTokenGetter) {
try {
const token = await authTokenGetter();
if (token) {
// Add token as query parameter for endpoints that support it
const separator = url.includes('?') ? '&' : '?';
url = `${url}${separator}token=${encodeURIComponent(token)}`;
}
} catch (tokenError) {
console.warn(`[fetchMediaBlobUrl] Failed to get token for query param:`, tokenError);
}
}
const res = await aiApiClient.get(url, { responseType: "blob" });
return URL.createObjectURL(res.data);
} catch (err: any) {
// Gracefully handle 404s and other errors - file might not exist or was regenerated