diff --git a/conf/app.php b/conf/app.php index 526f914..25fc81d 100644 --- a/conf/app.php +++ b/conf/app.php @@ -62,6 +62,7 @@ $configs = array( 'data_dir' => 'data/', //数据目录 'tag_dir' => 'tags/', //tag分类目录 'task_dir' => 'task/', //分享视频下载任务文件保存目录 + 'task_log' => 'tasks.log', //分享视频下载任务文件日志文件 'supportedPlatforms' => array( '抖音', '快手', diff --git a/themes/tajian/controller/FrontapiController.php b/themes/tajian/controller/FrontapiController.php index 8eadb2c..4cdd9ac 100644 --- a/themes/tajian/controller/FrontapiController.php +++ b/themes/tajian/controller/FrontapiController.php @@ -139,6 +139,9 @@ Class FrontApiController extends SiteController { $done = $done && $this->saveVideoToTag($shareUrl, $tagName); } + //保存任务日志 + $this->saveTaskLog($shareUrl, $title, $tagName); + //调用HeroUnion联盟接口,提交新的数据抓取任务 if (!empty(FSC::$app['config']['heroUnionEnable'])) { $platformName = Html::getShareVideosPlatform($shareUrl); @@ -190,6 +193,29 @@ Class FrontApiController extends SiteController { } } + //保存任务日志 + protected function saveTaskLog($url, $title, $tagName) { + $logFile = __DIR__ . '/../../../runtime/' . FSC::$app['config']['tajian']['task_log']; + + $saved = true; + try { + $fp = fopen($logFile, 'a'); + + $content = array( + 'url' => $url, + 'title' => $title, + 'tag' => $tagName, + 'created' => time(), + ); + + fwrite($fp, json_encode($content) . "\n"); + }catch(Exception $err) { + $saved = false; + } + + return $saved; + } + protected function sign($params, $token) { //对参数做MD5签名 ksort($params); return md5( json_encode($params, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . $token );