diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 7e1e223..e3c0079 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -2,6 +2,7 @@ namespace App\Console; +use App; use App\Services\BilibiliService; use App\Services\BilibiliServiceV2; use App\Services\CompressImageService; @@ -82,9 +83,9 @@ class Kernel extends ConsoleKernel })->dailyAt('04:00'); $schedule->call(function () { - $bilibili = new BilibiliServiceV2(); - Log::info("schedule checkVideoHasDownload started at: ". date("Y-m-d H:i:s")); - $bilibili->checkVideoHasDownload(); +// $bilibili = new BilibiliServiceV2(); +// Log::info("schedule checkVideoHasDownload started at: ". date("Y-m-d H:i:s")); +// $bilibili->checkVideoHasDownload(); })->dailyAt('09:30'); // $schedule->command('inspire') // ->hourly(); @@ -135,18 +136,22 @@ class Kernel extends ConsoleKernel // })->everyMinute(); })->dailyAt('05:00'); $schedule->call(function () { - $nvshenService = new NewNvshenService(); - $nvshenService->scrapeNvshenGirls(); + if (App::environment() == "local") { + $nvshenService = new NewNvshenService(); + $nvshenService->scrapeNvshenGirls(); + } // })->cron("0 */3 * * *"); })->dailyAt('05:00'); $schedule->call(function () { - $tuji = new TujiguService(); - $tuji->scrapeTujiguGirls(); + if (App::environment() == "local") { + $tuji = new TujiguService(); + $tuji->scrapeTujiguGirls(); + } // })->cron("30 */3 * * *"); })->dailyAt('04:00'); $schedule->call(function () { - $dailySignService = new DailySignService(); - $dailySignService->signClubHmoe(); +// $dailySignService = new DailySignService(); +// $dailySignService->signClubHmoe(); })->dailyAt('04:00'); diff --git a/app/Services/BilibiliServiceV2.php b/app/Services/BilibiliServiceV2.php index 7e88d83..23a3151 100644 --- a/app/Services/BilibiliServiceV2.php +++ b/app/Services/BilibiliServiceV2.php @@ -10,6 +10,7 @@ use App\BilibiliVideos; use Exception; use GuzzleHttp\Client; use Illuminate\Support\Arr; +use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Log; @@ -26,6 +27,8 @@ class BilibiliServiceV2 private $baseDir = "/Volumes/intel660p/video/mv/"; + private $remoteDir = "/data"; + public function queryPlayList() { $pageNo = 1; @@ -238,6 +241,7 @@ class BilibiliServiceV2 public function compareAndDownloadUpVideos($isAll = false) { + $env = App::environment(); $list = BilibiliUpVideos::all(); // $list = array_slice($list->all(), 15, 5); foreach ($list as $item) { @@ -262,20 +266,25 @@ class BilibiliServiceV2 $videoPartsMap[$vItem["aid"]] = $vItem["total_parts"]; echo "当前 up名称是: " . $item["up_name"] . " 当前下载的视频 title: " . $vItem["title"] . " 当前下载的视频 aid 是:" . $vItem["aid"] . "\n" ; Log::info("当前 up名称是: " . $item["up_name"] . " 当前下载的视频 title: " . $vItem["title"] . " 当前下载的视频 aid 是:" . $vItem["aid"]); - $result = false; - if ($item['mid'] == 27174777) { - $result = $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/", "女团"); - } else if ($item["mid"] == 391316322) { - $result = $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/", "娜娜"); - } else if ($item["mid"] == 396501206) { - $result = $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/", "佳佳"); + if ($env == "local") { + $result = false; + if ($item['mid'] == 27174777) { + $result = $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/", "女团"); + } else if ($item["mid"] == 391316322) { + $result = $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/", "娜娜"); + } else if ($item["mid"] == 396501206) { + $result = $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/", "佳佳"); + } else { + $result = $this->partDownloadBSitePlaylist($videoPartsMap, $this->baseDir . "bilibili/", $item['up_name']); + } + if ($result) { + $vItem["is_downloaded"] = 1; + $vItem->save(); + } } else { - $result = $this->partDownloadBSitePlaylist($videoPartsMap, $this->baseDir . "bilibili/", $item['up_name']); - } - if ($result) { - $vItem["is_downloaded"] = 1; - $vItem->save(); + $this->partDownloadBSitePlaylist($videoPartsMap, $this->remoteDir . "bilibili/", $item["up_name"]); } + } } } @@ -284,6 +293,7 @@ class BilibiliServiceV2 public function compareAndDownloadCollectionVideos($isAll = false) { + $env = App::environment(); $list = BilibiliCollections::all(); foreach ($list as $item) { dump("收藏夹名称是: " . $item["title"] . "\n"); @@ -309,22 +319,30 @@ class BilibiliServiceV2 $videoPartsMap[$vItem["aid"]] = $vItem["total_parts"]; echo "收藏夹名称是: " . $item["title"] . " 当前下载的视频 title: " . $vItem["title"] . " 当前下载的视频 aid 是:" . $vItem["aid"] . "\n" ; Log::info("收藏夹名称是: " . $item["title"] . " 当前下载的视频 title: " . $vItem["title"] . " 当前下载的视频 aid 是:" . $vItem["aid"]); - if ($item['title'] == "默认收藏夹") { - dump("xxxxxxxxxxxx----------------"); - $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/", "bilibili"); - } else if ($item['title'] == '少女时代') { - $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/少女时代", ""); - } else if ($item['title'] == 'aoa') { - $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/aoa", ""); - } else if ($item['title'] == 'blackpink') { - $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/blackpink", ""); - } else if ($item['title'] == 'wjsn') { - $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/wjsn", ""); + if ($env == "local") { + $result = false; + if ($item['title'] == "默认收藏夹") { + dump("xxxxxxxxxxxx----------------"); + $result = $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/", "bilibili"); + } else if ($item['title'] == '少女时代') { + $result = $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/少女时代", ""); + } else if ($item['title'] == 'aoa') { + $result = $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/aoa", ""); + } else if ($item['title'] == 'blackpink') { + $result = $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/blackpink", ""); + } else if ($item['title'] == 'wjsn') { + $result = $this->partDownloadBSitePlaylist($videoPartsMap, "/Volumes/WD/tmp/bilibili/wjsn", ""); + } else { + $result = $this->partDownloadBSitePlaylist($videoPartsMap, $this->baseDir . "bilibili/", $item['title']); + } + if ($result) { + $vItem["is_downloaded"] = 1; + $vItem->save(); + } } else { - $this->partDownloadBSitePlaylist($videoPartsMap, $this->baseDir . "bilibili/", $item['title']); + $this->partDownloadBSitePlaylist($videoPartsMap, $this->remoteDir . "bilibili", $item["title"]); } - $vItem["is_downloaded"] = 1; - $vItem->save(); + } } } @@ -867,6 +885,7 @@ class BilibiliServiceV2 */ public function partDownloadBSitePlaylist($aidMap, $dir = "/Volumes/intel660p/video/mv/mp4", $subDir) { + $env = App::environment(); $dirExists = is_dir($dir); dump($dirExists); if ($dirExists) { @@ -880,11 +899,19 @@ class BilibiliServiceV2 foreach ($aidMap as $aid => $parts) { dump($aid); Log::info("current download command is : cd '{$innerDir}' && annie -r https://www.bilibili.com/video/av80815149 -p " . $aid); - $downloadResult = shell_exec('export http_proxy=http://127.0.0.1:1087; export https_proxy=http://127.0.0.1:1087; cd "' .$innerDir .'" && url="https://www.bilibili.com/video/av' . $aid . '?p=" + if ($env == "local") { + $downloadResult = shell_exec('export http_proxy=http://127.0.0.1:1087; export https_proxy=http://127.0.0.1:1087; cd "' . $innerDir . '" && url="https://www.bilibili.com/video/av' . $aid . '?p=" for i in $(seq 1 ' . $parts . ') do annie -f 64 $url$i -done && echo "ok"' ); +done && echo "ok"'); + } else { + $downloadResult = shell_exec('cd "' . $innerDir . '" && url="https://www.bilibili.com/video/av' . $aid . '?p=" +for i in $(seq 1 ' . $parts . ') +do +annie -c "SESSDATA=216ce1c5%2C1636429756%2Cb86c3%2A51;" $url$i +done && echo "ok"'); + } Log::info($downloadResult); Log::info("$aid current download result: " . $downloadResult); try {