This commit is contained in:
root
2026-05-17 04:31:59 +00:00
parent 75a0ca4e31
commit 07aa02bca6
51 changed files with 1322 additions and 435 deletions

View File

@@ -71,20 +71,24 @@ export function saveYoutubeProChannels(channels: YoutubeProChannel[]): void {
const YOUTUBE_PRO_SYNC_PATHS = ["/hub/youtube_pro_channels", "/youtube_pro_channels"] as const;
export type YoutubeProChannelsRemoteResult = {
fetched: boolean;
channels: YoutubeProChannel[];
};
/** 从服务器拉多频道列表(依次尝试 /hub 与根路径,兼容反代未转发 /hub 的情况) */
export async function fetchYoutubeProChannelsRemote(
fetchJson: <T,>(path: string, init?: RequestInit) => Promise<T>,
): Promise<YoutubeProChannel[]> {
): Promise<YoutubeProChannelsRemoteResult> {
for (const path of YOUTUBE_PRO_SYNC_PATHS) {
try {
const data = await fetchJson<{ channels?: unknown }>(path);
const fromServer = parseYoutubeProChannelList(data.channels);
if (fromServer.length) return fromServer;
return { fetched: true, channels: parseYoutubeProChannelList(data.channels) };
} catch {
/* try next */
}
}
return [];
return { fetched: false, channels: [] };
}
export async function pushYoutubeProChannelsRemote(