feat: add melody-cdn-sharon and make it default

This commit is contained in:
shinya
2025-08-17 17:48:37 +08:00
parent 4ffd59c5d1
commit 6bab45b6d8
7 changed files with 71 additions and 48 deletions
+22 -15
View File
@@ -69,8 +69,8 @@ async function fetchWithTimeout(
proxyUrl === 'https://cors-anywhere.com/'
? `${proxyUrl}${url}`
: proxyUrl
? `${proxyUrl}${encodeURIComponent(url)}`
: url;
? `${proxyUrl}${encodeURIComponent(url)}`
: url;
const fetchOptions: RequestInit = {
signal: controller.signal,
@@ -94,18 +94,19 @@ async function fetchWithTimeout(
function getDoubanProxyConfig(): {
proxyType:
| 'direct'
| 'cors-proxy-zwei'
| 'cmliussss-cdn-tencent'
| 'cmliussss-cdn-ali'
| 'cors-anywhere'
| 'custom';
| 'direct'
| 'melody-cdn-sharon'
| 'cors-proxy-zwei'
| 'cmliussss-cdn-tencent'
| 'cmliussss-cdn-ali'
| 'cors-anywhere'
| 'custom';
proxyUrl: string;
} {
const doubanProxyType =
localStorage.getItem('doubanDataSource') ||
(window as any).RUNTIME_CONFIG?.DOUBAN_PROXY_TYPE ||
'direct';
'melody-cdn-sharon';
const doubanProxy =
localStorage.getItem('doubanProxyUrl') ||
(window as any).RUNTIME_CONFIG?.DOUBAN_PROXY ||
@@ -147,8 +148,8 @@ export async function fetchDoubanCategories(
const target = useTencentCDN
? `https://m.douban.cmliussss.net/rexxar/api/v2/subject/recent_hot/${kind}?start=${pageStart}&limit=${pageLimit}&category=${category}&type=${type}`
: useAliCDN
? `https://m.douban.cmliussss.com/rexxar/api/v2/subject/recent_hot/${kind}?start=${pageStart}&limit=${pageLimit}&category=${category}&type=${type}`
: `https://m.douban.com/rexxar/api/v2/subject/recent_hot/${kind}?start=${pageStart}&limit=${pageLimit}&category=${category}&type=${type}`;
? `https://m.douban.cmliussss.com/rexxar/api/v2/subject/recent_hot/${kind}?start=${pageStart}&limit=${pageLimit}&category=${category}&type=${type}`
: `https://m.douban.com/rexxar/api/v2/subject/recent_hot/${kind}?start=${pageStart}&limit=${pageLimit}&category=${category}&type=${type}`;
try {
const response = await fetchWithTimeout(
@@ -198,6 +199,8 @@ export async function getDoubanCategories(
const { kind, category, type, pageLimit = 20, pageStart = 0 } = params;
const { proxyType, proxyUrl } = getDoubanProxyConfig();
switch (proxyType) {
case 'melody-cdn-sharon':
return fetchDoubanCategories(params, 'https://douban.ihtw.moe/');
case 'cors-proxy-zwei':
return fetchDoubanCategories(params, 'https://ciao-cors.is-an.org/');
case 'cmliussss-cdn-tencent':
@@ -231,6 +234,8 @@ export async function getDoubanList(
const { tag, type, pageLimit = 20, pageStart = 0 } = params;
const { proxyType, proxyUrl } = getDoubanProxyConfig();
switch (proxyType) {
case 'melody-cdn-sharon':
return fetchDoubanList(params, 'https://douban.ihtw.moe/');
case 'cors-proxy-zwei':
return fetchDoubanList(params, 'https://ciao-cors.is-an.org/');
case 'cmliussss-cdn-tencent':
@@ -279,8 +284,8 @@ export async function fetchDoubanList(
const target = useTencentCDN
? `https://movie.douban.cmliussss.net/j/search_subjects?type=${type}&tag=${tag}&sort=recommend&page_limit=${pageLimit}&page_start=${pageStart}`
: useAliCDN
? `https://movie.douban.cmliussss.com/j/search_subjects?type=${type}&tag=${tag}&sort=recommend&page_limit=${pageLimit}&page_start=${pageStart}`
: `https://movie.douban.com/j/search_subjects?type=${type}&tag=${tag}&sort=recommend&page_limit=${pageLimit}&page_start=${pageStart}`;
? `https://movie.douban.cmliussss.com/j/search_subjects?type=${type}&tag=${tag}&sort=recommend&page_limit=${pageLimit}&page_start=${pageStart}`
: `https://movie.douban.com/j/search_subjects?type=${type}&tag=${tag}&sort=recommend&page_limit=${pageLimit}&page_start=${pageStart}`;
try {
const response = await fetchWithTimeout(
@@ -351,6 +356,8 @@ export async function getDoubanRecommends(
} = params;
const { proxyType, proxyUrl } = getDoubanProxyConfig();
switch (proxyType) {
case 'melody-cdn-sharon':
return fetchDoubanRecommends(params, 'https://douban.ihtw.moe/');
case 'cors-proxy-zwei':
return fetchDoubanRecommends(params, 'https://ciao-cors.is-an.org/');
case 'cmliussss-cdn-tencent':
@@ -432,8 +439,8 @@ async function fetchDoubanRecommends(
const baseUrl = useTencentCDN
? `https://m.douban.cmliussss.net/rexxar/api/v2/${kind}/recommend`
: useAliCDN
? `https://m.douban.cmliussss.com/rexxar/api/v2/${kind}/recommend`
: `https://m.douban.com/rexxar/api/v2/${kind}/recommend`;
? `https://m.douban.cmliussss.com/rexxar/api/v2/${kind}/recommend`
: `https://m.douban.com/rexxar/api/v2/${kind}/recommend`;
const reqParams = new URLSearchParams();
reqParams.append('refresh', '0');
reqParams.append('start', pageStart.toString());