debug
This commit is contained in:
@@ -1,14 +1,18 @@
|
|||||||
{site:forgelist count="3" d_key="d_key" d_val="novel" cache_life="1000"}
|
{site:helper func="initHomeTKD" /}
|
||||||
|
|
||||||
|
|
||||||
|
<!-- {site:forgelist count="3" d_key="d_key" d_val="novel" cache_life="1000"}
|
||||||
<li>
|
<li>
|
||||||
Index: {$d_key}
|
Index: {$d_key}
|
||||||
Title: {$novel.n_forge_title}
|
Title: {$novel.n_forge_title}
|
||||||
Author: {$novel.n_name_pinyin}
|
Author: {$novel.n_name_pinyin}
|
||||||
</li>
|
</li>
|
||||||
{/site:forgelist}
|
{/site:forgelist} -->
|
||||||
|
|
||||||
|
|
||||||
<!-- {novel:ranklist count="10" sort_type="total" n_status="wanjie" n_sex="man" d_key="d_key" d_val="novel" cache_life="1000"}
|
<!-- {novel:ranklist count="10" sort_type="total" n_status="wanjie" n_sex="man" d_key="d_key" d_val="novel" cache_life="1000"}
|
||||||
<li>
|
<li>
|
||||||
|
{php}var_dump($novel){/php}
|
||||||
Index: {$d_key}
|
Index: {$d_key}
|
||||||
Title: {$novel.n_name}
|
Title: {$novel.n_name}
|
||||||
Author: {$novel.n_category}
|
Author: {$novel.n_category}
|
||||||
|
|||||||
@@ -262,4 +262,16 @@ class SiteContext
|
|||||||
|
|
||||||
return $arrResult;
|
return $arrResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视图反向控制器(注释函数),在视图开头调用,用来初始化一些操作。这里尽量不要复杂逻辑。这是个样例
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function initHomeTKD()
|
||||||
|
{
|
||||||
|
ConverterMovel::setVal([
|
||||||
|
'strSiteName' => $this->DomainModel->d_name,
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,6 +74,26 @@ class Scheduler
|
|||||||
*/
|
*/
|
||||||
public function crawlFull()
|
public function crawlFull()
|
||||||
{
|
{
|
||||||
|
$Site = $this->getSite();
|
||||||
|
$arrVSourceId = [];
|
||||||
|
|
||||||
|
$arrVSourceId[] = ['v_source_id' => 66281];
|
||||||
|
|
||||||
|
|
||||||
|
$arrAllVideoInfoPage = $Site->getVideoInfoPageList($arrVSourceId);
|
||||||
|
foreach ($arrAllVideoInfoPage as $VideoInfoPage) {
|
||||||
|
$arrVideo = $VideoInfoPage->getVideo();
|
||||||
|
print_r($arrVideo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$intLimit = 10;
|
$intLimit = 10;
|
||||||
|
|
||||||
$Site = $this->getSite();
|
$Site = $this->getSite();
|
||||||
@@ -91,12 +111,11 @@ class Scheduler
|
|||||||
];
|
];
|
||||||
|
|
||||||
$arrVideoPageList = $Site->getVideoPageList($arrFilter);
|
$arrVideoPageList = $Site->getVideoPageList($arrFilter);
|
||||||
|
$arrVideoPager = $arrVideoPageList[0]->getVideoPager();
|
||||||
foreach ($arrVideoPageList as $VideoPage) {
|
|
||||||
$arrAllVideoPager = $VideoPage->getVideoPager();
|
|
||||||
|
|
||||||
$arrVSourceId = [];
|
$arrVSourceId = [];
|
||||||
foreach ($arrAllVideoPager['list'] as $arrVideoPager) {
|
|
||||||
|
foreach ($arrVideoPager['list'] as $arrVideoPager) {
|
||||||
$arrVSourceId[] = ['v_source_id' => (int)$arrVideoPager['vod_id']];
|
$arrVSourceId[] = ['v_source_id' => (int)$arrVideoPager['vod_id']];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -105,18 +124,24 @@ class Scheduler
|
|||||||
$arrVideo = $VideoInfoPage->getVideo();
|
$arrVideo = $VideoInfoPage->getVideo();
|
||||||
print_r($arrVideo);
|
print_r($arrVideo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// foreach ($arrVideoPageList as $VideoPage) {
|
||||||
|
// $arrAllVideoPager = $VideoPage->getVideoPager();
|
||||||
|
|
||||||
|
// $arrVSourceId = [];
|
||||||
|
// foreach ($arrAllVideoPager['list'] as $arrVideoPager) {
|
||||||
|
// $arrVSourceId[] = ['v_source_id' => (int)$arrVideoPager['vod_id']];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// $arrAllVideoInfoPage = $Site->getVideoInfoPageList($arrVSourceId);
|
||||||
|
// foreach ($arrAllVideoInfoPage as $VideoInfoPage) {
|
||||||
|
// $arrVideo = $VideoInfoPage->getVideo();
|
||||||
|
// print_r($arrVideo);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$arrCover = [];
|
|
||||||
|
|
||||||
|
|
||||||
if ($arrCover) {
|
|
||||||
// $Site->downRemoteImgToLocal($arrCover);
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,18 +68,8 @@ class Site
|
|||||||
],
|
],
|
||||||
'headers' => [
|
'headers' => [
|
||||||
'User-Agent' => 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
|
'User-Agent' => 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
|
||||||
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
|
||||||
'Accept-Language' => 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
|
||||||
'Referer' => $this->strDomain,
|
'Referer' => $this->strDomain,
|
||||||
'Connection' => 'keep-alive',
|
'Connection' => 'keep-alive',
|
||||||
'sec-ch-ua' => '"Not/A)Brand";v="8", "Chromium";v="130", "Google Chrome";v="130"',
|
|
||||||
'sec-ch-ua-mobile' => '?1',
|
|
||||||
'sec-ch-ua-platform' => '"Android"',
|
|
||||||
'sec-fetch-dest' => 'document',
|
|
||||||
'sec-fetch-mode' => 'navigate',
|
|
||||||
'sec-fetch-site' => 'same-origin',
|
|
||||||
'sec-fetch-user' => '?1',
|
|
||||||
'upgrade-insecure-requests' => '1',
|
|
||||||
],
|
],
|
||||||
'pool_size' => 20,
|
'pool_size' => 20,
|
||||||
'verify' => false,
|
'verify' => false,
|
||||||
@@ -261,7 +251,7 @@ class Site
|
|||||||
*/
|
*/
|
||||||
public function getVideoUri(int $intVSourceId): string
|
public function getVideoUri(int $intVSourceId): string
|
||||||
{
|
{
|
||||||
return sprintf('/inc/api_mac10.php?ac=detail&tds=%s', $intVSourceId);
|
return sprintf('/inc/api_mac10.php?ac=detail&ids=%s', $intVSourceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,17 +269,12 @@ class Site
|
|||||||
$arrPromises = [];
|
$arrPromises = [];
|
||||||
foreach ($arrFilter as $intKey => $arrItem) {
|
foreach ($arrFilter as $intKey => $arrItem) {
|
||||||
$arrFilter[$intKey]['uri'] = $this->getVideoUri($arrItem['v_source_id']);
|
$arrFilter[$intKey]['uri'] = $this->getVideoUri($arrItem['v_source_id']);
|
||||||
$arrPromises[$intKey] = $arrFilter[$intKey]['uri'];
|
|
||||||
|
$arrPromises[$intKey] = $this->getClient()->getAsync($arrFilter[$intKey]['uri']);
|
||||||
}
|
}
|
||||||
|
|
||||||
print_r($arrFilter);
|
|
||||||
|
|
||||||
$arrResults = Promise\Utils::settle($arrPromises)->wait();
|
$arrResults = Promise\Utils::settle($arrPromises)->wait();
|
||||||
|
|
||||||
|
|
||||||
var_dump($arrResults);
|
|
||||||
return [];
|
|
||||||
|
|
||||||
$arrSuccessfulResults = array_filter($arrResults, function ($arrResult) {
|
$arrSuccessfulResults = array_filter($arrResults, function ($arrResult) {
|
||||||
return $arrResult['state'] === 'fulfilled';
|
return $arrResult['state'] === 'fulfilled';
|
||||||
});
|
});
|
||||||
@@ -297,8 +282,6 @@ class Site
|
|||||||
foreach ($arrSuccessfulResults as $intKey => $arrResult) {
|
foreach ($arrSuccessfulResults as $intKey => $arrResult) {
|
||||||
$Response = $arrResult['value'];
|
$Response = $arrResult['value'];
|
||||||
|
|
||||||
var_dump($arrResult);
|
|
||||||
|
|
||||||
$strContent = $Response->getBody()->getContents();;
|
$strContent = $Response->getBody()->getContents();;
|
||||||
|
|
||||||
$VideoInfoPage = $this->getVideoInfoPage($this, $arrFilter[$intKey]['uri']);
|
$VideoInfoPage = $this->getVideoInfoPage($this, $arrFilter[$intKey]['uri']);
|
||||||
|
|||||||
@@ -54,6 +54,16 @@ class VideoInfoPage extends BasePage
|
|||||||
if (empty($this->arrVideo)) {
|
if (empty($this->arrVideo)) {
|
||||||
|
|
||||||
$this->arrVideo = json_decode($this->getContent(), true);
|
$this->arrVideo = json_decode($this->getContent(), true);
|
||||||
|
$this->arrVideo = $this->arrVideo['list'][0];
|
||||||
|
$this->arrVideo['vod_play_url'] = str_replace('#', '$', $this->arrVideo['vod_play_url']);
|
||||||
|
$this->arrVideo['vod_play_url'] = explode('$', $this->arrVideo['vod_play_url']);
|
||||||
|
$this->arrVideo['vod_play_url'] = array_chunk($this->arrVideo['vod_play_url'], 2);
|
||||||
|
foreach ($this->arrVideo['vod_play_url'] as $intKey => $arrVal) {
|
||||||
|
$this->arrVideo['vod_play_url'][$intKey] = [
|
||||||
|
'name' => $arrVal[0],
|
||||||
|
'url' => $arrVal[1],
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->arrVideo;
|
return $this->arrVideo;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use think\template\TagLib;
|
|||||||
class Novel extends TagLib
|
class Novel extends TagLib
|
||||||
{
|
{
|
||||||
protected $tags = [
|
protected $tags = [
|
||||||
'list' => ['attr' => 'limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val', 'close' => 1],
|
'list' => ['attr' => 'count,n_category,sort_type,n_status,n_sex,diff_key,cache_life,d_key,d_val', 'close' => 1],
|
||||||
'pager' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 1],
|
'pager' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 1],
|
||||||
'pagerexp' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 0],
|
'pagerexp' => ['attr' => 'page,limit,n_category,sort_type,n_status,n_sex,key,diff_key,cache_life,d_key,d_val,p_val,func,export_name', 'close' => 0],
|
||||||
'info' => ['attr' => 'n_id,n_key', 'close' => 0],
|
'info' => ['attr' => 'n_id,n_key', 'close' => 0],
|
||||||
@@ -15,6 +15,8 @@ class Novel extends TagLib
|
|||||||
'status' => ['attr' => 'd_key,d_val'],
|
'status' => ['attr' => 'd_key,d_val'],
|
||||||
'sex' => ['attr' => 'd_key,d_val'],
|
'sex' => ['attr' => 'd_key,d_val'],
|
||||||
'category' => ['attr' => 'd_key,d_val,n_sex'],
|
'category' => ['attr' => 'd_key,d_val,n_sex'],
|
||||||
|
|
||||||
|
'ranklist' => ['attr' => 'count,sort_type,n_status,n_sex,diff_key,cache_life,d_key,d_val', 'close' => 1],
|
||||||
];
|
];
|
||||||
|
|
||||||
private function customBuildVar($mixedArgs)
|
private function customBuildVar($mixedArgs)
|
||||||
@@ -27,8 +29,67 @@ class Novel extends TagLib
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* novel 自定义标签
|
* tagRankList
|
||||||
|
*
|
||||||
|
* @param array $tag
|
||||||
|
* @param string $content
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function tagRankList($tag, $content)
|
||||||
|
{
|
||||||
|
$count = $tag['count'] ?? '10';
|
||||||
|
$sort_type = $tag['sort_type'] ?? "";
|
||||||
|
$n_status = $tag['n_status'] ?? "all";
|
||||||
|
$n_sex = $tag['n_sex'] ?? "all";
|
||||||
|
|
||||||
|
$diff_key = $tag['diff_key'] ?? "";
|
||||||
|
$cache_life = $tag['cache_life'] ?? '0';
|
||||||
|
$d_key = $tag['d_key'] ?? 'd_key';
|
||||||
|
$d_val = $tag['d_val'] ?? 'd_val';
|
||||||
|
|
||||||
|
$sort_type = $this->customBuildVar($sort_type);
|
||||||
|
$n_status = $this->customBuildVar($n_status);
|
||||||
|
$n_sex = $this->customBuildVar($n_sex);
|
||||||
|
$diff_key = $this->customBuildVar($diff_key);
|
||||||
|
$cache_life = $this->customBuildVar($cache_life);
|
||||||
|
|
||||||
|
$arrDataName = randomString(5);
|
||||||
|
|
||||||
|
$strParse = <<<EOT
|
||||||
|
<?php
|
||||||
|
\${$arrDataName} = app(\\app\\services\\NovelService::class)->getRankList([
|
||||||
|
'count' => {$count},
|
||||||
|
'sort_type' => {$sort_type},
|
||||||
|
'n_status' => {$n_status},
|
||||||
|
'n_sex' => {$n_sex},
|
||||||
|
'diff_key' => {$diff_key},
|
||||||
|
'cache_life' => {$cache_life}
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!empty(\${$arrDataName}) && is_array(\${$arrDataName})):
|
||||||
|
|
||||||
|
?>
|
||||||
|
EOT;
|
||||||
|
$strParse .= <<<EOT
|
||||||
|
<?php foreach (\${$arrDataName} as \${$d_key} => \${$d_val}): ?>
|
||||||
|
EOT;
|
||||||
|
$strParse .= $content;
|
||||||
|
$strParse .= <<<EOT
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
EOT;
|
||||||
|
return $strParse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* tagPagerExp
|
||||||
|
*
|
||||||
|
* @param array $tag
|
||||||
|
* @param string $content
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tagPagerExp($tag, $content)
|
public function tagPagerExp($tag, $content)
|
||||||
{
|
{
|
||||||
@@ -36,7 +97,11 @@ class Novel extends TagLib
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* novel 自定义标签
|
* tagPager
|
||||||
|
*
|
||||||
|
* @param array $tag
|
||||||
|
* @param string $content
|
||||||
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function tagPager($tag, $content)
|
public function tagPager($tag, $content)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ class Site extends TagLib
|
|||||||
'replace' => ['attr' => 'code,diff', 'close' => 0],
|
'replace' => ['attr' => 'code,diff', 'close' => 0],
|
||||||
|
|
||||||
'forgelist' => ['attr' => 'count,diff_key,cache_life,d_key,d_val', 'close' => 1],
|
'forgelist' => ['attr' => 'count,diff_key,cache_life,d_key,d_val', 'close' => 1],
|
||||||
|
'helper' => ['attr' => 'func', 'close' => 0],
|
||||||
];
|
];
|
||||||
|
|
||||||
private function customBuildVar($mixedArgs)
|
private function customBuildVar($mixedArgs)
|
||||||
@@ -31,6 +32,26 @@ class Site extends TagLib
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 小说详情URL生成器
|
||||||
|
*
|
||||||
|
* @param array $n_id
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function tagHelper($tag)
|
||||||
|
{
|
||||||
|
$strFunc = (string)$tag['func'];
|
||||||
|
|
||||||
|
// $strFunc = $this->customBuildVar($strFunc);
|
||||||
|
|
||||||
|
$strParse = <<<EOD
|
||||||
|
<?php
|
||||||
|
app(\\app\\services\\SiteContext::class)->{$strFunc}();
|
||||||
|
?>
|
||||||
|
EOD;
|
||||||
|
return $strParse;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tagRankList
|
* tagRankList
|
||||||
@@ -297,11 +318,6 @@ EOD;
|
|||||||
return $strParse;
|
return $strParse;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 内容替换
|
* 内容替换
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -374,4 +374,13 @@ resData = [
|
|||||||
|
|
||||||
</li>
|
</li>
|
||||||
{/site:forgelist}
|
{/site:forgelist}
|
||||||
|
|
||||||
|
|
||||||
|
# 14、 视图反向控制器(注释函数),在视图开头调用,用来初始化一些操作。这里尽量不要复杂逻辑
|
||||||
|
# 传参与默认值(传参用下面的变量名,名称不需要$符号, 值的话如果用第三方变量作为值,需要带$符号):
|
||||||
|
$func # SiteContext 里面的方法名
|
||||||
|
|
||||||
|
# 样例
|
||||||
|
{site:helper func="initHomeTKD" /}
|
||||||
|
|
||||||
```
|
```
|
||||||
Reference in New Issue
Block a user