更新3.0

This commit is contained in:
admin
2025-03-28 17:00:42 +08:00
parent 86038423e1
commit 6cc49273b6
62 changed files with 6470 additions and 5240 deletions
+24 -120
View File
@@ -15,7 +15,6 @@ class Other extends QfShop
{
parent::__construct($app);
$this->model = new SourceModel();
$this->cookie = Config('qfshop.quark_cookie');
}
/**
@@ -25,14 +24,9 @@ class Other extends QfShop
*/
public function all_search($param='')
{
if(empty($param)){
$searchdata = input('post.');
if (empty($searchdata['title'])) {
return jerr("请输入要看的内容");
}
$title = $searchdata['title'];
}else{
$title = $param;
$title = $param ?: input('post.title', '');
if (empty($title)) {
return jerr("请输入要看的内容");
}
$map[] = ['status', '=', 1];
@@ -42,29 +36,17 @@ class Other extends QfShop
$urls = $this->model->where($map)->field('source_id as id, title, url,is_time')->order('update_time', 'desc')->limit(5)->select()->toArray();
if (!empty($urls)) {
// 获取所有需要更新的ID
$ids = [];
foreach ($urls as $item) {
$ids[] = $item['id'];
}
// 更新数据库中的 update_time 字段
if (!empty($ids)) {
$this->model->whereIn('source_id', $ids)->update(['update_time' => time()]);
}
$ids = array_column($urls, 'id');
$this->model->whereIn('source_id', $ids)->update(['update_time' => time()]);
return !empty($param) ? $urls : jok('临时资源获取成功', $urls);
}
//同一个搜索内容锁机
if (Cache::has($title)) {
//同一个搜索内容锁机
if (Cache::has($title)) {
// 检查缓存中是否已有结果
return !empty($param) ? Cache::get($title) : jok('临时资源获取成功', Cache::get($title));
}
// 检查是否有正在处理的请求
if (Cache::has($title . '_processing')) {
// 如果当前正在处理相同关键词的请求,等待结果
@@ -89,41 +71,19 @@ class Other extends QfShop
$num_total = 2; //最多想要几条结果
$num_success = 0;
// 处理第2个源
foreach (source2($title) as $value) {
// 定义源的顺序
$sources = ['source2', 'source4', 'source5', 'source3', 'source1'];
foreach ($sources as $source) {
if ($num_success >= $num_total) {
break; // 有效结果数量已达到,则跳出循环
break;
}
// 如果 URL 不存在则新增 $value
if (!$this->urlExists($searchList, $value['url'])) {
$searchList[] = $value;
$this->processUrl($value, $num_success, $datas);
}
}
// 处理第4个源
if ($num_success < $num_total) {
foreach (source4($title) as $value) {
foreach ($source($title) as $value) {
if ($num_success >= $num_total) {
break; // 有效结果数量已达到,则跳出循环
break;
}
// 如果 URL 不存在则新增 $value
if (!$this->urlExists($searchList, $value['url'])) {
$searchList[] = $value;
$this->processUrl($value, $num_success, $datas);
}
}
}
// 处理第5个源
if ($num_success < $num_total) {
foreach (source5($title) as $value) {
if ($num_success >= $num_total) {
break; // 有效结果数量已达到,则跳出循环
}
// 如果 URL 不存在则新增 $value
if (!$this->urlExists($searchList, $value['url'])) {
$searchList[] = $value;
$this->processUrl($value, $num_success, $datas);
@@ -131,36 +91,6 @@ class Other extends QfShop
}
}
// 处理第3个源
if ($num_success < $num_total) {
foreach (source3($title) as $value) {
if ($num_success >= $num_total) {
break; // 有效结果数量已达到,则跳出循环
}
// 如果 URL 不存在则新增 $value
if (!$this->urlExists($searchList, $value['url'])) {
$searchList[] = $value;
$this->processUrl($value, $num_success, $datas);
}
}
}
// 处理第1个源 第一个源放最后
if ($num_success < $num_total) {
foreach (source1($title) as $value) {
if ($num_success >= $num_total) {
break; // 有效结果数量已达到,则跳出循环
}
// 如果 URL 不存在则新增 $value
if (!$this->urlExists($searchList, $value['url'])) {
$searchList[] = $value;
$this->processUrl($value, $num_success, $datas);
}
}
}
Cache::set($title, $datas, 60); // 缓存结果60秒
Cache::delete($title . '_processing'); // 解锁
@@ -201,15 +131,14 @@ class Other extends QfShop
$pwd_id = substr($substring, 2); // 去除 's/' 部分
$urlData = array(
'cookie' => $this->cookie,
'url' => $value['url'],
'expired_type' => 2,
'to_pdir_fid' => '', //存入目标文件
'ad_fid' => '', //分享时带上这个文件
);
$res = curlHelper(Request::domain()."/api/open/transfer", "POST", $urlData)['body'];
$res = json_decode($res, true);
$transfer = new \netdisk\Transfer();
$res = $transfer->transfer($urlData);
if($res['code'] !== 200){
return; // 模拟 continue 行为
}
@@ -247,40 +176,15 @@ class Other extends QfShop
$this->model->where($map)->chunk(100, function ($order) {
foreach ($order as $value) {
$deles = $value->toArray();
// $filelist = [];
// $filelist[] = $deles['fid'];
$fid = $deles['fid'];
// 尝试解码,如果是有效的 JSON 数组则使用,否则转为单元素数组
$filelist = (is_string($fid) && ($decodedFid = json_decode($fid, true)) && is_array($decodedFid)) ? $decodedFid : (array)$fid;
$urlData = array(
'action_type' => 2,
'exclude_fids' => [],
'filelist' => $filelist,
);
$urlHeader = array(
'Accept: application/json, text/plain, */*',
'Accept-Language: zh-CN,zh;q=0.9',
'content-type: application/json;charset=UTF-8',
'sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"',
'sec-ch-ua-mobile: ?0',
'sec-ch-ua-platform: "Windows"',
'sec-fetch-dest: empty',
'sec-fetch-mode: cors',
'sec-fetch-site: same-site',
'Referer: https://pan.quark.cn/',
'Referrer-Policy: strict-origin-when-cross-origin',
'user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
'cookie: '.$this->cookie,
);
$res = curlHelper("https://drive-pc.quark.cn/1/clouddrive/file/delete?pr=ucpro&fr=pc&uc_param_str=", "POST", json_encode($urlData), $urlHeader)['body'];
$res = json_decode($res, true);
if($res['status'] == 200){
$this->model->where('fid', $deles['fid'])->delete();
}
$this->model->where('fid', $deles['fid'])->delete();
$transfer = new \netdisk\Transfer();
$transfer->deletepdirFid($deles['is_type'],$filelist);
}
});