|
|
@ -178,6 +178,11 @@ Class SiteController extends Controller { |
|
|
|
$code = 0; |
|
|
|
$code = 0; |
|
|
|
$msg = '参数不能为空'; |
|
|
|
$msg = '参数不能为空'; |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
|
|
|
|
//优先从缓存获取 |
|
|
|
|
|
|
|
$cacheKey = $this->getCacheKey($cateId, 'dirsnap'); |
|
|
|
|
|
|
|
$url = Common::getCacheFromFile($cacheKey); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (empty($url)) { |
|
|
|
//从缓存数据中获取目录的realpath |
|
|
|
//从缓存数据中获取目录的realpath |
|
|
|
$cachedData = Common::getCacheFromFile($cacheId); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheId); |
|
|
|
if (!empty($cachedData)) { |
|
|
|
if (!empty($cachedData)) { |
|
|
@ -189,7 +194,6 @@ Class SiteController extends Controller { |
|
|
|
$imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif'); |
|
|
|
$imgExts = !empty(FSC::$app['config']['supportedImageExts']) ? FSC::$app['config']['supportedImageExts'] : array('jpg', 'jpeg', 'png', 'webp', 'gif'); |
|
|
|
$imgFile = $scanner->getSnapshotImage($realpath, $imgExts); |
|
|
|
$imgFile = $scanner->getSnapshotImage($realpath, $imgExts); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//支持视频目录 |
|
|
|
//支持视频目录 |
|
|
|
if (empty($imgFile)) { |
|
|
|
if (empty($imgFile)) { |
|
|
|
$videoExts = !empty(FSC::$app['config']['supportedVideoExts']) ? FSC::$app['config']['supportedVideoExts'] : array('mp4', 'mov', 'm3u8'); |
|
|
|
$videoExts = !empty(FSC::$app['config']['supportedVideoExts']) ? FSC::$app['config']['supportedVideoExts'] : array('mp4', 'mov', 'm3u8'); |
|
|
@ -198,22 +202,25 @@ Class SiteController extends Controller { |
|
|
|
$url = '/img/beauty/video_dir.png'; |
|
|
|
$url = '/img/beauty/video_dir.png'; |
|
|
|
|
|
|
|
|
|
|
|
//尝试从缓存数据中获取封面图 |
|
|
|
//尝试从缓存数据中获取封面图 |
|
|
|
$cacheKey = $firstVideo['id']; |
|
|
|
$cacheKey_snap = $this->getCacheKey($firstVideo['id'], 'vmeta');; |
|
|
|
$expireSeconds = 86400*30; //有效期30天 |
|
|
|
$expireSeconds = 86400*30; //有效期30天 |
|
|
|
$cacheSubDir = 'video'; |
|
|
|
$cacheSubDir = 'video'; |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey_snap, $expireSeconds, $cacheSubDir); |
|
|
|
if (!empty($cachedData)) { |
|
|
|
if (!empty($cachedData)) { |
|
|
|
$url = $cachedData['snapshot']; |
|
|
|
$url = $cachedData['snapshot']; |
|
|
|
|
|
|
|
Common::saveCacheToFile($cacheKey, $url); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
$url = $imgFile['path']; |
|
|
|
$url = $imgFile['path']; |
|
|
|
|
|
|
|
Common::saveCacheToFile($cacheKey, $url); |
|
|
|
} |
|
|
|
} |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
$code = 0; |
|
|
|
$code = 0; |
|
|
|
$msg = '缓存数据已失效,请刷新网页'; |
|
|
|
$msg = '缓存数据已失效,请刷新网页'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return $this->renderJson(compact('code', 'msg', 'url')); |
|
|
|
return $this->renderJson(compact('code', 'msg', 'url')); |
|
|
|
} |
|
|
|
} |
|
|
@ -261,7 +268,7 @@ Class SiteController extends Controller { |
|
|
|
$code = 0; |
|
|
|
$code = 0; |
|
|
|
$msg = '参数不能为空'; |
|
|
|
$msg = '参数不能为空'; |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
$cacheKey = $videoId; |
|
|
|
$cacheKey = $this->getCacheKey($videoId, 'vmeta'); |
|
|
|
$expireSeconds = 86400*30; //有效期30天 |
|
|
|
$expireSeconds = 86400*30; //有效期30天 |
|
|
|
$cacheSubDir = 'video'; |
|
|
|
$cacheSubDir = 'video'; |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); |
|
|
@ -287,7 +294,7 @@ Class SiteController extends Controller { |
|
|
|
$code = 0; |
|
|
|
$code = 0; |
|
|
|
$msg = '参数不能为空'; |
|
|
|
$msg = '参数不能为空'; |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
$cacheKey = $videoId; |
|
|
|
$cacheKey = $this->getCacheKey($videoId, 'vmeta'); |
|
|
|
$cacheSubDir = 'video'; |
|
|
|
$cacheSubDir = 'video'; |
|
|
|
$saved = Common::saveCacheToFile($cacheKey, $metaData, $cacheSubDir); |
|
|
|
$saved = Common::saveCacheToFile($cacheKey, $metaData, $cacheSubDir); |
|
|
|
if ($saved !== false) { |
|
|
|
if ($saved !== false) { |
|
|
|