Skip to content

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

Dev (#72)

Zwei6c465cb9711e
diff --git a/css/styles.css b/css/styles.css
index b76a043..365cd89 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -32,6 +32,7 @@ button, .card-hover {
transition: all 0.3s ease;
}
+/* 改进卡片适应不同内容长度 */
.card-hover {
border: 1px solid var(--border-color);
background: linear-gradient(135deg, var(--card-gradient-start), var(--card-gradient-end));
@@ -39,6 +40,25 @@ button, .card-hover {
position: relative;
overflow: hidden;
border-radius: 6px;
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+}
+
+/* 确保卡片内容区域高度一致性 */
+.card-hover .flex-grow {
+ min-height: 90px;
+ display: flex;
+ flex-direction: column;
+}
+
+/* 针对不同长度的标题优化显示 */
+.card-hover h3 {
+ min-height: 3rem; /* 至少能显示2行标题 */
+ display: -webkit-box;
+ -webkit-box-orient: vertical;
+ overflow: hidden;
+ -webkit-line-clamp: 2; /* 最多显示2行 */
}
.card-hover::before {
@@ -172,6 +192,17 @@ body {
}
}
+/* 移动端布局优化 */
+@media screen and (max-width: 768px) {
+ .card-hover h3 {
+ min-height: 2.5rem;
+ }
+
+ .card-hover .flex-grow {
+ min-height: 80px;
+ }
+}
+
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
diff --git a/index.html b/index.html
index e0d7738..7e2ecd2 100644
--- a/index.html
+++ b/index.html
@@ -192,8 +192,8 @@
<div id="modal" class="fixed inset-0 bg-black/95 hidden flex items-center justify-center transition-opacity duration-300">
<div class="bg-[#111] p-8 rounded-lg w-11/12 max-w-4xl border border-[#333] max-h-[90vh] flex flex-col">
<div class="flex justify-between items-center mb-6 flex-none">
- <h2 id="modalTitle" class="text-2xl font-bold gradient-text"></h2>
- <button onclick="closeModal()" class="text-gray-400 hover:text-white text-2xl transition-colors">&times;</button>
+ <h2 id="modalTitle" class="text-2xl font-bold gradient-text break-words pr-4 max-w-[80%]"></h2>
+ <button onclick="closeModal()" class="text-gray-400 hover:text-white text-2xl transition-colors flex-shrink-0">&times;</button>
</div>
<div id="modalContent" class="overflow-auto flex-1 min-h-0">
<div class="grid grid-cols-2 sm:grid-cols-4 md:grid-cols-6 lg:grid-cols-8 gap-2">
diff --git a/js/api.js b/js/api.js
index 9bb676b..0cc7cac 100644
--- a/js/api.js
+++ b/js/api.js
@@ -206,8 +206,20 @@ async function handleApiRequest(url) {
}
}
+// 新增: 处理极速资源详情的特殊函数 - 类似非凡影视的处理方式
+async function handleJisuDetail(id, sourceCode) {
+ // 直接复用通用的特殊源处理函数,传入相应参数
+ return await handleSpecialSourceDetail(id, sourceCode);
+}
+
// 添加: 处理非凡影视详情的特殊函数
async function handleFFZYDetail(id, sourceCode) {
+ // 直接复用通用的特殊源处理函数,传入相应参数
+ return await handleSpecialSourceDetail(id, sourceCode);
+}
+
+// 新增: 通用特殊源详情处理函数
+async function handleSpecialSourceDetail(id, sourceCode) {
try {
// 构建详情页URL(使用配置中的detail URL而不是api URL)
const detailUrl = `${API_SITES[sourceCode].detail}/index.php/vod/detail/id/${id}.html`;
@@ -233,84 +245,21 @@ async function handleFFZYDetail(id, sourceCode) {
// 获取HTML内容
const html = await response.text();
- // 非凡影视使用不同的正则表达式
- const ffzyPattern = /\$(https?:\/\/[^"'\s]+?\/\d{8}\/\d+_[a-f0-9]+\/index\.m3u8)/g;
- let matches = html.match(ffzyPattern) || [];
-
- // 处理可能包含括号的链接
- matches = matches.map(link => {
- link = link.substring(1, link.length);
- const parenIndex = link.indexOf('(');
- return parenIndex > 0 ? link.substring(0, parenIndex) : link;
- });
-
- // 如果没有找到链接,尝试一个更通用的模式
+ // 根据不同源类型使用不同的正则表达式
+ let matches = [];
+
+ if (sourceCode === 'ffzy') {
+ // 非凡影视使用特定的正则表达式
+ const ffzyPattern = /\$(https?:\/\/[^"'\s]+?\/\d{8}\/\d+_[a-f0-9]+\/index\.m3u8)/g;
+ matches = html.match(ffzyPattern) || [];
+ }
+
+ // 如果没有找到链接或者是其他源类型,尝试一个更通用的模式
if (matches.length === 0) {
const generalPattern = /\$(https?:\/\/[^"'\s]+?\.m3u8)/g;
matches = html.match(generalPattern) || [];
- matches = matches.map(link => {
- link = link.substring(1, link.length);
- const parenIndex = link.indexOf('(');
- return parenIndex > 0 ? link.substring(0, parenIndex) : link;
- });
- }
-
- // 提取可能存在的标题、简介等基本信息
- // 这些正则可能需要根据网站实际HTML结构调整
- const titleMatch = html.match(/<h1[^>]*>([^<]+)<\/h1>/);
- const titleText = titleMatch ? titleMatch[1].trim() : '';
-
- const descMatch = html.match(/<div[^>]*class=["']sketch["'][^>]*>([\s\S]*?)<\/div>/);
- const descText = descMatch ? descMatch[1].replace(/<[^>]+>/g, ' ').trim() : '';
-
- return JSON.stringify({
- code: 200,
- episodes: matches,
- detailUrl: detailUrl,
- videoInfo: {
- title: titleText,
- desc: descText,
- source_name: API_SITES[sourceCode].name,
- source_code: sourceCode
- }
- });
- } catch (error) {
- console.error('非凡影视详情获取失败:', error);
- throw error;
- }
-}
-
-// 新增: 处理极速资源详情的特殊函数 - 类似非凡影视的处理方式
-async function handleJisuDetail(id, sourceCode) {
- try {
- // 构建详情页URL(使用配置中的detail URL而不是api URL)
- const detailUrl = `${API_SITES[sourceCode].detail}/index.php/vod/detail/id/${id}.html`;
-
- // 添加超时处理
- const controller = new AbortController();
- const timeoutId = setTimeout(() => controller.abort(), 10000);
-
- // 获取详情页HTML
- const response = await fetch(PROXY_URL + encodeURIComponent(detailUrl), {
- 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',
- },
- signal: controller.signal
- });
-
- clearTimeout(timeoutId);
-
- if (!response.ok) {
- throw new Error(`详情页请求失败: ${response.status}`);
}
- // 获取HTML内容
- const html = await response.text();
-
- // 极速资源的正则表达式模式 - 类似非凡的处理方式
- const jisuPattern = /\$(https?:\/\/[^"'\s]+?\.m3u8)/g;
- let matches = html.match(jisuPattern) || [];
-
// 处理链接
matches = matches.map(link => {
link = link.substring(1, link.length);
@@ -337,7 +286,7 @@ async function handleJisuDetail(id, sourceCode) {
}
});
} catch (error) {
- console.error('极速资源详情获取失败:', error);
+ console.error(`${API_SITES[sourceCode].name}详情获取失败:`, error);
throw error;
}
}
diff --git a/js/app.js b/js/app.js
index 8d122b2..c318518 100644
--- a/js/app.js
+++ b/js/app.js
@@ -412,10 +412,10 @@ async function search() {
</div>
</div>` : ''}
- <!-- 内容区域 - 减小内边距 -->
+ <!-- 内容区域 - 调整为适应多行标题 -->
<div class="p-3 flex flex-col flex-grow ${hasCover ? 'md:w-3/4' : 'w-full'}">
<div class="flex-grow">
- <h3 class="text-lg font-semibold mb-2 line-clamp-2">${safeName}</h3>
+ <h3 class="text-lg font-semibold mb-2 break-words">${safeName}</h3>
<!-- 添加影片元数据 - 使用原始彩色标签样式,但减小间距 -->
<div class="flex flex-wrap gap-1 mb-2">
@@ -428,7 +428,7 @@ async function search() {
${item.vod_year}
</span>` : ''}
</div>
- <p class="text-gray-400 text-xs line-clamp-2">
+ <p class="text-gray-400 text-xs h-9 overflow-hidden">
${(item.vod_remarks || '暂无介绍').toString().replace(/</g, '&lt;')}
</p>
</div>
@@ -511,7 +511,8 @@ async function showDetails(id, vod_name, sourceCode = currentApiSource) {
const sourceName = data.videoInfo && data.videoInfo.source_name ?
` <span class="text-sm font-normal text-gray-400">(${data.videoInfo.source_name})</span>` : '';
- modalTitle.innerHTML = (vod_name || '未知视频') + sourceName;
+ // 不对标题进行截断处理,允许完整显示
+ modalTitle.innerHTML = `<span class="break-words">${vod_name || '未知视频'}</span>${sourceName}`;
currentVideoTitle = vod_name || '未知视频';
// 保存当前源码以便后续操作