diff --git a/themes/beauty/controller/M3u8Controller.php b/themes/beauty/controller/M3u8Controller.php index ddbfc04..e73b807 100644 --- a/themes/beauty/controller/M3u8Controller.php +++ b/themes/beauty/controller/M3u8Controller.php @@ -47,13 +47,14 @@ Class M3u8Controller extends Controller { throw new Exception($err, 500); } }else { //尝试从索引数据中获取文件信息 + $cacheDir = 'index'; $expireSeconds = 86400 * 365; //缓存 365 天 - $cacheData = Common::getCacheFromFile($this->allFilesCacheKey . '_stats', $expireSeconds); + $cacheData = Common::getCacheFromFile($this->allFilesCacheKey . '_stats', $expireSeconds, $cacheDir); if (!empty($cacheData)) { $dirNum = $cacheData['dirnum']; $index = Common::getIndexNumByFileId($videoId, $dirNum) + 1; $cacheKey = $this->allFilesCacheKey . "_{$index}"; - $cacheFiles = Common::getCacheFromFile($cacheKey, $expireSeconds); + $cacheFiles = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheDir); if (!empty($cacheFiles[$videoId])) { $m3u8 = $cacheFiles[$videoId]; @@ -130,17 +131,15 @@ Class M3u8Controller extends Controller { if (!empty($matchedTs)) { return $matchedTs['path']; - }else { - $webroot = FSC::$app['config']['content_directory']; - $rootDir = __DIR__ . '/../../../www/' . $webroot; - $rootDir = realpath($rootDir); - $m3u8Dir = dirname($m3u8_realpath); - $relativeDir = str_replace("{$rootDir}/", '', $m3u8Dir); - return "/{$webroot}{$relativeDir}/{$ts_filename}"; } } - return dirname($m3u8_realpath) . "/{$ts_filename}"; + $webroot = FSC::$app['config']['content_directory']; + $rootDir = __DIR__ . '/../../../www/' . $webroot; + $rootDir = realpath($rootDir); + $m3u8Dir = dirname($m3u8_realpath); + $relativeDir = str_replace("{$rootDir}/", '', $m3u8Dir); + return "/{$webroot}{$relativeDir}/{$ts_filename}"; } } \ No newline at end of file diff --git a/themes/beauty/controller/SiteController.php b/themes/beauty/controller/SiteController.php index 6cee013..8a5bd07 100644 --- a/themes/beauty/controller/SiteController.php +++ b/themes/beauty/controller/SiteController.php @@ -9,6 +9,7 @@ require_once __DIR__ . '/../../../plugins/Html.php'; Class SiteController extends Controller { protected $dateIndexCacheKey = 'MainBotDateIndex'; //索引数据的key单独缓存,缓存key为此{cacheKey}_keys + protected $allFilesCacheKey = 'MainBotAllFiles'; protected $noOriginalCtimeFilesCacheKey = 'MainBotNoOriginalCtimeFiles'; public function actionIndex() { @@ -811,7 +812,6 @@ Class SiteController extends Controller { $page = $this->get('page', 1); $pageSize = $this->get('limit', 100); - // || empty($cacheParentDataId) if (empty($videoUrl) || empty($videoId) || empty($cateId)) { throw new Exception("缺少参数!", 403); } @@ -819,19 +819,23 @@ Class SiteController extends Controller { $arr = parse_url($videoUrl); $videoFilename = basename($arr['path']); - //增加文件后缀格式检查,区分:mp4, mov, m3u8 + //增加文件后缀格式检查,区分:mp4, mov $videoExtension = pathinfo($arr['path'], PATHINFO_EXTENSION); //支持m3u8地址:/m3u8/?id=xxx - if ($videoFilename == 'm3u8' && !empty($cacheParentDataId)) { + if ($videoFilename == 'm3u8') { $videoExtension = 'm3u8'; //从缓存数据获取文件名 - $cacheSeconds = 86400; - $cachedParentData = Common::getCacheFromFile($cacheParentDataId, $cacheSeconds); - if (!empty($cachedParentData)) { - $m3u8 = $cachedParentData[$videoId]; - $videoFilename = $m3u8['filename'] . '.m3u8'; + if (!empty($cacheParentDataId)) { + $cacheSeconds = 86400; + $cachedParentData = Common::getCacheFromFile($cacheParentDataId, $cacheSeconds); + if (!empty($cachedParentData)) { + $m3u8 = $cachedParentData[$videoId]; + $videoFilename = $m3u8['filename'] . '.m3u8'; + } + }else { + //TODO: 从索引数据中获取 } } diff --git a/themes/beauty/views/site/player.php b/themes/beauty/views/site/player.php index 0849a6c..cea3e4d 100644 --- a/themes/beauty/views/site/player.php +++ b/themes/beauty/views/site/player.php @@ -57,6 +57,7 @@ +

@@ -75,6 +76,7 @@ data-page-size="" class="othervideos">
...
+