<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\BilibiliVideos;
|
|
use App\Services\CommonScrapeService;
|
|
use App\Services\FfmpegService;
|
|
use App\Services\FileService;
|
|
use App\Utils\FileUtils;
|
|
use Illuminate\Console\Command;
|
|
use Illuminate\Support\Facades\App;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
|
class CommonTest extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'common:test {path} {needDeleteAfterEncode=0} {needDeleteExistFiles=0}';
|
|
|
|
/**
|
|
* 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()
|
|
{
|
|
$fileService = new FileService();
|
|
// $fileService->compareLocalFilesAndGooglePhotoFiles();exit;
|
|
// echo App::environment();exit;
|
|
// $list = BilibiliVideos::where("created_at", ">", "2021-09-09 00:00:00")->get();
|
|
// dump($list[0]->getAttributes());exit;
|
|
date_default_timezone_set('PRC');
|
|
$path = $this->argument("path");
|
|
$service = new FfmpegService();
|
|
$needDeleteAfterEncode = $this->argument("needDeleteAfterEncode");
|
|
if (trim($needDeleteAfterEncode) == "1") {
|
|
$service->setNeedRemoveAfterEncode(true);
|
|
}
|
|
$needDeleteExistFiles = $this->argument("needDeleteExistFiles");
|
|
if (trim($needDeleteExistFiles) == "1") {
|
|
$service->setNeedRemoveExistFiles(true);
|
|
}
|
|
// $service->checkFileEncodeType();exit;
|
|
$service->processDir(trim($path));exit;
|
|
$cache = Cache::driver("redis");
|
|
$cache->tags(["aaa", "bbb"])->put("key1", "value1");
|
|
$cache->put("key2", "value2");
|
|
exit;
|
|
$this->testAnnie();exit;
|
|
$commonScrapeService = new CommonScrapeService();
|
|
$commonScrapeService->scrapeAlbum();exit;
|
|
dump(FileUtils::scanDuplicateDir("/Volumes/intel660p/image/xg/ycc"));exit;
|
|
$fileService = new FileService();
|
|
$fileService->segmentFiles("/Volumes/Samsung/weibo/old_image");
|
|
exit;
|
|
// Redis::set("hello", "123");
|
|
echo Redis::get("fullSet");
|
|
exit;
|
|
|
|
echo mb_strlen("霸气欣欣爷,内地画师,兼职推女神模特,毕业于广州美术学院国画系,自称广州沙画师彩绘师欣儿,一位猫咪爱好%E8");exit;
|
|
setlocale(LC_ALL,array('zh_CN.gbk','zh_CN.gb2312','zh_CN.gb18030'));
|
|
setlocale(LC_ALL, "zh_CN.UTF-8");
|
|
$p1 = pathinfo('D:\\atlas\\这是文件夹\\可爱胖胖是怎么变帅的#超能陆战队.mp4');
|
|
$p2 = pathinfo('D:\\atlas\\dirname\\sssss#ddddd.mp4');
|
|
|
|
print_r($p1);
|
|
print_r($p2);
|
|
//
|
|
}
|
|
|
|
public function testAnnie()
|
|
{
|
|
$result = shell_exec("annie -i av417536178");
|
|
echo $result;
|
|
preg_match_all("#\[(\d+)\]\s+-+\s+Quality:\s+[\S]+\s+720P#", $result, $match);
|
|
dump($match);
|
|
}
|
|
|
|
/**
|
|
* 重命名因 handbrake 编码后自动添加数字的文件
|
|
* @param $path
|
|
* @return bool
|
|
*/
|
|
public function renameHandBrakeRenamedFiles($path) {
|
|
$files = scandir($path);
|
|
foreach ($files as $file) {
|
|
if ($file == "." || $file == "..") {
|
|
continue;
|
|
}
|
|
preg_match_all("/(\s\d+)\.mp4/", $file, $matches);
|
|
if (array_key_exists(1, $matches) && array_key_exists(0, $matches[1])) {
|
|
$newFileName = str_replace($matches[0][0], ".mp4", $file);
|
|
rename($path . "/" . $file, $path . "/" . $newFileName);
|
|
// dump($path . "/" . $newFileName);
|
|
}
|
|
// dump($matches);
|
|
}
|
|
}
|
|
}
|