chore: 批量修改文件权限为可执行
将项目内绝大多数文件的权限从644调整为755,统一可执行权限配置
This commit is contained in:
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+151
-127
@@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
declare (strict_types = 1);
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace app\command;
|
namespace app\command;
|
||||||
|
|
||||||
use Exception;
|
use Exception;
|
||||||
use think\console\Command;
|
use think\console\Command;
|
||||||
use think\console\Input;
|
use think\console\Input;
|
||||||
@@ -31,9 +33,9 @@ class Lebo extends Command
|
|||||||
}
|
}
|
||||||
protected function execute(Input $input, Output $output)
|
protected function execute(Input $input, Output $output)
|
||||||
{
|
{
|
||||||
$this->aria2 = new Aria2('http://127.0.0.1:16800/jsonrpc','11223344');
|
$this->aria2 = new Aria2('http://192.168.100.106:16800/jsonrpc', '11223344');
|
||||||
$this->completed = false;
|
$this->completed = false;
|
||||||
while($this->completed === false){
|
while ($this->completed === false) {
|
||||||
try {
|
try {
|
||||||
$this->start();
|
$this->start();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
@@ -47,33 +49,45 @@ class Lebo extends Command
|
|||||||
}
|
}
|
||||||
private function start()
|
private function start()
|
||||||
{
|
{
|
||||||
// $savepath = store_path() . '/lebolebo/';
|
$savepath = store_path() . '/lebolebo/';
|
||||||
$savepath = 'D:/lebolebo/';
|
// $savepath = 'D:/lebolebo/';
|
||||||
|
$account_cache_key = 'lebo_account';
|
||||||
|
$account_info = Cache::get($account_cache_key);
|
||||||
|
if ($account_info) {
|
||||||
|
} else {
|
||||||
$account = new Account();
|
$account = new Account();
|
||||||
$account_info = $account->login('13880615958','robo520');
|
$account_info = $account->login('13880615958', 'robo520');
|
||||||
if($account_info['code'] == 500){
|
if ($account_info['code'] == 500) {
|
||||||
dump($account_info['msg']);
|
dump($account_info['msg']);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
$curl = new Curl();
|
Cache::set($account_cache_key, $account_info, 3600);
|
||||||
|
dump('账号信息缓存成功');
|
||||||
|
}
|
||||||
|
// $curl = new Curl();
|
||||||
$curr = new Curriculum();
|
$curr = new Curriculum();
|
||||||
$curr->setHeader('token',$account_info['data']['token']);
|
$curr->setHeader('token', $account_info['data']['token']);
|
||||||
$course = $curr->list(0);
|
$course = $curr->list(1);
|
||||||
|
|
||||||
foreach ($course['data']['list'] as $list){
|
foreach ($course['data']['list'] as $index => $list) {
|
||||||
$c = $savepath . $list['courseName'];
|
$c = $savepath . $list['courseName'];
|
||||||
is_dir($c) || mkdir($c,0755,true);
|
// dump($index,$list['courseName']);
|
||||||
|
if ($list['courseName'] != '线上-CSP-J 集训课程') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
is_dir($c) || mkdir($c, 0755, true);
|
||||||
$detail = $curr->detail($list['id']);
|
$detail = $curr->detail($list['id']);
|
||||||
$courseCover = $c . '/courseCover.png';
|
$courseCover = $c . '/courseCover.png';
|
||||||
if($detail['data']['courseCover']){
|
if ($detail['data']['courseCover']) {
|
||||||
$downloadurl = $detail['data']['courseCover'];
|
$downloadurl = $detail['data']['courseCover'];
|
||||||
$check = $this->checkfile($downloadurl,$courseCover);
|
$check = $this->checkfile($downloadurl, $courseCover);
|
||||||
if(!$check && !is_file($courseCover)){
|
if (!$check && !is_file($courseCover)) {
|
||||||
// $result = $curl->_fastDownload($downloadurl,$courseCover);
|
// $result = $curl->_fastDownload($downloadurl,$courseCover);
|
||||||
$this->aria2->addUri(
|
$this->aria2->addUri(
|
||||||
[$downloadurl],
|
[$downloadurl],
|
||||||
['dir'=>$c,
|
[
|
||||||
'out'=>'courseCover.png'
|
'dir' => $c,
|
||||||
|
'out' => 'courseCover.png'
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
// dump('封面下载结果:',$result);
|
// dump('封面下载结果:',$result);
|
||||||
@@ -82,26 +96,26 @@ class Lebo extends Command
|
|||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
$txt = $courseCover . '-下载地址.txt';
|
$txt = $courseCover . '-下载地址.txt';
|
||||||
$this->savetxt($txt,$downloadurl);
|
$this->savetxt($txt, $downloadurl);
|
||||||
}
|
}
|
||||||
$d = $curr->courseUnitList($list['courseCode']);
|
$d = $curr->courseUnitList($list['courseCode']);
|
||||||
$courseUnits = $d['data']['courseUnit'];
|
$courseUnits = $d['data']['courseUnit'];
|
||||||
if($courseUnits === null){
|
if ($courseUnits === null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
foreach ($courseUnits as $courseUnit){
|
foreach ($courseUnits as $courseUnit) {
|
||||||
$courseUnitName = $c . '/' . str_ireplace('/','-',$courseUnit['courseUnitName']);
|
$courseUnitName = $c . '/' . str_ireplace('/', '-', $courseUnit['courseUnitName']);
|
||||||
if(!is_dir($courseUnitName)){
|
if (!is_dir($courseUnitName)) {
|
||||||
dump('创建课程文件夹:' . $courseUnitName);
|
dump('创建课程文件夹:' . $courseUnitName);
|
||||||
mkdir($courseUnitName,0755,true);
|
mkdir($courseUnitName, 0755, true);
|
||||||
}
|
}
|
||||||
$selectByCourseUnits = $curr->selectByCourseUnits($courseUnit['courseCode'],$courseUnit['courseUnitCode']);
|
$selectByCourseUnits = $curr->selectByCourseUnits($courseUnit['courseCode'], $courseUnit['courseUnitCode']);
|
||||||
foreach ($selectByCourseUnits['data'] as $selectByCourseUnit){
|
foreach ($selectByCourseUnits['data'] as $selectByCourseUnit) {
|
||||||
$this->waiting();
|
$this->waiting();
|
||||||
$sessionName = $courseUnitName . '/' . $selectByCourseUnit['sessionName'];
|
$sessionName = $courseUnitName . '/' . $selectByCourseUnit['sessionName'];
|
||||||
if(!is_dir($sessionName)){
|
if (!is_dir($sessionName)) {
|
||||||
dump('创建课件文件夹:'.$sessionName);
|
dump('创建课件文件夹:' . $sessionName);
|
||||||
mkdir($sessionName,0755,true);
|
mkdir($sessionName, 0755, true);
|
||||||
}
|
}
|
||||||
$t = $curr->selectByCourseSessionCode($selectByCourseUnit['courseSessionCode']);
|
$t = $curr->selectByCourseSessionCode($selectByCourseUnit['courseSessionCode']);
|
||||||
// 0: {type: 1, des: "PPT-HTML"}
|
// 0: {type: 1, des: "PPT-HTML"}
|
||||||
@@ -119,20 +133,20 @@ class Lebo extends Command
|
|||||||
// 12: {type: 16, des: "课后拓展"}
|
// 12: {type: 16, des: "课后拓展"}
|
||||||
// 13: {type: 18, des: "素养目标"}
|
// 13: {type: 18, des: "素养目标"}
|
||||||
$ts = $t['data'];
|
$ts = $t['data'];
|
||||||
foreach ($ts as $kk ){
|
foreach ($ts as $kk) {
|
||||||
switch ($kk['resourceType']) {
|
switch ($kk['resourceType']) {
|
||||||
case '1':// PPT-HTML
|
case '1': // PPT-HTML
|
||||||
if(!isset($kk['content'])){
|
if (!isset($kk['content'])) {
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
$filename = $kk['content']['fileName'];
|
$filename = $kk['content']['fileName'];
|
||||||
$downloadurl = $kk['content']['fileUrl'];
|
$downloadurl = $kk['content']['fileUrl'];
|
||||||
$file = $sessionName . '/' . $filename;
|
$file = $sessionName . '/' . $filename;
|
||||||
// 保存下载地址
|
// 保存下载地址
|
||||||
$txt = "{$file}-下载地址.txt";
|
$txt = "{$file}-下载地址.txt";
|
||||||
$this->savetxt($txt,$downloadurl);
|
$this->savetxt($txt, $downloadurl);
|
||||||
$check = $this->checkfile($downloadurl,$file);
|
$check = $this->checkfile($downloadurl, $file);
|
||||||
if(!$check && !is_file($file)){
|
if (!$check && !is_file($file)) {
|
||||||
dump('下载PPT:' . $file);
|
dump('下载PPT:' . $file);
|
||||||
// $result = $curl->_fastDownload($downloadurl,$file);
|
// $result = $curl->_fastDownload($downloadurl,$file);
|
||||||
// dump('PPT下载结果:',$result);
|
// dump('PPT下载结果:',$result);
|
||||||
@@ -141,18 +155,20 @@ class Lebo extends Command
|
|||||||
// }
|
// }
|
||||||
$this->aria2->addUri(
|
$this->aria2->addUri(
|
||||||
[$downloadurl],
|
[$downloadurl],
|
||||||
['dir'=>$sessionName,
|
[
|
||||||
'out'=>$filename]
|
'dir' => $sessionName,
|
||||||
|
'out' => $filename
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}else if($check && !is_file($file)){
|
} else if ($check && !is_file($file)) {
|
||||||
if(is_file($check)){
|
if (is_file($check)) {
|
||||||
try {
|
try {
|
||||||
copy($check,$file);
|
copy($check, $file);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dump('文件拷贝失败:',$e);
|
dump('文件拷贝失败:', $e);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
dump('下载PPT:' . $file);
|
dump('下载PPT:' . $file);
|
||||||
// $result = $curl->_fastDownload($downloadurl,$file);
|
// $result = $curl->_fastDownload($downloadurl,$file);
|
||||||
// dump('PPT下载结果:',$result);
|
// dump('PPT下载结果:',$result);
|
||||||
@@ -161,15 +177,17 @@ class Lebo extends Command
|
|||||||
// }
|
// }
|
||||||
$this->aria2->addUri(
|
$this->aria2->addUri(
|
||||||
[$downloadurl],
|
[$downloadurl],
|
||||||
['dir'=>$sessionName,
|
[
|
||||||
'out'=>$filename]
|
'dir' => $sessionName,
|
||||||
|
'out' => $filename
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
dump('跳过PPT:' . $file);
|
dump('跳过PPT:' . $file);
|
||||||
}else{
|
} else {
|
||||||
dump('PPT文件已存在:' . $file);
|
dump('PPT文件已存在:' . $file);
|
||||||
$this->complete($downloadurl,$file);
|
$this->complete($downloadurl, $file);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
@@ -183,20 +201,20 @@ class Lebo extends Command
|
|||||||
case '6':
|
case '6':
|
||||||
// 试一试
|
// 试一试
|
||||||
$shiyishi = $sessionName . '/试一试/';
|
$shiyishi = $sessionName . '/试一试/';
|
||||||
if(!is_dir($shiyishi)){
|
if (!is_dir($shiyishi)) {
|
||||||
mkdir($shiyishi,0755,true);
|
mkdir($shiyishi, 0755, true);
|
||||||
}
|
}
|
||||||
$questions = $kk['content']['questions'];
|
$questions = $kk['content']['questions'];
|
||||||
if(!is_array($questions))break;
|
if (!is_array($questions)) break;
|
||||||
foreach ($questions as $key => $question) {
|
foreach ($questions as $key => $question) {
|
||||||
$filename = $question['fileName'];
|
$filename = $question['fileName'];
|
||||||
$downloadurl = $question['fileUrl'];
|
$downloadurl = $question['fileUrl'];
|
||||||
$file = $shiyishi . $filename;
|
$file = $shiyishi . $filename;
|
||||||
// 保存文件下载地址
|
// 保存文件下载地址
|
||||||
$txt = "{$file}-下载地址.txt";
|
$txt = "{$file}-下载地址.txt";
|
||||||
$this->savetxt($txt,$downloadurl);
|
$this->savetxt($txt, $downloadurl);
|
||||||
$check = $this->checkfile($downloadurl,$file);
|
$check = $this->checkfile($downloadurl, $file);
|
||||||
if(!$check && !is_file($file)){
|
if (!$check && !is_file($file)) {
|
||||||
// $result = $curl->_fastDownload($downloadurl,$file);
|
// $result = $curl->_fastDownload($downloadurl,$file);
|
||||||
// dump('试一试下载结果:',$result);
|
// dump('试一试下载结果:',$result);
|
||||||
// if($result){
|
// if($result){
|
||||||
@@ -204,15 +222,17 @@ class Lebo extends Command
|
|||||||
// }
|
// }
|
||||||
$this->aria2->addUri(
|
$this->aria2->addUri(
|
||||||
[$downloadurl],
|
[$downloadurl],
|
||||||
['dir'=>$shiyishi,
|
[
|
||||||
'out'=>$filename]
|
'dir' => $shiyishi,
|
||||||
|
'out' => $filename
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}else if($check && !is_file($file)){
|
} else if ($check && !is_file($file)) {
|
||||||
copy($check,$file);
|
copy($check, $file);
|
||||||
dump('跳过试一试:' . $file);
|
dump('跳过试一试:' . $file);
|
||||||
}else{
|
} else {
|
||||||
dump('试一试文件已存在:' . $file);
|
dump('试一试文件已存在:' . $file);
|
||||||
$this->complete($downloadurl,$file);
|
$this->complete($downloadurl, $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -224,30 +244,30 @@ class Lebo extends Command
|
|||||||
break;
|
break;
|
||||||
case '13':
|
case '13':
|
||||||
// 教辅
|
// 教辅
|
||||||
if(!isset($kk['content']['resourceList'])){
|
if (!isset($kk['content']['resourceList'])) {
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
$jiaofupath = $sessionName . '/教辅/';
|
$jiaofupath = $sessionName . '/教辅/';
|
||||||
if(!is_dir($jiaofupath)){
|
if (!is_dir($jiaofupath)) {
|
||||||
mkdir($jiaofupath,0755,true);
|
mkdir($jiaofupath, 0755, true);
|
||||||
}
|
}
|
||||||
$resourceLists = $kk['content']['resourceList'];
|
$resourceLists = $kk['content']['resourceList'];
|
||||||
foreach($resourceLists as $resourceList){
|
foreach ($resourceLists as $resourceList) {
|
||||||
if(empty($resourceList['fileName'])){
|
if (empty($resourceList['fileName'])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$file = $jiaofupath . $resourceList['fileName'] ;
|
$file = $jiaofupath . $resourceList['fileName'];
|
||||||
if(Str::endsWith($file,['.mp4','.mov'])){
|
if (Str::endsWith($file, ['.mp4', '.mov'])) {
|
||||||
$dd = $curr->getVideoUrl($resourceList['fileUrl']);
|
$dd = $curr->getVideoUrl($resourceList['fileUrl']);
|
||||||
$downloadurl = $dd['data'];
|
$downloadurl = $dd['data'];
|
||||||
}else{
|
} else {
|
||||||
$downloadurl = $resourceList['fileUrl'];
|
$downloadurl = $resourceList['fileUrl'];
|
||||||
}
|
}
|
||||||
// 保存下载地址
|
// 保存下载地址
|
||||||
$txt = "{$file}-下载地址.txt";
|
$txt = "{$file}-下载地址.txt";
|
||||||
$this->savetxt($txt,$downloadurl);
|
$this->savetxt($txt, $downloadurl);
|
||||||
$check = $this->checkfile($downloadurl,$file);
|
$check = $this->checkfile($downloadurl, $file);
|
||||||
if(!$check && !is_file($file)){
|
if (!$check && !is_file($file)) {
|
||||||
dump('下载教辅:' . $file);
|
dump('下载教辅:' . $file);
|
||||||
// $result = $curl->_fastDownload($downloadurl,$file);
|
// $result = $curl->_fastDownload($downloadurl,$file);
|
||||||
// dump('教辅下载结果:',$result);
|
// dump('教辅下载结果:',$result);
|
||||||
@@ -256,41 +276,43 @@ class Lebo extends Command
|
|||||||
// }
|
// }
|
||||||
$this->aria2->addUri(
|
$this->aria2->addUri(
|
||||||
[$downloadurl],
|
[$downloadurl],
|
||||||
['dir'=>$jiaofupath,
|
[
|
||||||
'out'=>$resourceList['fileName']]
|
'dir' => $jiaofupath,
|
||||||
|
'out' => $resourceList['fileName']
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}else if($check && !is_file($file)){
|
} else if ($check && !is_file($file)) {
|
||||||
copy($check,$file);
|
copy($check, $file);
|
||||||
dump('跳过教辅:' . $file);
|
dump('跳过教辅:' . $file);
|
||||||
}else{
|
} else {
|
||||||
dump('教辅文件已存在:' . $file);
|
dump('教辅文件已存在:' . $file);
|
||||||
$this->complete($downloadurl,$file);
|
$this->complete($downloadurl, $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '14':
|
case '14':
|
||||||
// 备课
|
// 备课
|
||||||
if(!isset($kk['content']['resourceList'])){
|
if (!isset($kk['content']['resourceList'])) {
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
$beikepath = $sessionName . '/备课/';
|
$beikepath = $sessionName . '/备课/';
|
||||||
if(!is_dir($beikepath)){
|
if (!is_dir($beikepath)) {
|
||||||
mkdir($beikepath,0755,true);
|
mkdir($beikepath, 0755, true);
|
||||||
}
|
}
|
||||||
$resourceLists = $kk['content']['resourceList'];
|
$resourceLists = $kk['content']['resourceList'];
|
||||||
foreach($resourceLists as $resourceList){
|
foreach ($resourceLists as $resourceList) {
|
||||||
$file = $beikepath . $resourceList['fileName'] ;
|
$file = $beikepath . $resourceList['fileName'];
|
||||||
if(Str::endsWith($file,['.mp4','.mov','.MP4','.mkv','.wmv'])){
|
if (Str::endsWith($file, ['.mp4', '.mov', '.MP4', '.mkv', '.wmv'])) {
|
||||||
$dd = $curr->getVideoUrl($resourceList['fileUrl']);
|
$dd = $curr->getVideoUrl($resourceList['fileUrl']);
|
||||||
$downloadurl = $dd['data'];
|
$downloadurl = $dd['data'];
|
||||||
}else{
|
} else {
|
||||||
$downloadurl = $resourceList['fileUrl'];
|
$downloadurl = $resourceList['fileUrl'];
|
||||||
}
|
}
|
||||||
// 保存下载地址
|
// 保存下载地址
|
||||||
$txt = "{$file}-下载地址.txt";
|
$txt = "{$file}-下载地址.txt";
|
||||||
$this->savetxt($txt,$downloadurl);
|
$this->savetxt($txt, $downloadurl);
|
||||||
$check = $this->checkfile($downloadurl,$file);
|
$check = $this->checkfile($downloadurl, $file);
|
||||||
if(!$check && !is_file($file)){
|
if (!$check && !is_file($file)) {
|
||||||
dump('下载备课:' . $file);
|
dump('下载备课:' . $file);
|
||||||
// $result = $curl->_fastDownload($downloadurl,$file);
|
// $result = $curl->_fastDownload($downloadurl,$file);
|
||||||
// dump('备课下载结果:',$result);
|
// dump('备课下载结果:',$result);
|
||||||
@@ -299,23 +321,25 @@ class Lebo extends Command
|
|||||||
// }
|
// }
|
||||||
$this->aria2->addUri(
|
$this->aria2->addUri(
|
||||||
[$downloadurl],
|
[$downloadurl],
|
||||||
['dir'=>$beikepath,
|
[
|
||||||
'out'=>$resourceList['fileName']]
|
'dir' => $beikepath,
|
||||||
|
'out' => $resourceList['fileName']
|
||||||
|
]
|
||||||
);
|
);
|
||||||
}else if($check && !is_file($file)){
|
} else if ($check && !is_file($file)) {
|
||||||
copy($check,$file);
|
copy($check, $file);
|
||||||
dump('跳过备课:' . $file);
|
dump('跳过备课:' . $file);
|
||||||
}else{
|
} else {
|
||||||
dump('备课文件已存在:' . $file);
|
dump('备课文件已存在:' . $file);
|
||||||
$this->complete($downloadurl,$file);
|
$this->complete($downloadurl, $file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case '15':
|
case '15':
|
||||||
// 课程内容
|
// 课程内容
|
||||||
if(is_null($kk['content']['courseContent']))break;
|
if (is_null($kk['content']['courseContent'])) break;
|
||||||
$file = "{$sessionName}/课程内容.txt";
|
$file = "{$sessionName}/课程内容.txt";
|
||||||
$this->savetxt($file,strip_tags($kk['content']['courseContent']));
|
$this->savetxt($file, strip_tags($kk['content']['courseContent']));
|
||||||
break;
|
break;
|
||||||
case '16':
|
case '16':
|
||||||
break;
|
break;
|
||||||
@@ -332,76 +356,76 @@ class Lebo extends Command
|
|||||||
}
|
}
|
||||||
$this->completed = true;
|
$this->completed = true;
|
||||||
}
|
}
|
||||||
private function checkfile($url,$file)
|
private function checkfile($url, $file)
|
||||||
{
|
{
|
||||||
$key = 'lebolebo_check_header_'.md5($url);
|
$key = 'lebolebo_check_header_' . md5($url);
|
||||||
try {
|
try {
|
||||||
if(($head = Cache::get($key,null)) === NULL ){
|
if (($head = Cache::get($key, null)) === NULL) {
|
||||||
$head = @get_headers($url,1);
|
$head = @get_headers($url, true);
|
||||||
if ($head === false) {
|
if ($head === false) {
|
||||||
dump('获取文件信息失败,直接重新下载'.$file);
|
dump('获取文件信息失败,直接重新下载' . $file);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Cache::set($key,$head,86400);
|
Cache::set($key, $head, 86400);
|
||||||
}
|
}
|
||||||
$kk = 'lebolebo_file_' . pathinfo($file,PATHINFO_BASENAME);
|
$kk = 'lebolebo_file_' . pathinfo($file, PATHINFO_BASENAME);
|
||||||
if(isset($head['Content-Length']) && ($size = intval($head['Content-Length']))){
|
if (isset($head['Content-Length']) && ($size = intval($head['Content-Length']))) {
|
||||||
$kk .= $size;
|
$kk .= $size;
|
||||||
if(is_file($file) && ($size !== filesize($file))){
|
if (is_file($file) && ($size !== filesize($file))) {
|
||||||
dump('文件大小不符,重新下载'.$file);
|
dump('文件大小不符,重新下载' . $file);
|
||||||
unlink($file);
|
unlink($file);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isset($head['ETag'])){
|
if (isset($head['ETag'])) {
|
||||||
$t = $kk . md5($head['ETag']);
|
$t = $kk . md5($head['ETag']);
|
||||||
if(Cache::has($t)){
|
if (Cache::has($t)) {
|
||||||
return Cache::get($t);
|
return Cache::get($t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(isset($head['Content-MD5'])){
|
if (isset($head['Content-MD5'])) {
|
||||||
$t = $kk . md5($head['Content-MD5']);
|
$t = $kk . md5($head['Content-MD5']);
|
||||||
if(Cache::has($t)){
|
if (Cache::has($t)) {
|
||||||
return Cache::get($t);
|
return Cache::get($t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dump('检查文件失败:',$url,$file,$e);
|
dump('检查文件失败:', $url, $file, $e);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
private function complete($url,$file)
|
private function complete($url, $file)
|
||||||
{
|
{
|
||||||
$key = 'lebolebo_check_header_' . md5($url);
|
$key = 'lebolebo_check_header_' . md5($url);
|
||||||
try {
|
try {
|
||||||
if(($head = Cache::get($key,null)) === NULL ){
|
if (($head = Cache::get($key, null)) === NULL) {
|
||||||
$head = @get_headers($url,1);
|
$head = @get_headers($url, 1);
|
||||||
if($head === false){
|
if ($head === false) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Cache::set($key,$head,86400);
|
Cache::set($key, $head, 86400);
|
||||||
}
|
}
|
||||||
$kk = 'lebolebo_file_' . pathinfo($file,PATHINFO_BASENAME);
|
$kk = 'lebolebo_file_' . pathinfo($file, PATHINFO_BASENAME);
|
||||||
if(isset($head['Content-Length'])){
|
if (isset($head['Content-Length'])) {
|
||||||
$kk .= intval($head['Content-Length']);
|
$kk .= intval($head['Content-Length']);
|
||||||
}
|
}
|
||||||
if(isset($head['ETag'])){
|
if (isset($head['ETag'])) {
|
||||||
$t = $kk . md5($head['ETag']);
|
$t = $kk . md5($head['ETag']);
|
||||||
Cache::set($t,$file,86400);
|
Cache::set($t, $file, 86400);
|
||||||
}
|
}
|
||||||
if(isset($head['Content-MD5'])){
|
if (isset($head['Content-MD5'])) {
|
||||||
$t = $kk . md5($head['Content-MD5']);
|
$t = $kk . md5($head['Content-MD5']);
|
||||||
Cache::set($t,$file,86400);
|
Cache::set($t, $file, 86400);
|
||||||
}
|
}
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dump($e);
|
dump($e);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private function savetxt(string $file,string $content)
|
private function savetxt(string $file, string $content)
|
||||||
{
|
{
|
||||||
if(is_file($file)){
|
if (is_file($file)) {
|
||||||
unlink($file);
|
unlink($file);
|
||||||
}
|
}
|
||||||
$myfile = fopen($file, "w");
|
$myfile = fopen($file, "w");
|
||||||
@@ -412,13 +436,13 @@ class Lebo extends Command
|
|||||||
private function waiting()
|
private function waiting()
|
||||||
{
|
{
|
||||||
$num = 1;
|
$num = 1;
|
||||||
while($num > 0){
|
while ($num > 0) {
|
||||||
$activeDownloads = $this->aria2->getGlobalStat();
|
$activeDownloads = $this->aria2->getGlobalStat();
|
||||||
$num = intval($activeDownloads['result']['numWaiting']);
|
$num = intval($activeDownloads['result']['numWaiting']);
|
||||||
if($num > 10){
|
if ($num > 10) {
|
||||||
dump('当前任务过多,等待任务数:',$num);
|
dump('当前任务过多,等待任务数:', $num);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}else{
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
+6
-4
@@ -33,14 +33,16 @@ class Curriculum
|
|||||||
|
|
||||||
public function list(int $page = 0)
|
public function list(int $page = 0)
|
||||||
{
|
{
|
||||||
$url = 'https://api-manage2.shengtongedu.cn/st-course-server/manage/course/coursePageListV3';
|
// $url = 'https://api-manage2.shengtongedu.cn/st-course-server/manage/course/coursePageListV3';
|
||||||
|
$url = 'https://api-manage2.shengtongedu.cn/st-course-server/manage/course/coursePageListV6';
|
||||||
$options = [
|
$options = [
|
||||||
'body'=>json_encode([
|
'body'=>json_encode([
|
||||||
'campusIdList'=>["1863"],
|
'campusIdList'=>["2404"],
|
||||||
'pageNum'=>$page,
|
'pageNum'=>$page,
|
||||||
'pageSize'=>200,
|
'pageSize'=>96,
|
||||||
'platform'=>"OMO_WEB",
|
'platform'=>"OMO_WEB",
|
||||||
'total'=>101,
|
'searchType'=>true,
|
||||||
|
'total'=>152,
|
||||||
]),
|
]),
|
||||||
'headers'=>$this->headers
|
'headers'=>$this->headers
|
||||||
];
|
];
|
||||||
|
|||||||
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Regular → Executable
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user