diff --git a/themes/tajian/controller/FrontapiController.php b/themes/tajian/controller/FrontapiController.php index c96dc61..80e079e 100644 --- a/themes/tajian/controller/FrontapiController.php +++ b/themes/tajian/controller/FrontapiController.php @@ -219,7 +219,7 @@ Class FrontApiController extends SiteController { } //保存快捷方式 - protected function saveUrlShortCut($task_id, $task_url) { + protected function saveUrlShortCut($video_id, $task_url) { $data_dir = __DIR__ . '/../../../runtime/' . FSC::$app['config']['tajian']['data_dir']; if (!is_dir($data_dir)) { mkdir($data_dir, 0755, true); @@ -231,7 +231,7 @@ URL={$task_url} eof; try { - $filepath = "{$data_dir}/{$task_id}.url"; + $filepath = "{$data_dir}/{$video_id}.url"; return file_put_contents($filepath, $shortUrlContent); }catch(Exception $err) { return false; @@ -239,7 +239,7 @@ eof; } //保存描述文件:标题和图片 - protected function saveDescriptionFiles($task_id, $task_data) { + protected function saveDescriptionFiles($video_id, $task_data) { $data_dir = __DIR__ . '/../../../runtime/' . FSC::$app['config']['tajian']['data_dir']; if (!is_dir($data_dir)) { mkdir($data_dir, 0755, true); @@ -249,18 +249,18 @@ eof; try { //保存标题 - $filepath_title ="{$data_dir}/{$task_id}_title.txt"; + $filepath_title ="{$data_dir}/{$video_id}_title.txt"; file_put_contents($filepath_title, $task_data['title']); //保存图片文件 if (!empty($task_data['cover_base64'])) { - $filepath_cover ="{$data_dir}/{$task_id}.{$task_data['cover_type']}"; + $filepath_cover ="{$data_dir}/{$video_id}.{$task_data['cover_type']}"; file_put_contents($filepath_cover, $task_data['cover_base64']); - $filepath_desc ="{$data_dir}/{$task_id}_cover.txt"; - file_put_contents($filepath_desc, "{$task_id}.{$task_data['cover_type']}"); + $filepath_desc ="{$data_dir}/{$video_id}_cover.txt"; + file_put_contents($filepath_desc, "{$video_id}.{$task_data['cover_type']}"); }else if (!empty($task_data['cover'])) { - $filepath_desc ="{$data_dir}/{$task_id}_cover.txt"; + $filepath_desc ="{$data_dir}/{$video_id}_cover.txt"; file_put_contents($filepath_desc, "{$task_data['cover']}"); } }catch(Exception $err) { @@ -308,8 +308,9 @@ eof; $code = 0; $err = '签名验证不通过!'; }else if (!empty($task_result['done'])) { //如果任务成功抓取到数据 - $saveUrlRes = $this->saveUrlShortCut($task_id, $task_result['url']); - $saveDescRes = $this->saveDescriptionFiles($task_id, $task_result); + $video_id = $this->getVideoId($task_result['url']); + $saveUrlRes = $this->saveUrlShortCut($video_id, $task_result['url']); + $saveDescRes = $this->saveDescriptionFiles($video_id, $task_result); if (!$saveUrlRes) { $code = 0; $err = '网址快捷方式文件保存失败!';