Skip to content

一分钟搭建影视站,支持Docker等部署方式

Dev (#23)

Zwei0ddd9aef5bc1
diff --git a/index.html b/index.html
index 7a4d615..d385bfd 100644
--- a/index.html
+++ b/index.html
@@ -57,9 +57,13 @@
<option value="ffzy">非凡影视 (ffzy)</option>
<option value="tyyszy">天涯资源 (tyyszy)</option>
<option value="ckzy">CK资源 (ckzy)</option>
+ <option value="zy360">360资源 (zy360)</option>
+ <option value="wolong">卧龙资源 (wolong)</option>
+ <option value="cjhw">新华为 (cjhw)</option>
+ <option value="dbzy">豆瓣资源 (dbzy)</option>
<option value="custom">自定义接口</option>
</select>
- <p class="text-xs text-gray-500 mt-1">目前有效源: 黑木耳、非凡、天涯、CK</p>
+ <p class="text-xs text-gray-500 mt-1">目前有效源: 黑木耳、非凡、天涯、CK、360、卧龙、新华为、豆瓣</p>
</div>
<!-- 添加自定义接口输入框 -->
diff --git a/js/api.js b/js/api.js
index 2b0e60a..b692795 100644
--- a/js/api.js
+++ b/js/api.js
@@ -77,8 +77,8 @@ async function handleApiRequest(url) {
}
const detailUrl = customApi
- ? `${customApi}${API_CONFIG.detail.path}${id}.html`
- : `${API_SITES[source].detail}${API_CONFIG.detail.path}${id}.html`;
+ ? `${customApi}${API_CONFIG.detail.path}${id}`
+ : `${API_SITES[source].api}${API_CONFIG.detail.path}${id}`;
// 添加超时处理
const controller = new AbortController();
@@ -96,37 +96,60 @@ async function handleApiRequest(url) {
throw new Error(`详情请求失败: ${response.status}`);
}
- const html = await response.text();
- if (!html || html.length < 100) {
+ // 由于现在返回的是JSON而不是HTML,我们需要解析JSON
+ const data = await response.json();
+
+ // 检查返回的数据是否有效
+ if (!data || !data.list || !Array.isArray(data.list) || data.list.length === 0) {
throw new Error('获取到的详情内容无效');
}
- const matches = html.match(M3U8_PATTERN) || [];
+ // 获取第一个匹配的视频详情
+ const videoDetail = data.list[0];
- // 改进的URL清理
- const cleanUrls = matches.map(link => {
- try {
- // 去除各种引号和前缀
- let cleanLink = link.replace(/^\$/, '')
- .replace(/^["']+/, '')
- .replace(/["']+$/, '');
-
- // 处理可能嵌在括号中的URL
- if (cleanLink.includes('(') && cleanLink.includes(')')) {
- cleanLink = cleanLink.split(')')[0].split('(').pop();
- }
+ // 提取播放地址
+ let episodes = [];
+
+ if (videoDetail.vod_play_url) {
+ // 分割不同播放源
+ const playSources = videoDetail.vod_play_url.split('$$$');
+
+ // 提取第一个播放源的集数(通常为主要源)
+ if (playSources.length > 0) {
+ const mainSource = playSources[0];
+ const episodeList = mainSource.split('#');
- // 确保链接是http或https开头
- return (cleanLink.startsWith('http://') || cleanLink.startsWith('https://')) ? cleanLink : '';
- } catch (e) {
- return '';
+ // 从每个集数中提取URL
+ episodes = episodeList.map(ep => {
+ const parts = ep.split('$');
+ // 返回URL部分(通常是第二部分,如果有的话)
+ return parts.length > 1 ? parts[1] : '';
+ }).filter(url => url && (url.startsWith('http://') || url.startsWith('https://')));
}
- }).filter(link => link); // 过滤掉空URL
-
+ }
+
+ // 如果没有找到播放地址,尝试使用正则表达式查找m3u8链接
+ if (episodes.length === 0 && videoDetail.vod_content) {
+ const matches = videoDetail.vod_content.match(M3U8_PATTERN) || [];
+ episodes = matches.map(link => link.replace(/^\$/, ''));
+ }
+
return JSON.stringify({
code: 200,
- episodes: cleanUrls,
+ episodes: episodes,
detailUrl: detailUrl,
+ // 添加更多视频详情,以便前端展示
+ videoInfo: {
+ title: videoDetail.vod_name,
+ cover: videoDetail.vod_pic,
+ desc: videoDetail.vod_content,
+ type: videoDetail.type_name,
+ year: videoDetail.vod_year,
+ area: videoDetail.vod_area,
+ director: videoDetail.vod_director,
+ actor: videoDetail.vod_actor,
+ remarks: videoDetail.vod_remarks
+ }
});
} catch (fetchError) {
clearTimeout(timeoutId);
diff --git a/js/config.js b/js/config.js
index c0e1a9b..6deaaaa 100644
--- a/js/config.js
+++ b/js/config.js
@@ -18,24 +18,35 @@ const API_SITES = {
heimuer: {
api: 'https://json.heimuer.xyz',
name: '黑木耳',
- detail: 'https://heimuer.tv',
},
ffzy: {
api: 'http://ffzy5.tv',
name: '非凡影视',
- detail: 'http://ffzy5.tv',
},
tyyszy: {
api: 'https://tyyszy.com',
name: '天涯资源',
- detail: 'https://tyyszy.com',
},
ckzy: {
api: 'https://www.ckzy1.com',
name: 'CK资源',
- detail: 'https://www.ckzy1.com',
},
-
+ zy360: {
+ api: 'https://360zy.com',
+ name: '360资源',
+ },
+ wolong: {
+ api: 'https://wolongzyw.com',
+ name: '卧龙资源',
+ },
+ cjhw: {
+ api: 'https://cjhwba.com',
+ name: '新华为',
+ },
+ dbzy: {
+ api: 'https://dbzy.com',
+ name: '豆瓣资源',
+ }
};
// 抽象API请求配置
@@ -49,9 +60,11 @@ const API_CONFIG = {
}
},
detail: {
- path: '/index.php/vod/detail/id/',
+ // 修改详情接口也使用videolist接口,但是通过ID查询,减少请求次数
+ path: '/api.php/provide/vod/?ac=videolist&ids=',
headers: {
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36'
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36',
+ 'Accept': 'application/json'
}
}
};
diff --git a/readme.md b/readme.md
index de620dc..8e10ea6 100644
--- a/readme.md
+++ b/readme.md
@@ -42,6 +42,27 @@ LibreTV集成了强大的自定义播放器,具有以下特点:
- 对M3U8清单文件进行实时处理
- 支持严格和宽松两种过滤模式
+## 📹 视频源支持说明
+
+LibreTV 默认支持以下几种视频源接口:
+- 黑木耳影视 (heimuer)
+- 非凡影视 (ffzy)
+- 天涯资源 (tyyszy)
+- CK资源 (ckzy)
+
+### CMS采集站源兼容性
+
+本项目支持标准的苹果CMS V10 API格式。自定义API需遵循以下格式:
+- 搜索接口: `https://example.com/api.php/provide/vod/?ac=videolist&wd=关键词`
+- 详情接口: `https://example.com/api.php/provide/vod/?ac=detail&ids=视频ID`
+
+**重要提示**: 像 `https://360zy.com/api.php/provide/vod` 这样的CMS源需要按照以下格式添加:
+1. 在设置面板中选择"自定义接口"
+2. 接口地址只填写到域名部分: `https://360zy.com`(不要包含`/api.php/provide/vod`部分)
+3. 项目会自动补全正确的路径格式
+
+如果CMS接口非标准格式,可能需要修改项目中的`config.js`文件中的`API_CONFIG.search.path`和`API_CONFIG.detail.path`配置。
+
## 🛠️ 技术栈
- HTML5 + CSS3 + JavaScript (ES6+)
@@ -51,6 +72,12 @@ LibreTV集成了强大的自定义播放器,具有以下特点:
- 前端API请求拦截技术
- localStorage本地存储
+## 🚀 一键部署
+
+[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2FbestZwei%2FLibreTV)
+
+[![Deploy to Cloudflare Pages](https://img.shields.io/badge/Deploy%20to-Cloudflare%20Pages-blue?style=for-the-badge&logo=cloudflare)](https://dash.cloudflare.com/)
+
## 🚀 部署指南
### Cloudflare Pages部署
@@ -168,4 +195,4 @@ LibreTV仅作为视频搜索工具,不存储、上传或分发任何视频内
## 🔄 更新日志
- 1.0.0 (2025-04-06): 初始版本发布
-- 1.0.1 (2025-04-07): 添加广告过滤功能,优化播放器性能
\ No newline at end of file
+- 1.0.1 (2025-04-07): 添加广告过滤功能,优化播放器性能