Browse Source

add task log save

master
filesite 7 months ago
parent
commit
6d1f5ae0e1
  1. 1
      conf/app.php
  2. 26
      themes/tajian/controller/FrontapiController.php

1
conf/app.php

@ -62,6 +62,7 @@ $configs = array( @@ -62,6 +62,7 @@ $configs = array(
'data_dir' => 'data/', //数据目录
'tag_dir' => 'tags/', //tag分类目录
'task_dir' => 'task/', //分享视频下载任务文件保存目录
'task_log' => 'tasks.log', //分享视频下载任务文件日志文件
'supportedPlatforms' => array(
'抖音',
'快手',

26
themes/tajian/controller/FrontapiController.php

@ -139,6 +139,9 @@ Class FrontApiController extends SiteController { @@ -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 { @@ -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 );

Loading…
Cancel
Save