|
|
|
@ -4,6 +4,7 @@
@@ -4,6 +4,7 @@
|
|
|
|
|
*/ |
|
|
|
|
require_once __DIR__ . '/../../../lib/DirScanner.php'; |
|
|
|
|
require_once __DIR__ . '/../../../plugins/Parsedown.php'; |
|
|
|
|
require_once __DIR__ . '/../../../plugins/Html.php'; |
|
|
|
|
require_once __DIR__ . '/SiteController.php'; |
|
|
|
|
|
|
|
|
|
Class ApiController extends SiteController { |
|
|
|
@ -62,8 +63,16 @@ Class ApiController extends SiteController {
@@ -62,8 +63,16 @@ Class ApiController extends SiteController {
|
|
|
|
|
$content = urldecode($content); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//分享内容来源平台检查 |
|
|
|
|
$shareUrl = $this->getShareUrlFromContent($content); |
|
|
|
|
$platform = Html::getShareVideosPlatform($shareUrl); |
|
|
|
|
if (!in_array($platform, FSC::$app['config']['tajian']['supportedPlatforms'])) { |
|
|
|
|
$code = 0; |
|
|
|
|
$err = '目前只支持抖音、快手、西瓜视频和Bilibili的分享网址哦!'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$tagName = ''; |
|
|
|
|
if (!empty($tag) || !empty($tagid)) { //检查分类名称或id是否存在 |
|
|
|
|
if ($code == 1 && (!empty($tag) || !empty($tagid))) { //检查分类名称或id是否存在 |
|
|
|
|
$scanner = new DirScanner(); |
|
|
|
|
$scanner->setWebRoot(FSC::$app['config']['content_directory']); |
|
|
|
|
$dirTree = $scanner->scan(__DIR__ . '/../../../www/' . FSC::$app['config']['content_directory'], 3); |
|
|
|
@ -107,19 +116,28 @@ Class ApiController extends SiteController {
@@ -107,19 +116,28 @@ Class ApiController extends SiteController {
|
|
|
|
|
return md5($url); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//保存分享视频 |
|
|
|
|
protected function saveShareVideo($content, $title, $tagName) { |
|
|
|
|
$done = true; |
|
|
|
|
$newVideo = array(); |
|
|
|
|
protected function getShareUrlFromContent($content) { |
|
|
|
|
$url = ''; |
|
|
|
|
|
|
|
|
|
preg_match("/https:\/\/[\w\.]+(\/\w+){1,}\/?/i", $content, $matches); |
|
|
|
|
if (!empty($matches)) { |
|
|
|
|
$newVideo['url'] = $matches[0]; |
|
|
|
|
$done = $done && $this->saveBotTask($newVideo['url']); |
|
|
|
|
$url = $matches[0]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($tagName)) { |
|
|
|
|
$done = $done && $this->saveVideoToTag($newVideo['url'], $tagName); |
|
|
|
|
return $url; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//保存分享视频 |
|
|
|
|
protected function saveShareVideo($content, $title, $tagName) { |
|
|
|
|
$done = true; |
|
|
|
|
|
|
|
|
|
$shareUrl = $this->getShareUrlFromContent($content); |
|
|
|
|
if (!empty($shareUrl)) { |
|
|
|
|
$done = $done && $this->saveBotTask($shareUrl); |
|
|
|
|
|
|
|
|
|
if (!empty($tagName)) { |
|
|
|
|
$done = $done && $this->saveVideoToTag($shareUrl, $tagName); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return $done; |
|
|
|
|