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>
44 lines
1.5 KiB
TypeScript
44 lines
1.5 KiB
TypeScript
/** 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 "";
|
||
}
|