Browse Source

add log for trace

feature/new_bilibili_and_instagram_sxs20191126
shixuesen 4 years ago
parent
commit
4d9ba86a43
3 changed files with 100 additions and 3 deletions
  1. +45
    -0
      app/Console/Commands/XiaomiDate.php
  2. +7
    -3
      app/Services/FfmpegService.php
  3. +48
    -0
      app/Services/XiaomiDataService.php

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

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

+ 7
- 3
app/Services/FfmpegService.php View File

@ -111,7 +111,7 @@ class FfmpegService
if (filemtime($pathFile) > strtotime("2021-07-26 00:00:00")) {
$mtime = date("Y-m-d H:i:s", filemtime($pathFile));
dump("$pathFile modify at $mtime is after 2021-07-26 00:00:00 skip");
return;
// return;
} else {
$mtime = date("Y-m-d H:i:s", filemtime($pathFile));
dump("$pathFile modify at $mtime is before 2021-07-19 00:00:00");
@ -133,19 +133,23 @@ class FfmpegService
return;
}
dump("targetFile", [$targetFile]);
$result = shell_exec("ffmpeg -threads 4 -i '". $pathFile ."' -c:v libx265 -vtag hvc1 '" . $targetFile . "' && echo 'ok'");
Log::info("process target file : $targetFile");
$result = shell_exec("ffmpeg -threads 3 -i '". $pathFile ."' -c:v libx265 -vtag hvc1 '" . $targetFile . "' && echo 'ok'");
echo $result;
if (trim($result) == "ok") {
echo "compress work done remove the file \n";
Log::info("compress work done remove the file");
$oldFileSize = filesize($pathFile);
$newFileSize = filesize($targetFile);
if ($newFileSize >= $oldFileSize) {
Redis::sadd("unneed", $fileInfo["filename"]);
echo "old file size is smaller than new one, old is " . file_size($oldFileSize) . " and new is " . file_size($newFileSize) . ", now remove new one";
Log::info("old file size is smaller than new one, old is " . file_size($oldFileSize) . " and new is " . file_size($newFileSize) . ", now remove new one");
unlink($targetFile);
} else {
Redis::sadd("unneed", $fileInfo["filename"]);
echo "new file size is smaller than old one, new is " . file_size($newFileSize) . " and old is " . file_size($oldFileSize) . ", now remove old one";
Log::info("new file size is smaller than old one, new is " . file_size($newFileSize) . " and old is " . file_size($oldFileSize) . ", now remove old one");
unlink($pathFile);
rename($targetFile, $pathFile);
}
@ -239,7 +243,7 @@ class FfmpegService
return true;
}
$fileSize = FileUtils::humanFilesize(filesize($file));
echo "$file size < 200Mb filesize is $fileSize skip \n";
echo "$file size < 100Mb filesize is $fileSize skip \n";
return false;
}


+ 48
- 0
app/Services/XiaomiDataService.php View File

@ -0,0 +1,48 @@
<?php
namespace App\Services;
class XiaomiDataService
{
public function fetchData()
{
# code...
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api-mifit-cn2.huami.com/users/1003389185/members/-1/weightRecords?r=AAF4B906-DC99-4026-A146-978ACE0CABE0&t=1627438226827&limit=100&toTime=1627438226',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Host: api-mifit-cn2.huami.com',
'country: CN',
'v: 2.0',
'hm-privacy-ceip: true',
'accept: */*',
'appname: com.xiaomi.hm.health',
'channel: appstore',
'apptoken: NQVBQFJyQktGHlp6QkpbRl5LRl5qek4uXAQABAAAAAMd7RkoNu16RKYjOLDC7AN1jtFMyJHKQgy70qG8fHyLhWQM3BDpraOjD3ROnQ9dk_QLCN6Pk4XQ0rrzrvVJSIFqopGscLK86H0PjUisykFjAkKQ8q4H00ZvNRNit8CaG70Gs0oVB9Q-Dn8HC_EBhxMWzjGUwCgkO4BJnvjO5B2NC',
'accept-language: zh-Hans-CN;q=1, en-CN;q=0.9',
'x-request-id: 49EACAE1-63FB-4035-BF1E-CCED0579FD14',
'cv: 159_5.2.0',
'lang: zh_CN',
'timezone: Asia/Shanghai',
'appplatform: ios_phone',
'hm-privacy-diagnostics: false',
'user-agent: MiFit/5.2.0 (iPhone; iOS 14.7; Scale/3.00)'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
}
}

Loading…
Cancel
Save