douyinWEB/frontend/src/lib/ytBrandHints.ts
eric c9c71948cb Unify YouTube OAuth/YPP card meta and fix YPP monetize payloads.
Seed brand hints on startup, merge Shorts OAuth into yt-long board, and retry Studio monetize with corrected self-cert formats.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-22 01:59:36 -05:00

44 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/** Google OAuth picker brand name ↔ YouTube channel (title/handle often differ). */
export const YT_OAUTH_BRAND_BY_HANDLE: Record<string, string> = {
"@ewfwefwefewf": "digitl nomad",
"@nomadstreetfood": "hackrobot-jp",
"@nomadrohub": "nomad Immigration",
"@evanstreetfood": "Nhat Vy",
"@nomadvloglife": "Lyca Hack",
"@walkingtour-c8t": "walking tour",
"@hackrobotlite": "hackrobot-jp",
};
const TITLE_BRAND: Array<[string, string]> = [
["nomad vlog", "Lyca Hack"],
["nomad street food", "hackrobot-jp"],
["nomadro hub", "nomad Immigration"],
["异度世界", "digitl nomad"],
["nomdfsfbjksfbsjk", "digitl nomad"],
["evan", "Nhat Vy"],
];
export function normalizeYtHandle(raw?: string | null): string {
const s = String(raw || "").trim();
if (!s) return "";
if (s.startsWith("@")) return s;
if (s.startsWith("UC")) return s;
return `@${s.replace(/^@/, "")}`;
}
export function brandHintForChannel(
profile?: { custom_url?: string; title?: string } | null,
fallbackChannelId?: string,
note?: string,
): string {
const fromNote = String(note || "").match(/Google品牌[::]\s*(.+)/i)?.[1]?.trim();
if (fromNote) return fromNote.split("\n")[0].trim();
const handle = normalizeYtHandle(profile?.custom_url || fallbackChannelId);
if (handle && YT_OAUTH_BRAND_BY_HANDLE[handle]) return YT_OAUTH_BRAND_BY_HANDLE[handle];
const title = String(profile?.title || "").trim().toLowerCase();
for (const [key, brand] of TITLE_BRAND) {
if (title.includes(key)) return brand;
}
return "";
}