This commit is contained in:
root
2026-05-17 05:22:53 +00:00
parent 07aa02bca6
commit 03dc47a569
24 changed files with 941 additions and 93 deletions

View File

@@ -13,6 +13,16 @@ export type YoutubeProChannel = {
};
const STORAGE_KEY = "live-hub-youtube-pro-v2";
const PM2_SANITIZE_RE = /[^a-zA-Z0-9_.-]+/g;
export function sanitizeYoutubePm2Name(value: string): string {
return (value || "").trim().replace(PM2_SANITIZE_RE, "_");
}
export function resolveYoutubeProChannelPm2(channel: Pick<YoutubeProChannel, "id" | "pm2Name">): string {
const raw = sanitizeYoutubePm2Name(String(channel.pm2Name || ""));
return raw || defaultPm2NameForChannel(String(channel.id || ""));
}
export function parseYoutubeProChannelList(raw: unknown): YoutubeProChannel[] {
if (!Array.isArray(raw)) return [];
@@ -116,5 +126,5 @@ export function newChannelId(): string {
}
export function defaultPm2NameForChannel(channelId: string): string {
return `youtube2__${channelId}`;
return `youtube2__${sanitizeYoutubePm2Name(channelId) || "channel"}`;
}