一分钟搭建影视站,支持Docker等部署方式
fix: play from history Signed-off-by: JohnsonRan <[email protected]>
JohnsonRanb785a0a573eb
diff --git a/js/ui.js b/js/ui.jsindex 020abd1..455bd8a 100644--- a/js/ui.js+++ b/js/ui.js@@ -489,7 +489,7 @@ function playFromHistory(url, title, episodeIndex, playbackPosition = 0) {console.log(`已将剧集列表保存到localStorage,共 ${episodesList.length} 集`);}// 构造带播放进度参数的URL- const positionParam = playbackPosition > 10 ? `&position=${Math.floor(playbackPosition)}` : '';+ const positionParam = `&position=${Math.floor(playbackPosition || 0)}`;if (url.includes('?')) {// URL已有参数,添加索引和位置参数@@ -497,13 +497,11 @@ function playFromHistory(url, title, episodeIndex, playbackPosition = 0) {if (!playUrl.searchParams.has('index') && episodeIndex > 0) {playUrl.searchParams.set('index', episodeIndex);}- if (playbackPosition > 10) {- playUrl.searchParams.set('position', Math.floor(playbackPosition).toString());- }+ playUrl.searchParams.set('position', Math.floor(playbackPosition || 0).toString());showVideoPlayer(playUrl.toString());} else {// 原始URL,构造player页面链接- const playerUrl = `player.html?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&index=${episodeIndex}${positionParam}`;+ const playerUrl = `player.html?url=${encodeURIComponent(url)}&title=${encodeURIComponent(title)}&index=${episodeIndex}&position=${Math.floor(playbackPosition || 0)}`;showVideoPlayer(playerUrl);}} catch (e) {diff --git a/player.html b/player.htmlindex 2e53346..2ea0d7e 100644--- a/player.html+++ b/player.html@@ -461,20 +461,27 @@const nestedVideoUrl = nestedUrlParams.get('url');// 检查嵌套URL是否包含播放位置信息const nestedPosition = nestedUrlParams.get('position');+ const nestedIndex = nestedUrlParams.get('index');+ const nestedTitle = nestedUrlParams.get('title');if (nestedVideoUrl) {videoUrl = nestedVideoUrl;console.log('已修正为真实视频URL:', videoUrl);- // 如果嵌套URL中有播放位置参数,且当前URL没有,则添加到当前URL- if (nestedPosition && !urlParams.has('position')) {- // 更新当前URL参数- const url = new URL(window.location.href);+ // 更新当前URL参数+ const url = new URL(window.location.href);+ if (!urlParams.has('position') && nestedPosition) {url.searchParams.set('position', nestedPosition);- // 替换当前URL(不刷新页面)- window.history.replaceState({}, '', url);- console.log('从嵌套URL提取播放位置:', nestedPosition);}+ if (!urlParams.has('index') && nestedIndex) {+ url.searchParams.set('index', nestedIndex);+ }+ if (!urlParams.has('title') && nestedTitle) {+ url.searchParams.set('title', nestedTitle);+ }+ // 替换当前URL+ window.history.replaceState({}, '', url);+ console.log('从嵌套URL提取参数:', {position: nestedPosition, index: nestedIndex});} else {console.warn('无法从重定向URL中提取视频链接');showError('历史记录链接无效,请返回首页重新访问');@@ -1401,13 +1408,13 @@title: currentVideoTitle,// 直接保存原始视频链接,而非播放页面链接directVideoUrl: currentVideoUrl,- // 完整的播放器URL,修改格式确保正确传递视频链接- url: `player.html?url=${encodeURIComponent(currentVideoUrl)}&title=${encodeURIComponent(currentVideoTitle)}&source=${encodeURIComponent(sourceName)}&source_code=${encodeURIComponent(sourceCode)}&index=${currentEpisodeIndex}`,+ // 完整的播放器URL+ url: `player.html?url=${encodeURIComponent(currentVideoUrl)}&title=${encodeURIComponent(currentVideoTitle)}&source=${encodeURIComponent(sourceName)}&source_code=${encodeURIComponent(sourceCode)}&index=${currentEpisodeIndex}&position=${Math.floor(currentPosition || 0)}`,episodeIndex: currentEpisodeIndex,sourceName: sourceName,timestamp: Date.now(),// 添加播放进度信息- playbackPosition: currentPosition > 10 ? currentPosition : 0,+ playbackPosition: currentPosition,duration: videoDuration,// 重要:保存完整的集数列表,确保进行深拷贝episodes: currentEpisodes && currentEpisodes.length > 0 ? [...currentEpisodes] : []