|
|
@ -203,7 +203,7 @@ Class SiteController extends Controller { |
|
|
|
|
|
|
|
|
|
|
|
//尝试从缓存数据中获取封面图 |
|
|
|
//尝试从缓存数据中获取封面图 |
|
|
|
$cacheKey_snap = $this->getCacheKey($firstVideo['id'], 'vmeta');; |
|
|
|
$cacheKey_snap = $this->getCacheKey($firstVideo['id'], 'vmeta');; |
|
|
|
$expireSeconds = 86400*30; //有效期30天 |
|
|
|
$expireSeconds = FSC::$app['config']['screenshot_expire_seconds']; //有效期3650天 |
|
|
|
$cacheSubDir = 'video'; |
|
|
|
$cacheSubDir = 'video'; |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey_snap, $expireSeconds, $cacheSubDir); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey_snap, $expireSeconds, $cacheSubDir); |
|
|
|
if (!empty($cachedData)) { |
|
|
|
if (!empty($cachedData)) { |
|
|
@ -225,6 +225,53 @@ Class SiteController extends Controller { |
|
|
|
return $this->renderJson(compact('code', 'msg', 'url')); |
|
|
|
return $this->renderJson(compact('code', 'msg', 'url')); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//优先从缓存获取小尺寸的图片 |
|
|
|
|
|
|
|
public function actionSmallimg() { |
|
|
|
|
|
|
|
$imgId = $this->get('id', ''); |
|
|
|
|
|
|
|
$imgUrl = $this->get('url', ''); |
|
|
|
|
|
|
|
if (empty($imgId) || empty($imgUrl)) { |
|
|
|
|
|
|
|
return $this->redirect('/img/beauty/lazy.svg'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cacheKey = $this->getCacheKey($imgId, 'imgsm'); |
|
|
|
|
|
|
|
$expireSeconds = FSC::$app['config']['screenshot_expire_seconds']; //有效期3650天 |
|
|
|
|
|
|
|
$cacheSubDir = 'image'; |
|
|
|
|
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); |
|
|
|
|
|
|
|
if (!empty($cachedData)) { |
|
|
|
|
|
|
|
$imgType = preg_replace('/^data:(image\/.+);base64,.+$/i', "$1", $cachedData); |
|
|
|
|
|
|
|
$base64_img = preg_replace('/^data:image\/.+;base64,/i', '', $cachedData); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
header("Content-Type: {$imgType}"); |
|
|
|
|
|
|
|
echo base64_decode($base64_img); |
|
|
|
|
|
|
|
exit; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->redirect($imgUrl); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//保存小尺寸图片数据到缓存 |
|
|
|
|
|
|
|
public function actionSavesmallimg() { |
|
|
|
|
|
|
|
$code = 0; |
|
|
|
|
|
|
|
$msg = 'OK'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$imgId = $this->post('id', ''); |
|
|
|
|
|
|
|
$imgData = $this->post('data', ''); //base64格式的图片数据 |
|
|
|
|
|
|
|
if (empty($imgId) || empty($imgData)) { |
|
|
|
|
|
|
|
$code = 0; |
|
|
|
|
|
|
|
$msg = '参数不能为空'; |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
$cacheKey = $this->getCacheKey($imgId, 'imgsm'); |
|
|
|
|
|
|
|
$cacheSubDir = 'image'; |
|
|
|
|
|
|
|
$saved = Common::saveCacheToFile($cacheKey, $imgData, $cacheSubDir); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ($saved !== false) { |
|
|
|
|
|
|
|
$code = 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $this->renderJson(compact('code', 'msg')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function actionPlayer() { |
|
|
|
public function actionPlayer() { |
|
|
|
$videoUrl = $this->get('url', ''); |
|
|
|
$videoUrl = $this->get('url', ''); |
|
|
|
$videoId = $this->get('id', ''); |
|
|
|
$videoId = $this->get('id', ''); |
|
|
@ -269,7 +316,7 @@ Class SiteController extends Controller { |
|
|
|
$msg = '参数不能为空'; |
|
|
|
$msg = '参数不能为空'; |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
$cacheKey = $this->getCacheKey($videoId, 'vmeta'); |
|
|
|
$cacheKey = $this->getCacheKey($videoId, 'vmeta'); |
|
|
|
$expireSeconds = 86400*30; //有效期30天 |
|
|
|
$expireSeconds = FSC::$app['config']['screenshot_expire_seconds']; //有效期3650天 |
|
|
|
$cacheSubDir = 'video'; |
|
|
|
$cacheSubDir = 'video'; |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); |
|
|
|
if (!empty($cachedData)) { |
|
|
|
if (!empty($cachedData)) { |
|
|
@ -303,7 +350,7 @@ Class SiteController extends Controller { |
|
|
|
$metaData['manual'] = 1; |
|
|
|
$metaData['manual'] = 1; |
|
|
|
$saved = Common::saveCacheToFile($cacheKey, $metaData, $cacheSubDir); |
|
|
|
$saved = Common::saveCacheToFile($cacheKey, $metaData, $cacheSubDir); |
|
|
|
}else { |
|
|
|
}else { |
|
|
|
$expireSeconds = 86400*30; //有效期30天 |
|
|
|
$expireSeconds = FSC::$app['config']['screenshot_expire_seconds']; //有效期3650天 |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); |
|
|
|
$cachedData = Common::getCacheFromFile($cacheKey, $expireSeconds, $cacheSubDir); |
|
|
|
if (empty($cachedData) || empty($cachedData['manual'])) { |
|
|
|
if (empty($cachedData) || empty($cachedData['manual'])) { |
|
|
|
$saved = Common::saveCacheToFile($cacheKey, $metaData, $cacheSubDir); |
|
|
|
$saved = Common::saveCacheToFile($cacheKey, $metaData, $cacheSubDir); |
|
|
|