Browse Source

add some code

feature/for_windows_video_compress_sxs20200923
shixuesen 5 years ago
parent
commit
94b5e88d66
12 changed files with 562 additions and 33 deletions
  1. +7
    -3
      app/Console/Commands/BiliVideoCode.php
  2. +45
    -0
      app/Console/Commands/FullSiteCommand.php
  3. +45
    -0
      app/Console/Commands/HandBrakeCommand.php
  4. +1
    -1
      app/Console/Commands/RenameTest.php
  5. +45
    -0
      app/Console/Commands/TujiguCommand.php
  6. +55
    -10
      app/Services/BilibiliService.php
  7. +59
    -0
      app/Services/FullSiteService.php
  8. +47
    -0
      app/Services/HandBrakeService.php
  9. +6
    -2
      app/Services/InstagramService.php
  10. +35
    -17
      app/Services/NewNvshenService.php
  11. +209
    -0
      app/Services/TujiguService.php
  12. +8
    -0
      fail.log

+ 7
- 3
app/Console/Commands/BiliVideoCode.php View File

@ -42,16 +42,20 @@ class BiliVideoCode extends Command
// dump($this->arguments());exit; // dump($this->arguments());exit;
// //
$bilibili = new BilibiliService(); $bilibili = new BilibiliService();
// $bilibili->queryLocalUpVideoList();exit;
// $bilibili->insertDBTest();exit; // $bilibili->insertDBTest();exit;
// $bilibili->queryPlayList(); // $bilibili->queryPlayList();
// $bilibili->queryUpVideoList(10278125);
$bilibili->queryUpVideoList(10278125);
$bilibili->queryDBCollectionList();
$bilibili->queryForVideoParts();
$bilibili->compareAndDownloadUpVideos(); $bilibili->compareAndDownloadUpVideos();
// $bilibili->queryDBCollectionList();
$bilibili->compareAndDownloadCollectionVideos(); $bilibili->compareAndDownloadCollectionVideos();
// $bilibili->queryCollectionList(); // $bilibili->queryCollectionList();
// $bilibili->compareAndDownloadNewVideos(); // $bilibili->compareAndDownloadNewVideos();
// $bilibili->queryLocalUpVideoList(); // $bilibili->queryLocalUpVideoList();
$bilibili->queryForVideoParts();
// $bilibili->queryForVideoParts();
// $bilibili->queryDBCollectionList(); // $bilibili->queryDBCollectionList();
$bilibili->checkVideoHasDownload(); $bilibili->checkVideoHasDownload();
// echo is_dir("/Volumes/Seagate Backup Plus Drive/Video/bilibili/少女时代"); // echo is_dir("/Volumes/Seagate Backup Plus Drive/Video/bilibili/少女时代");


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

@ -0,0 +1,45 @@
<?php
namespace App\Console\Commands;
use App\Services\FullSiteService;
use Illuminate\Console\Command;
class FullSiteCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'full:get';
/**
* 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 FullSiteService();
$service->fullSiteDownloadImage();
//
}
}

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

@ -0,0 +1,45 @@
<?php
namespace App\Console\Commands;
use App\Services\HandBrakeService;
use Illuminate\Console\Command;
class HandBrakeCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'handle:video';
/**
* 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 HandBrakeService();
$service->handleVideos();
}
}

+ 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/美媛馆/");
$rename->rename("/Users/shixuesen/Documents/tmp/秀人旗下《YouWu尤物馆》套图及视频写真-TLoB/套图/");
// $rename->rename(); // $rename->rename();
// $rename->mvFiles("/Users/shixuesen/Documents/tmp/秀人旗下《MFStar模范学院》套图及视频写真-TLoB/视频/"); // $rename->mvFiles("/Users/shixuesen/Documents/tmp/秀人旗下《MFStar模范学院》套图及视频写真-TLoB/视频/");
} }


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

@ -0,0 +1,45 @@
<?php
namespace App\Console\Commands;
use App\Services\TujiguService;
use Illuminate\Console\Command;
class TujiguCommand extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'tujigu:s';
/**
* 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 TujiguService();
$service->scrapeTujiguGirls();
}
}

+ 55
- 10
app/Services/BilibiliService.php View File

@ -161,6 +161,7 @@ class BilibiliService
// $list = BilibiliUpVideos::all(); // $list = BilibiliUpVideos::all();
$list = []; $list = [];
$up = ["mid" => 391073761, "up_name" => "女团直拍"]; $up = ["mid" => 391073761, "up_name" => "女团直拍"];
$up = ["mid" => 254624554, "up_name" => "女团能量站"];
$list[] = $up; $list[] = $up;
foreach ($list as $item) { foreach ($list as $item) {
Log::info("schedule queryUpVideoList current up is {$item['up_name']}, started at: " . date("Y-m-d H:i:s")); Log::info("schedule queryUpVideoList current up is {$item['up_name']}, started at: " . date("Y-m-d H:i:s"));
@ -245,13 +246,16 @@ class BilibiliService
if (count($vItems) > 0) { if (count($vItems) > 0) {
foreach ($vItems as $vItem) { foreach ($vItems as $vItem) {
if ($vItem["is_download"] == 1 && $vItem["is_downloaded"] == 0) { if ($vItem["is_download"] == 1 && $vItem["is_downloaded"] == 0) {
$videoList[] = "av" . $value;
// $videoList[] = "av" . $value;
$videoList = [];
$videoList[$value] = $vItem->total_parts;
$this->partDownloadBSitePlaylist($videoList, $this->baseDir . "bilibili/", $item['up_name']);
} }
} }
} }
// $videoList[] = "av" . $value; // $videoList[] = "av" . $value;
} }
$this->downloadBSitePlaylist($videoList, $this->baseDir . "bilibili/", $item['up_name']);
// $this->downloadBSitePlaylist($videoList, $this->baseDir . "bilibili/", $item['up_name']);
} }
} }
@ -278,18 +282,28 @@ class BilibiliService
foreach ($vItems as $vItem) { foreach ($vItems as $vItem) {
if ($vItem["is_download"] == 1 && $vItem["is_downloaded"] == 0) { if ($vItem["is_download"] == 1 && $vItem["is_downloaded"] == 0) {
$videoList[] = "av" . $value; $videoList[] = "av" . $value;
$videoMap = [];
$videoMap[$value] = $vItem->total_parts;
if ($item['title'] == "默认收藏夹") {
dump("xxxxxxxxxxxx----------------");
$this->partDownloadBSitePlaylist($videoMap, $this->baseDir, "bilibili");
} else if ($item['title'] == '少女时代') {
$this->partDownloadBSitePlaylist($videoMap, "/Volumes/WD/tmp/bilibili/少女时代", "");
} else {
$this->partDownloadBSitePlaylist($videoMap, $this->baseDir . "bilibili/", $item['title']);
}
} }
} }
} }
} }
if ($item['title'] == "默认收藏夹") {
dump("xxxxxxxxxxxx----------------");
$this->downloadBSitePlaylist($videoList, $this->baseDir, "bilibili");
} else if ($item['title'] == '少女时代') {
$this->downloadBSitePlaylist($videoList, "/Volumes/Seagate Backup Plus Drive/Video/bilibili/少女时代", "");
} else {
$this->downloadBSitePlaylist($videoList, $this->baseDir . "bilibili/", $item['title']);
}
// if ($item['title'] == "默认收藏夹") {
// dump("xxxxxxxxxxxx----------------");
// $this->downloadBSitePlaylist($videoList, $this->baseDir, "bilibili");
// } else if ($item['title'] == '少女时代') {
// $this->downloadBSitePlaylist($videoList, "/Volumes/Seagate Backup Plus Drive/Video/bilibili/少女时代", "");
// } else {
// $this->downloadBSitePlaylist($videoList, $this->baseDir . "bilibili/", $item['title']);
// }
} }
} }
@ -737,6 +751,37 @@ class BilibiliService
} }
} }
public function partDownloadBSitePlaylist($aidMap, $dir = "/Volumes/intel660p/video/mv/mp4", $subDir)
{
dump("partDownloadBSitePlaylist");
dump($aidMap);
dump($dir);
$dirExists = is_dir($dir);
dump($dirExists);
if ($dirExists) {
$innerDir = $dir . "/" . $subDir;
dump($innerDir);
if (!is_dir($innerDir)) {
mkdir($innerDir);
}
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('cd "' .$innerDir .'" && url="https://www.bilibili.com/video/av' . $aid . '?p="
for i in $(seq 1 ' . $parts . ')
do
annie -c "SESSDATA=622d365f%2C1611483669%2C8c222*71" $url$i
done ' );
Log::info($downloadResult);
Log::info("current download result: " . $downloadResult);
try {
usleep(random_int(1000, 10000) * 1000);
} catch (\Exception $e) {
}
}
}
}
public function deleteFileNotContainP() public function deleteFileNotContainP()
{ {
$dir = "/Volumes/intel660p/video/mv/mp4"; $dir = "/Volumes/intel660p/video/mv/mp4";


+ 59
- 0
app/Services/FullSiteService.php View File

@ -0,0 +1,59 @@
<?php
namespace App\Services;
use Log;
use QL\QueryList;
class FullSiteService {
public function fullSiteDownloadImage()
{
$dir = "/Volumes/WD/tmp/site/mm24.cc/beautyleg/";
$files = scandir($dir);
$ql = QueryList::getInstance();
$i = 0;
foreach ($files as $file) {
$i++;
if ($i % 100 == 0) {
dump("current counter i is ". $i . "\n");
}
if ($file == "." || $file == ".." || $file == ".DS_Store") {
continue;
}
$htmlNum = substr($file, 0, 4);
if ((int)$htmlNum < 1072) {
continue;
}
if (str_contains($file, "html")) {
dump($file);
$ql = $ql->html(file_get_contents($dir. "/" . $file));
$rt = $ql->find('img')->attrs('src');
dump($rt);
foreach ($rt as $r) {
$filePathInfo = pathinfo($r);
// 获取相对路径
$path = parse_url($filePathInfo['dirname'])['path'];
if (str_contains($path, "..")) {
$localFilePath = $dir . $path . "/";
} else {
$localFilePath = $dir . "../" . $path . "/";
}
if (is_file($localFilePath . $filePathInfo["basename"])) {
continue;
}
if (!is_dir($localFilePath)) {
mkdir($localFilePath, 0777, true);
}
try {
$content = file_get_contents($r);
} catch (\Exception $e) {
Log::error("current url is " . $r . " trace: " . $e->getTraceAsString());
continue;
}
file_put_contents($dir . "../" . $path . "/" .$filePathInfo["basename"], $content);
usleep(1000 * random_int(1000, 10000));
}
// dump($rt);exit;
}
}
}
}

+ 47
- 0
app/Services/HandBrakeService.php View File

@ -0,0 +1,47 @@
<?php
namespace App\Services;
class HandBrakeService
{
public function handleVideos($dir = "/Users/shixuesen/Documents/tmp/秀人旗下《YouWu尤物馆》套图及视频写真-TLoB/")
{
$files = scandir($dir);
foreach ($files as $file) {
if ($file == "." || $file == "..") {
continue;
}
$subDir = implode("/", [$dir, $file]);
$isDir = is_dir($subDir);
if ($isDir) {
$subFiles = scandir($subDir);
foreach ($subFiles as $subFile) {
$subPathFile = implode("/", [$subDir, $subFile]);
if (is_dir($subPathFile) || $subFile == ".DS_Store") {
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]);
// $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);
}
}
}
}
print_r($files);
}
}

+ 6
- 2
app/Services/InstagramService.php View File

@ -314,9 +314,13 @@ class InstagramService
} catch (\Exception $e) { } catch (\Exception $e) {
// if ($e instanceof UserNotFou) // if ($e instanceof UserNotFou)
Log::error("ins get user id for name error: " . $e->getMessage() . " username is " . $userName); Log::error("ins get user id for name error: " . $e->getMessage() . " username is " . $userName);
if (array_key_exists(trim($userName), $userList)) {
$userId = null;
if (array_key_exists(trim($userName), $this->userList)) {
$userId = Arr::get($userList, trim($userName)); $userId = Arr::get($userList, trim($userName));
} }
if ($userId == null) {
continue;
}
// continue; // continue;
} }
echo "\n username: " . $trueName . " " . $userId . "\n"; echo "\n username: " . $trueName . " " . $userId . "\n";
@ -479,7 +483,7 @@ class InstagramService
exit(0); exit(0);
} }
dump($ig->people->getInfoById('1577496884'));exit;
dump($ig->people->getInfoById('17865689564'));exit;
$response = $ig->user->getUserFeed('6794713533', null); $response = $ig->user->getUserFeed('6794713533', null);
// $response = $ig->story->getUserReelMediaFeed('12801506409'); // $response = $ig->story->getUserReelMediaFeed('12801506409');
dump($response);exit; dump($response);exit;


+ 35
- 17
app/Services/NewNvshenService.php View File

@ -4,6 +4,7 @@
namespace App\Services; namespace App\Services;
use GuzzleHttp\Exception\ConnectException;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use QL\QueryList; use QL\QueryList;
use Illuminate\Http\File; use Illuminate\Http\File;
@ -18,16 +19,16 @@ class NewNvshenService
// "code" => 16274, // "code" => 16274,
// "name" => "周韦彤" // "name" => "周韦彤"
// ], // ],
"ycc" => [
"dir" => "ycc",
"code" => 22162,
"name" => "杨晨晨"
],
"ry" => [
"dir" => "忍野さら",
"code" => "21250",
"name" => "忍野さら"
],
// "ycc" => [
// "dir" => "ycc",
// "code" => 22162,
// "name" => "杨晨晨"
// ],
// "ry" => [
// "dir" => "忍野さら",
// "code" => "21250",
// "name" => "忍野さら"
// ],
"azu" => [ "azu" => [
"dir" => "azu", "dir" => "azu",
"code" => 26002, "code" => 26002,
@ -86,7 +87,7 @@ class NewNvshenService
// 26560 姜仁卿 // 26560 姜仁卿
$NUM_OF_ATTEMPTS = 50; $NUM_OF_ATTEMPTS = 50;
$mainQl = QueryList::getInstance();
foreach (self::$name_dir as $username => $name) { foreach (self::$name_dir as $username => $name) {
// $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"] . "/";
@ -107,9 +108,23 @@ class NewNvshenService
$peopleUrl = "https://www.nvshens.net/girl/"; $peopleUrl = "https://www.nvshens.net/girl/";
$peopleUrl .= $name['code']; $peopleUrl .= $name['code'];
// 获取总的相册数量 // 获取总的相册数量
$albumNumSelector = ".archive_more > a"; $albumNumSelector = ".archive_more > a";
$baseQl = QueryList::get($peopleUrl);
for ($i = 0; $i < 100; $i++) {
try {
$baseQl =$mainQl->get($peopleUrl,[], ['maxTry' => 5]);
break;
} catch (ConnectException $e) {
echo 'connection error: ' . $e->getMessage() . "\n";
echo "retry times: " . $i . " times \n";
sleep(1);
$sleepTime = 1000 * random_int(1000, 10000);
echo "retry sleep {$sleepTime} nano second \n";
usleep($sleepTime);
}
}
$ql = $baseQl->find($albumNumSelector)->htmls(); $ql = $baseQl->find($albumNumSelector)->htmls();
$onlyOnePage = false; $onlyOnePage = false;
// 相册页数 // 相册页数
@ -130,21 +145,24 @@ 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++) {
if ($onlyOnePage) { if ($onlyOnePage) {
$albumQl = QueryList::get($peopleUrl);
$albumQl = $mainQl->get($peopleUrl);
} else { } else {
$albumQl = QueryList::get($baseAlbumUrl . $i . ".html");
$albumQl = $mainQl->get($baseAlbumUrl . $i . ".html");
} }
// dump($albumQl->getHtml()); // dump($albumQl->getHtml());
$albumList = $albumQl->find(".igalleryli > .igalleryli_div > .igalleryli_link")->attrs("href"); $albumList = $albumQl->find(".igalleryli > .igalleryli_div > .igalleryli_link")->attrs("href");
$pageAlbum = $albumList->all(); $pageAlbum = $albumList->all();
// if ($i == 4) {
// $pageAlbum = array_slice($pageAlbum, 1);
// }
// $pageAlbum = array_slice($pageAlbum, 19); // $pageAlbum = array_slice($pageAlbum, 19);
// dump($pageAlbum);exit; // dump($pageAlbum);exit;
foreach ($pageAlbum as $album) { foreach ($pageAlbum as $album) {
usleep(10000 * random_int(1000, 10000)); usleep(10000 * random_int(1000, 10000));
dump("相册:", [$album]); dump("相册:", [$album]);
$pageQL = QueryList::get($baseUrl . $album);
$page = $pageQL->find(".albumInfo > span")->htmls();
$title = $pageQL->find(".albumTitle > #htilte")->htmls();
// $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();
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);


+ 209
- 0
app/Services/TujiguService.php View File

@ -0,0 +1,209 @@
<?php
namespace App\Services;
use QL\QueryList;
class TujiguService
{
private static $name_dir = [
// "周韦彤" => [
// "dir" => "周韦彤",
// "code" => 16274,
// "name" => "周韦彤"
// ],
// "ycc" => [
// "dir" => "ycc",
// "code" => 22162,
// "name" => "杨晨晨"
// ],
// "ry" => [
// "dir" => "忍野さら",
// "code" => "21250",
// "name" => "忍野さら"
// ],
// "azu" => [
// "dir" => "azu",
// "code" => 26002,
// "name" => "阿朱"
// ],
// "xq" => [
// "dir" => "xq",
// "code" => 22204,
// "name" => "小琪"
// ],
// "ygh" => [
// "dir" => "ygh",
// "code" => 15902,
// "name" => "原干惠"
// ],
// "wyc" => [
// "dir" => "wyc",
// "code" => 19702,
// "name" => "王语纯"
// ],
// "zz" => [
// "dir" => "zz",
// "code" => 22899,
// "name" => "芝芝 booty"
// ],
// "hlr" => [
// "dir" => "hlr",
// "code" => 20015,
// "name" => "黄乐然"
// ],
"jrq" => [
"dir" => "jrq",
"code" => 5034,
"name" => "姜仁卿"
],
// "ny" => [
// "dir" => "ny",
// "code" => 26298,
// "name" => "奈月"
// ],
// "杉本有美" => [
// "dir" => "杉本有美",
// "code" => 15939,
// "name" => "杉本有美"
// ]
];
public function scrapeTujiguGirls()
{
foreach (self::$name_dir as $username => $name) {
// $baseDir = "/Users/shixuesen/Documents/tmp/image/xg/" . $name['dir'] . "/";
$baseDir = "/Volumes/intel660p/image/xg/" . $name["dir"] . "/";
// 处理两个网站对应图册名不一致,直接取图册 id 作为唯一性判断的 map
if (is_dir($baseDir)) {
$albumDirList = scandir($baseDir);
foreach ($albumDirList as $albumDir) {
if ($albumDir == "." || $albumDir == "..") {
continue;
}
if (is_dir($baseDir . $albumDir) && is_numeric(explode("-", $albumDir)[0])) {
$albumCodeMap[explode("-", $albumDir)[0]] = $albumDir;
}
}
}
$baseUrl = "https://www.tujigu.com/";
// usleep(random_int(1000, 10000) * 1000);
$peopleUrl = "https://www.tujigu.com/t/";
$peopleUrl .= $name['code'];
// 获取总的相册数量
$albumNumSelector = "body > div:nth-child(4) > span";
$baseQl = QueryList::get($peopleUrl);
$ql = $baseQl->find($albumNumSelector)->htmls();
dump($ql->all());
$onlyOnePage = false;
// 相册页数
if (count($ql->all()) == 0) {
// 不超过 1 页时,不显示数量
$totalAlbumPage = 1;
$onlyOnePage = true;
} else {
preg_match("#\d+#", $ql->all()[0], $result);
dump($result);
$totalAlbumNum = 0;
if (is_numeric($result[0])) {
$totalAlbumNum = $result[0];
}
$totalAlbumPage = ceil($totalAlbumNum / 40);
}
$baseAlbumUrl = "https://www.tujigu.com/t/{$name['code']}/";
for ($i = 1; $i <= $totalAlbumPage; $i++) {
if ($onlyOnePage || $totalAlbumPage == 1) {
$albumQl = QueryList::get($peopleUrl);
} else {
$albumQl = QueryList::get($baseAlbumUrl . $i . ".html");
}
// dump($albumQl->getHtml());
$albumList = $albumQl->find("body > div.hezi > ul > li > a")->attrs("href");
$pageAlbum = $albumList->all();
dump($pageAlbum);
foreach ($pageAlbum as $album) {
usleep(1000 * random_int(1000, 10000));
dump("相册:", [$album]);
$pageQL = QueryList::get( $album);
$page = $pageQL->find("body > div.tuji > p:nth-child(6)")->htmls();
$title = $pageQL->find("body > div.tuji > div.weizhi > h1")->htmls();
dump($title->all());
$titleStr = $title->all()[0];
preg_match("#\d+#", $page->all()[0], $result);
$totalImageNum = $result[0];
for ($j = 1; $j <= $totalImageNum; $j++) {
$albumCode = substr($album, 25, 5);
$baseImageUrl = "https://lns.hywly.com/a/1/{$albumCode}/";
// if ($j == 0) {
// $imageName = $j . ".jpg";
// } else {
// $suffix = str_pad($j, 3, "0", STR_PAD_LEFT);
// $imageName = $suffix . ".jpg";
// }
$imageName = $j . ".jpg";
$imageUrl = $baseImageUrl . $imageName;
// if ($j == 0) {
// $imageName = "000.jpg";
// }
$imageName = $username . "-" . $albumCode . "-" . $imageName;
$albumPath = "";
if (!file_exists($baseDir . $albumCode . "-" . $titleStr) && !array_key_exists($albumCode, $albumCodeMap)) {
dump($baseDir . $albumCode . "-" . $titleStr);
mkdir($baseDir . $albumCode . "-" . $titleStr);
}
if (array_key_exists($albumCode, $albumCodeMap)) {
$albumPath = $baseDir . $albumCodeMap[$albumCode];
} else {
$albumPath = $baseDir . $albumCode . "-" . $titleStr;
}
if (file_exists($albumPath . "/" . $imageName)) {
dump($albumPath . "/" . $imageName . " exists. skipped!");
continue;
}
$opts = array('http' => ['header' =>
"User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36 \r\n
Referer:" . $baseUrl . "\r\n"
]);
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $imageUrl);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2000);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.109 Safari/537.36');
curl_setopt($curl_handle, CURLOPT_REFERER, $baseUrl);
$query = curl_exec($curl_handle);
$i = 1;
while ($query === false) {
echo 'Curl error: ' . curl_error($curl_handle) . "\n";
echo "retry times: " . $i++ . " times \n";
sleep(1);
$sleepTime = 1000 * random_int(1000, 10000);
echo "retry sleep {$sleepTime} nano second \n";
usleep($sleepTime);
$query = curl_exec($curl_handle);
if ($i >= 100) {
break;
}
}
echo curl_error($curl_handle);
$fp = fopen($albumPath . "/" . $imageName, 'x');
fwrite($fp, $query);
fclose($fp);
$sleepTime = 1000 * random_int(100, 1000);
echo "after write image sleep {$sleepTime} nano second \n";
usleep($sleepTime);
echo $imageUrl;
}
dump($page->all());
// exit;
}
}
}
}
}

+ 8
- 0
fail.log View File

@ -692,3 +692,11 @@
/Users/shixuesen/OneDrive/Pictures/instagram/aiiiiidj/ https://scontent-lax3-1.cdninstagram.com/v/t72.14836-16/77139885_290930192172637_5198370042565630198_n.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5zdG9yeS5kZWZhdWx0In0&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=101&_nc_ohc=wmikFSyYN28AX9V8q6X&vs=17872087717860866_3916825148&_nc_vs=HBkcFQAYJEdLMFBtUVJkUnNKMm1RZ0JBUFlZS1BZQ1VpUklidlE1QUFBRhUAAsgBACgAGAAbAYgHdXNlX29pbAExFQAAGAAWhPzFnrGkvz8VAigCQzMsF0AhEOVgQYk3GBJkYXNoX2Jhc2VsaW5lXzFfdjERAHXoBwA%3D&_nc_rid=378d8d9536&oe=5F2987E0&oh=707ffd2b27f74740eebf5d8be5179924 /Users/shixuesen/OneDrive/Pictures/instagram/aiiiiidj/ https://scontent-lax3-1.cdninstagram.com/v/t72.14836-16/77139885_290930192172637_5198370042565630198_n.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5zdG9yeS5kZWZhdWx0In0&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=101&_nc_ohc=wmikFSyYN28AX9V8q6X&vs=17872087717860866_3916825148&_nc_vs=HBkcFQAYJEdLMFBtUVJkUnNKMm1RZ0JBUFlZS1BZQ1VpUklidlE1QUFBRhUAAsgBACgAGAAbAYgHdXNlX29pbAExFQAAGAAWhPzFnrGkvz8VAigCQzMsF0AhEOVgQYk3GBJkYXNoX2Jhc2VsaW5lXzFfdjERAHXoBwA%3D&_nc_rid=378d8d9536&oe=5F2987E0&oh=707ffd2b27f74740eebf5d8be5179924
/Users/shixuesen/OneDrive/Pictures/instagram/cr5p__br/ https://scontent-lax3-1.cdninstagram.com/v/t51.2885-15/e35/65846982_2546776852023965_7033037719418202124_n.jpg?_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=105&_nc_ohc=ccgXr2Nq_kcAX87-ZDq&se=7&_nc_tp=18&oh=8f902ba42b072cbc47ff0b82c3d59d6d&oe=5F4FF775&ig_cache_key=MjA3NzU2OTEzMDMwMjk0NjM1OQ%3D%3D.2 /Users/shixuesen/OneDrive/Pictures/instagram/cr5p__br/ https://scontent-lax3-1.cdninstagram.com/v/t51.2885-15/e35/65846982_2546776852023965_7033037719418202124_n.jpg?_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=105&_nc_ohc=ccgXr2Nq_kcAX87-ZDq&se=7&_nc_tp=18&oh=8f902ba42b072cbc47ff0b82c3d59d6d&oe=5F4FF775&ig_cache_key=MjA3NzU2OTEzMDMwMjk0NjM1OQ%3D%3D.2
/Users/shixuesen/OneDrive/Pictures/instagram/cr5p__br/ https://scontent-lax3-1.cdninstagram.com/v/t51.2885-15/e35/65261358_158339078634649_6944565250026032091_n.jpg?_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=101&_nc_ohc=JkgWNO119mMAX_laiB1&se=7&_nc_tp=18&oh=35b9c98fde729f8004231164d3a5ce43&oe=5F51D694&ig_cache_key=MjA3NzU2OTEzMDMxOTgzNzczOQ%3D%3D.2 /Users/shixuesen/OneDrive/Pictures/instagram/cr5p__br/ https://scontent-lax3-1.cdninstagram.com/v/t51.2885-15/e35/65261358_158339078634649_6944565250026032091_n.jpg?_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=101&_nc_ohc=JkgWNO119mMAX_laiB1&se=7&_nc_tp=18&oh=35b9c98fde729f8004231164d3a5ce43&oe=5F51D694&ig_cache_key=MjA3NzU2OTEzMDMxOTgzNzczOQ%3D%3D.2
/Users/shixuesen/OneDrive/Pictures/instagram/linda.zz99tw/ https://scontent-lax3-1.cdninstagram.com/v/t51.2885-15/e35/117646763_1179198095773954_6807439955666719206_n.jpg?_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=110&_nc_ohc=kGEGBq2RgPgAX-VqrIf&se=7&oh=d9a78a811feef90970b466a1e0ecc27c&oe=5F65BB3E&ig_cache_key=MjM3ODQxOTk1NDA3Nzk2NDQ0Mg%3D%3D.2
/Users/shixuesen/OneDrive/Pictures/instagram/janie.lin/ https://scontent-lax3-1.cdninstagram.com/v/t72.14836-16/77201205_673847993213496_7774010421176351117_n.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5zdG9yeS5kZWZhdWx0In0&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=100&_nc_ohc=j8Q1yPppePkAX8BKtNF&vs=17846186702320598_1948532587&_nc_vs=HBkcFQAYJEdEWC1tUVE0b2tSMjNHUUNBSTI1WmlKSzFlSnJidlE1QUFBRhUAAsgBACgAGAAbAYgHdXNlX29pbAExFQAAGAAWrPfzmOTAsz8VAigCQzMsF0AUAAAAAAAAGBJkYXNoX2Jhc2VsaW5lXzFfdjERAHXoBwA%3D&_nc_rid=7833ea2152&oe=5F3E61AB&oh=ace3fac81a0c5e8875a4f2a2222854a2
/Users/shixuesen/OneDrive/Pictures/instagram/ngoctrinh89/ https://scontent-lax3-1.cdninstagram.com/v/t72.14836-16/75535324_587513715261099_7404070956589526058_n.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5zdG9yeS5kZWZhdWx0In0&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=1&_nc_ohc=6xmjrKw-Fq4AX-15vQ6&vs=17868893092940531_2513393285&_nc_vs=HBksFQAYJEdOeVRnQVNyZmt3eVZ4WUNBQ29zVG50T2k4Qm1idlE1QUFBRhUAAsgBABUAGCRHTjMya2dRNU55QU1jZ0lKQUZMMTBGMjBuNnM0YnZRNUFBQUYVAgLIAQAoABgAGwGIB3VzZV9vaWwBMRUAABgAFuaq%2Ft676r0%2FFQIoAkMzLBdALgAAAAAAABgSZGFzaF9iYXNlbGluZV8xX3YxEQB16AcA&_nc_rid=c32bab5330&oe=5F3E2B95&oh=82f4eac144674f9b56c00131993b4809
/Users/shixuesen/OneDrive/Pictures/instagram/sabrina888888_/ https://scontent-lax3-1.cdninstagram.com/v/t72.14836-16/76925155_140832457719453_9180412409707727222_n.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5zdG9yeS5kZWZhdWx0In0&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=109&_nc_ohc=Lxbr0BRUR9EAX8JeYln&vs=17974291876311381_2513308505&_nc_vs=HBksFQAYJEdPUElsUVNkZnAwY0ZvQUFBSGFKTjF4eVlHZC1idlE1QUFBRhUAAsgBABUAGCRHTTlHaFFRaV9mc09WaEFCQUJFTjg5RUlKSVY3YnZRNUFBQUYVAgLIAQAoABgAGwGIB3VzZV9vaWwBMRUAABgAFqqNy7O94e0%2FFQIoAkMzLBdAEkOVgQYk3RgSZGFzaF9iYXNlbGluZV8xX3YxEQB16AcA&_nc_rid=58005d3d5a&oe=5F3E764C&oh=14859f2ecacc58a64a734f36b356e210
/Users/shixuesen/OneDrive/Pictures/instagram/yui_xin_/ https://scontent-lax3-1.cdninstagram.com/v/t72.14836-16/75428600_755924618501504_2048311050821646003_n.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5zdG9yeS5kZWZhdWx0In0&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=108&_nc_ohc=pQiDuq6K7cEAX-hVOB9&vs=17869884913906512_108280769&_nc_vs=HBksFQAYJEdQanlmZ1NBM1Z4cWdxOENBTE0ydTEwTUVHMGNidlE1QUFBRhUAAsgBABUAGCRHTFR2bWdRa1A4Tm1QcXNGQU0xYkhDYndpbUFhYnZRNUFBQUYVAgLIAQAoABgAGwGIB3VzZV9vaWwBMRUAABgAFqDz9eOYpL4%2FFQIoAkMzLBdALgAAAAAAABgSZGFzaF9iYXNlbGluZV8xX3YxEQB16AcA&_nc_rid=90c810f24d&oe=5F3DFA88&oh=31a5b50ab41a32b699da846892417bc4
/Users/shixuesen/OneDrive/Pictures/instagram/m.hakase/ https://scontent-lax3-1.cdninstagram.com/v/t50.2886-16/118218403_846812562516988_3111523094919873920_n.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5mZWVkLmRlZmF1bHQifQ&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=104&_nc_ohc=oE8BA1n3dI8AX-E40QL&vs=17870934580897073_264014687&_nc_vs=HBksFQAYJEdLUGVDd2Y4Ni1ycEt3SURBSUNGSF8tRVdTNHJia1lMQUFBRhUAAsgBABUAGCRHSGV2QndjRndZZDNSVm9DQUR1SnN0dWdhc2tzYmtZTEFBQUYVAgLIAQAoABgAGwGIB3VzZV9vaWwBMBUAABgAFuLQ0pWm4b4%2FFQIoAkMzLBdAPGZmZmZmZhgSZGFzaF9iYXNlbGluZV8xX3YxEQB16gcA&_nc_rid=9e0c1d31bf&oe=5F44858B&oh=9c3bdb7eb60b397508ba81be10c59dc9
/Users/shixuesen/OneDrive/Pictures/instagram/sharalinmusic/ https://scontent-lax3-1.cdninstagram.com/v/t72.14836-16/76567757_779704676109049_7483955894682146113_n.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5zdG9yeS5kZWZhdWx0In0&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=101&_nc_ohc=tSgcczQk7P8AX-yiFpM&vs=18067696816226248_2424269083&_nc_vs=HBkcFQAYJEdNMVVrQVQ1eWo4a0k4VUNBRUZWT0FrOFd0eG5idlE1QUFBRhUAAsgBACgAGAAbAYgHdXNlX29pbAExFQAAGAAWkM%2B8%2FK6emEAVAigCQzMsF0AYAAAAAAAAGBJkYXNoX2Jhc2VsaW5lXzFfdjERAHXoBwA%3D&_nc_rid=2edcaee0e9&oe=5F44CC3D&oh=e5bb5c1a35be47e9d1847e9610da3415
/Users/shixuesen/OneDrive/Pictures/instagram/loveruby_official/ https://scontent-lax3-1.cdninstagram.com/v/t72.14836-16/77049927_114165790266740_2661896184818341417_n.mp4?efg=eyJ2ZW5jb2RlX3RhZyI6InZ0c192b2RfdXJsZ2VuLjcyMC5zdG9yeS5kZWZhdWx0In0&_nc_ht=scontent-lax3-1.cdninstagram.com&_nc_cat=108&_nc_ohc=M38SQT5rCNAAX9YUbnF&vs=17866243067003473_1228086245&_nc_vs=HBkcFQAYJEdFZXdsd1IwMVY5TDFXY0FBQ21XRUExNjlQQWtidlE1QUFBRhUAAsgBACgAGAAbAYgHdXNlX29pbAExFQAAGAAWorHk4JvQvD8VAigCQzMsF0AUAAAAAAAAGBJkYXNoX2Jhc2VsaW5lXzFfdjERAHXoBwA%3D&_nc_rid=7918e60731&oe=5F489B5F&oh=a0e2ff8ccf9cb8a1c11bd999064c15c0

Loading…
Cancel
Save