fix: video model category
This commit is contained in:
75
code/app/task/crawler/custom/Scheduler.php
Normal file
75
code/app/task/crawler/custom/Scheduler.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\task\crawler\custom;
|
||||
|
||||
use app\model\ChapterModel;
|
||||
use app\model\CustomCrawlerModel;
|
||||
use app\task\crawler\custom\page\Site;
|
||||
use microserver\QueueManage;
|
||||
use storage\StorageCore;
|
||||
|
||||
/**
|
||||
* @mixin think\Model
|
||||
*/
|
||||
class Scheduler
|
||||
{
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
* @var \microserver\QueueManage
|
||||
*/
|
||||
protected $QueueManage = NULL;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->QueueManage = new QueueManage();
|
||||
}
|
||||
|
||||
/**
|
||||
* create a site-wide craw task
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function crawlFull()
|
||||
{
|
||||
$AllCustomCrawlerModel = CustomCrawlerModel::select();
|
||||
|
||||
foreach ($AllCustomCrawlerModel as $CustomCrawlerModel) {
|
||||
|
||||
if (
|
||||
$CustomCrawlerModel->pt_last_exec != 0 &&
|
||||
($CustomCrawlerModel->pt_last_exec + $CustomCrawlerModel->pt_limit) > time()
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$CustomCrawlerModel->pt_last_exec = time();
|
||||
|
||||
$CustomCrawlerModel->save();
|
||||
|
||||
switch ($CustomCrawlerModel->cc_code) {
|
||||
case 'PULL_WEN_XUE_GUAN':
|
||||
$arrTask = [
|
||||
'callback' => [self::class, 'createCrawlWenXueGuanTask'],
|
||||
'data' => [
|
||||
'cc_data' => $CustomCrawlerModel->cc_data
|
||||
],
|
||||
];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
$this->QueueManage->set($arrTask);
|
||||
}
|
||||
}
|
||||
|
||||
public function createCrawlWenXueGuanTask(array $arrData)
|
||||
{
|
||||
$arrCcData = json_decode($arrData['cc_data'], true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user