Browse Source

modify some code

feature/for_windows_video_compress_sxs20200923
shixuesen 5 years ago
parent
commit
a85436c475
10 changed files with 220 additions and 58 deletions
  1. +45
    -0
      app/Console/Commands/DailySignCommand.php
  2. +1
    -0
      app/Console/Commands/FullSiteCommand.php
  3. +1
    -1
      app/Console/Commands/RenameTest.php
  4. +7
    -0
      app/Console/Commands/TujiguCommand.php
  5. +5
    -0
      app/Console/Kernel.php
  6. +46
    -0
      app/Services/DailySignService.php
  7. +31
    -6
      app/Services/FullSiteService.php
  8. +19
    -14
      app/Services/HandBrakeService.php
  9. +15
    -2
      app/Services/NewNvshenService.php
  10. +50
    -35
      app/Services/TujiguService.php

+ 45
- 0
app/Console/Commands/DailySignCommand.php View File

@ -0,0 +1,45 @@
<?php
namespace App\Console\Commands;
use App\Services\DailySignService;
use Illuminate\Console\Command;
class DailySignCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'daily:hmoe';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$service = new DailySignService();
$service->signClubHmoe();
//
}
}

+ 1
- 0
app/Console/Commands/FullSiteCommand.php View File

@ -39,6 +39,7 @@ class FullSiteCommand extends Command
public function handle() public function handle()
{ {
$service = new FullSiteService(); $service = new FullSiteService();
// $service->replaceImagePath();exit;
$service->fullSiteDownloadImage(); $service->fullSiteDownloadImage();
// //
} }


+ 1
- 1
app/Console/Commands/RenameTest.php View File

@ -40,7 +40,7 @@ class RenameTest extends Command
{ {
// //
$rename = new RenameService(); $rename = new RenameService();
$rename->rename("/Users/shixuesen/Documents/tmp/秀人旗下《YouWu尤物馆》套图及视频写真-TLoB/套图/");
$rename->rename("/Users/shixuesen/Documents/tmp/福利姬 软软趴在床单上-铃木美咲(Misaki Suzuki) 合集-TLoB/");
// $rename->rename(); // $rename->rename();
// $rename->mvFiles("/Users/shixuesen/Documents/tmp/秀人旗下《MFStar模范学院》套图及视频写真-TLoB/视频/"); // $rename->mvFiles("/Users/shixuesen/Documents/tmp/秀人旗下《MFStar模范学院》套图及视频写真-TLoB/视频/");
} }


+ 7
- 0
app/Console/Commands/TujiguCommand.php View File

@ -39,6 +39,13 @@ class TujiguCommand extends Command
public function handle() public function handle()
{ {
// //
// $titleStr = "杨晨晨/玛鲁娜/许诺Sabrina/兜豆靓《海边众女神美臀福利》 [爱蜜社IMISS] Vol.150 写真集";
// $titleStr = preg_replace("#/#", "-", $titleStr);
// echo $titleStr;exit;
// $albumUrl = "https://www.tujigu.com/a/8401/";
// $albumCode = explode("/", $albumUrl)[4];
// echo $albumCode;exit;
$service = new TujiguService(); $service = new TujiguService();
$service->scrapeTujiguGirls(); $service->scrapeTujiguGirls();
} }


+ 5
- 0
app/Console/Kernel.php View File

@ -4,6 +4,7 @@ namespace App\Console;
use App\Services\BilibiliService; use App\Services\BilibiliService;
use App\Services\CompressImageService; use App\Services\CompressImageService;
use App\Services\DailySignService;
use App\Services\NewXiuGirlsService; use App\Services\NewXiuGirlsService;
use App\Services\XiuGirlsService; use App\Services\XiuGirlsService;
use App\Services\VitabioticsService; use App\Services\VitabioticsService;
@ -124,6 +125,10 @@ class Kernel extends ConsoleKernel
$xiuService->scrapeXiuGirls(); $xiuService->scrapeXiuGirls();
// })->everyMinute(); // })->everyMinute();
})->dailyAt('05:00'); })->dailyAt('05:00');
$schedule->call(function () {
$dailySignService = new DailySignService();
$dailySignService->signClubHmoe();
})->dailyAt('04:00');


+ 46
- 0
app/Services/DailySignService.php View File

@ -0,0 +1,46 @@
<?php
namespace App\Services;
class DailySignService
{
public function signClubHmoe()
{
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://club.hmoe.club/wp-json/b2/v1/userMission",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => array(
"authority: club.hmoe.club",
"content-length: 0",
"pragma: no-cache",
"cache-control: no-cache",
"accept: application/json, text/plain, */*",
"authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczpcL1wvY2x1Yi5obW9lLmNsdWIiLCJpYXQiOjE2MDAxNTUyNzcsIm5iZiI6MTYwMDE1NTI3NywiZXhwIjoxNjAwNzYwMDc3LCJkYXRhIjp7InVzZXIiOnsiaWQiOiIzODI5NyJ9fX0.eCpbJ-qqYQuS-n04Z-7nUz0C1G06TVdYaZwAHI4dMMo",
"user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36",
"origin: https://club.hmoe.club",
"sec-fetch-site: same-origin",
"sec-fetch-mode: cors",
"sec-fetch-dest: empty",
"referer: https://club.hmoe.club/",
"accept-language: zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6,ja;q=0.5",
"cookie: PHPSESSID=s5j99cdcp99a2go41mq3c3f6hm; wordpress_logged_in_eb096bd0935f7dd6358a62cbe85a51c3=user38297_694%7C1601364877%7CJMM25vh5jDz4ZO21TWW0xm4vJhaNwR8Hhi06USiyEwz%7C9678dbb8017d50d1b20006500c21ee03bec9bc580756c2bc326bc645e14e4222"
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
}
}

+ 31
- 6
app/Services/FullSiteService.php View File

@ -7,8 +7,10 @@ class FullSiteService {
public function fullSiteDownloadImage() public function fullSiteDownloadImage()
{ {
$dir = "/Volumes/WD/tmp/site/mm24.cc/beautyleg/";
$dir = "/Volumes/WD/tmp/site/mm24.cc/simu/";
$files = scandir($dir); $files = scandir($dir);
dump("total files count is " . count($files));
// $files = array_slice($files, 38300);
$ql = QueryList::getInstance(); $ql = QueryList::getInstance();
$i = 0; $i = 0;
foreach ($files as $file) { foreach ($files as $file) {
@ -19,10 +21,10 @@ class FullSiteService {
if ($file == "." || $file == ".." || $file == ".DS_Store") { if ($file == "." || $file == ".." || $file == ".DS_Store") {
continue; continue;
} }
$htmlNum = substr($file, 0, 4);
if ((int)$htmlNum < 1072) {
continue;
}
// $htmlNum = substr($file, 0, 4);
// if ((int)$htmlNum < 3776) {
// continue;
// }
if (str_contains($file, "html")) { if (str_contains($file, "html")) {
dump($file); dump($file);
$ql = $ql->html(file_get_contents($dir. "/" . $file)); $ql = $ql->html(file_get_contents($dir. "/" . $file));
@ -50,10 +52,33 @@ class FullSiteService {
continue; continue;
} }
file_put_contents($dir . "../" . $path . "/" .$filePathInfo["basename"], $content); file_put_contents($dir . "../" . $path . "/" .$filePathInfo["basename"], $content);
usleep(1000 * random_int(1000, 10000));
usleep(100 * random_int(1000, 10000));
} }
// dump($rt);exit; // dump($rt);exit;
} }
} }
} }
public function replaceImagePath()
{
$dir = "/Volumes/WD/tmp/site/mm24.cc/beautyleg/";
// $files = scandir($dir);
// dump("total files count is " . count($files));
// foreach ($files as $file) {
// if ($file == "." || $file == ".." || $file == ".DS_Store") {
// continue;
// }
// dump($file);
// file_put_contents($dir . $file, str_replace("http://img.huangguogan.net", "..", file_get_contents($dir . $file)));
// exit;
// }
for ($i = 1; $i <= 46; $i++) {
if ($i == 1) {
$file = "4063.html";
} else {
$file = "4063_" . $i . ".html";
}
file_put_contents($dir . $file, str_replace("http://img.huangguogan.net", "..", file_get_contents($dir . $file)));
}
}
} }

+ 19
- 14
app/Services/HandBrakeService.php View File

@ -6,7 +6,7 @@ namespace App\Services;
class HandBrakeService class HandBrakeService
{ {
public function handleVideos($dir = "/Users/shixuesen/Documents/tmp/秀人旗下《YouWu尤物馆》套图及视频写真-TLoB/")
public function handleVideos($dir = "/Users/shixuesen/Documents/tmp/福利姬 软软趴在床单上-铃木美咲(Misaki Suzuki) 合集-TLoB/")
{ {
$files = scandir($dir); $files = scandir($dir);
foreach ($files as $file) { foreach ($files as $file) {
@ -22,21 +22,26 @@ class HandBrakeService
if (is_dir($subPathFile) || $subFile == ".DS_Store") { if (is_dir($subPathFile) || $subFile == ".DS_Store") {
continue; continue;
} }
if (is_file($subPathFile)) {
$fileInfo = pathinfo($subPathFile);
dump("fileInfo", $fileInfo);
if (ends_with($fileInfo["filename"], "-1")) {
continue;
}
if (is_file($fileInfo["dirname"] . '/' .$fileInfo["filename"] . '-1'. '.' . $fileInfo["extension"])) {
continue;
}
$targetFile = $fileInfo["dirname"] . '/' .$fileInfo["filename"] . '-1'. '.' . $fileInfo["extension"];
dump("targetFile", [$targetFile]);
$mime = mime_content_type($subPathFile);
// dump("file type", [$mime, $subPathFile]);
// continue;
if (strstr($mime, "video/")) {
if (is_file($subPathFile)) {
$fileInfo = pathinfo($subPathFile);
dump("fileInfo", $fileInfo);
if (ends_with($fileInfo["filename"], "-1")) {
continue;
}
if (is_file($fileInfo["dirname"] . '/' .$fileInfo["filename"] . '-1'. '.' . $fileInfo["extension"])) {
continue;
}
$targetFile = $fileInfo["dirname"] . '/' .$fileInfo["filename"] . '-1'. '.' . $fileInfo["extension"];
dump("targetFile", [$targetFile]);
// $result = shell_exec("handBrakeCli -Z 'Very Fast 720p30' -i '". $subPathFile ."' -o '". $targetFile . " && echo 'success'"); // $result = shell_exec("handBrakeCli -Z 'Very Fast 720p30' -i '". $subPathFile ."' -o '". $targetFile . " && echo 'success'");
$result = shell_exec("handBrakeCli -Z 'Very Fast 720p30' -i '". $subPathFile ."' -o '". $targetFile . "'");
dump($result);
$result = shell_exec("handBrakeCli -Z 'Very Fast 720p30' -i '". $subPathFile ."' -o '". $targetFile . "'");
dump($result);
}
} }
} }
} }


+ 15
- 2
app/Services/NewNvshenService.php View File

@ -144,6 +144,7 @@ class NewNvshenService
$baseAlbumUrl = "https://www.nvshens.net/girl/{$name['code']}/album/"; $baseAlbumUrl = "https://www.nvshens.net/girl/{$name['code']}/album/";
for ($i = 1; $i <= $totalAlbumPage; $i++) { for ($i = 1; $i <= $totalAlbumPage; $i++) {
dump("current album page no: " . $i);
if ($onlyOnePage) { if ($onlyOnePage) {
$albumQl = $mainQl->get($peopleUrl); $albumQl = $mainQl->get($peopleUrl);
} else { } else {
@ -161,8 +162,20 @@ class NewNvshenService
usleep(10000 * random_int(1000, 10000)); usleep(10000 * random_int(1000, 10000));
dump("相册:", [$album]); dump("相册:", [$album]);
// $pageQL = $qL0->get($baseUrl . $album); // $pageQL = $qL0->get($baseUrl . $album);
$page = $mainQl->get($baseUrl . $album, [], ['maxTry' => 5])->find(".albumInfo > span")->htmls();
$title = $mainQl->get($baseUrl . $album, [], ['maxTry' => 5])->find(".albumTitle > #htilte")->htmls();
for ($m = 0; $m < 100; $m++) {
try {
$page = $mainQl->get($baseUrl . $album, [], ['maxTry' => 5])->find(".albumInfo > span")->htmls();
$title = $mainQl->get($baseUrl . $album, [], ['maxTry' => 5])->find(".albumTitle > #htilte")->htmls();
break;
} catch (ConnectException $e) {
echo 'connection error: ' . $e->getMessage() . "\n";
echo "retry times: " . $m . " times \n";
sleep(1);
$sleepTime = 1000 * random_int(1000, 10000);
echo "retry sleep {$sleepTime} nano second \n";
usleep($sleepTime);
}
}
dump($title->all()); dump($title->all());
$titleStr = $title->all()[0]; $titleStr = $title->all()[0];
preg_match("#\d+#", $page->all()[0], $result); preg_match("#\d+#", $page->all()[0], $result);


+ 50
- 35
app/Services/TujiguService.php View File

@ -12,70 +12,77 @@ class TujiguService
private static $name_dir = [ private static $name_dir = [
// "周韦彤" => [ // "周韦彤" => [
// "dir" => "周韦彤", // "dir" => "周韦彤",
// "code" => 16274,
// "code" => 1456,
// "name" => "周韦彤" // "name" => "周韦彤"
// ], // ],
// "ycc" => [ // "ycc" => [
// "dir" => "ycc", // "dir" => "ycc",
// "code" => 22162,
// "code" => 459,
// "name" => "杨晨晨" // "name" => "杨晨晨"
// ], // ],
// "ry" => [ // "ry" => [
// "dir" => "忍野さら", // "dir" => "忍野さら",
// "code" => "21250",
// "code" => "1875",
// "name" => "忍野さら" // "name" => "忍野さら"
// ], // ],
// "azu" => [ // "azu" => [
// "dir" => "azu", // "dir" => "azu",
// "code" => 26002,
// "code" => 437,
// "name" => "阿朱" // "name" => "阿朱"
// ], // ],
// "xq" => [ // "xq" => [
// "dir" => "xq", // "dir" => "xq",
// "code" => 22204,
// "code" => 2438,
// "name" => "小琪" // "name" => "小琪"
// ], // ],
// "ygh" => [ // "ygh" => [
// "dir" => "ygh", // "dir" => "ygh",
// "code" => 15902,
// "code" => 550,
// "name" => "原干惠" // "name" => "原干惠"
// ], // ],
// "wyc" => [ // "wyc" => [
// "dir" => "wyc", // "dir" => "wyc",
// "code" => 19702,
// "code" => 293,
// "name" => "王语纯" // "name" => "王语纯"
// ], // ],
// "zz" => [
// "dir" => "zz",
// "code" => 22899,
// "name" => "芝芝 booty"
// ],
// "hlr" => [
// "dir" => "hlr",
// "code" => 20015,
// "name" => "黄乐然"
// ],
"zz" => [
"dir" => "zz",
"code" => 954,
"name" => "芝芝 booty"
],
"hlr" => [
"dir" => "hlr",
"code" => 1289,
"name" => "黄乐然"
],
"jrq" => [ "jrq" => [
"dir" => "jrq", "dir" => "jrq",
"code" => 5034, "code" => 5034,
"name" => "姜仁卿" "name" => "姜仁卿"
], ],
// "ny" => [
// "dir" => "ny",
// "code" => 26298,
// "name" => "奈月"
// ],
// "杉本有美" => [
// "dir" => "杉本有美",
// "code" => 15939,
// "name" => "杉本有美"
// ]
"ny" => [
"dir" => "ny",
"code" => 5301,
"name" => "奈月"
],
"杉本有美" => [
"dir" => "杉本有美",
"code" => 632,
"name" => "杉本有美"
],
"糯美子" => [
"dir" => "糯美子",
"code" => 161,
"name" => "糯美子"
]
]; ];
public function scrapeTujiguGirls() public function scrapeTujiguGirls()
{ {
foreach (self::$name_dir as $username => $name) { foreach (self::$name_dir as $username => $name) {
// 重置下这个 map,不同网站,不同人可能会有相册 id 重复的情况
$albumCodeMap = [];
// $baseDir = "/Users/shixuesen/Documents/tmp/image/xg/" . $name['dir'] . "/"; // $baseDir = "/Users/shixuesen/Documents/tmp/image/xg/" . $name['dir'] . "/";
$baseDir = "/Volumes/intel660p/image/xg/" . $name["dir"] . "/"; $baseDir = "/Volumes/intel660p/image/xg/" . $name["dir"] . "/";
// 处理两个网站对应图册名不一致,直接取图册 id 作为唯一性判断的 map // 处理两个网站对应图册名不一致,直接取图册 id 作为唯一性判断的 map
@ -115,28 +122,36 @@ class TujiguService
$totalAlbumPage = ceil($totalAlbumNum / 40); $totalAlbumPage = ceil($totalAlbumNum / 40);
} }
$baseAlbumUrl = "https://www.tujigu.com/t/{$name['code']}/"; $baseAlbumUrl = "https://www.tujigu.com/t/{$name['code']}/";
for ($i = 1; $i <= $totalAlbumPage; $i++) {
if ($onlyOnePage || $totalAlbumPage == 1) {
for ($i = 1; $i < $totalAlbumPage; $i++) {
if ($onlyOnePage || $totalAlbumPage == 1 || $i == 0) {
$albumQl = QueryList::get($peopleUrl); $albumQl = QueryList::get($peopleUrl);
} else { } else {
$albumQl = QueryList::get($baseAlbumUrl . $i . ".html");
$albumQl = QueryList::get($baseAlbumUrl . "index_".$i . ".html");
} }
// dump($albumQl->getHtml()); // dump($albumQl->getHtml());
$albumList = $albumQl->find("body > div.hezi > ul > li > a")->attrs("href"); $albumList = $albumQl->find("body > div.hezi > ul > li > a")->attrs("href");
$pageAlbum = $albumList->all(); $pageAlbum = $albumList->all();
dump($pageAlbum); dump($pageAlbum);
foreach ($pageAlbum as $album) { foreach ($pageAlbum as $album) {
usleep(1000 * random_int(1000, 10000));
dump("current album page no: " . $i);
usleep(10000 * random_int(1000, 10000));
dump("相册:", [$album]); dump("相册:", [$album]);
$pageQL = QueryList::get( $album); $pageQL = QueryList::get( $album);
$page = $pageQL->find("body > div.tuji > p:nth-child(6)")->htmls();
$page = $pageQL->find("body > div.tuji > p:nth-child(5)")->htmls();
$pageAlternative = $pageQL->find("body > div.tuji > p:nth-child(6)")->htmls();
$title = $pageQL->find("body > div.tuji > div.weizhi > h1")->htmls(); $title = $pageQL->find("body > div.tuji > div.weizhi > h1")->htmls();
dump($title->all()); dump($title->all());
$titleStr = $title->all()[0]; $titleStr = $title->all()[0];
preg_match("#\d+#", $page->all()[0], $result);
$totalImageNum = $result[0];
$titleStr = preg_replace("#/#", "-", $titleStr);
preg_match("#图片数量: (\d+)P#", $page->all()[0], $result);
if (count($result) < 2) {
preg_match("#图片数量: (\d+)P#", $pageAlternative->all()[0], $result);
}
$totalImageNum = $result[1];
for ($j = 1; $j <= $totalImageNum; $j++) { for ($j = 1; $j <= $totalImageNum; $j++) {
$albumCode = substr($album, 25, 5);
// $albumCode = substr($album, 25, 5);
$albumCode = explode("/", $album)[4];
$baseImageUrl = "https://lns.hywly.com/a/1/{$albumCode}/"; $baseImageUrl = "https://lns.hywly.com/a/1/{$albumCode}/";
// if ($j == 0) { // if ($j == 0) {
// $imageName = $j . ".jpg"; // $imageName = $j . ".jpg";


Loading…
Cancel
Save