From 4d9ba86a432d7f49a0f208467dcdb5fc0b4313c1 Mon Sep 17 00:00:00 2001 From: shixuesen Date: Tue, 3 Aug 2021 09:56:55 +0800 Subject: [PATCH] add log for trace --- app/Console/Commands/XiaomiDate.php | 45 +++++++++++++++++++++++++++ app/Services/FfmpegService.php | 10 ++++-- app/Services/XiaomiDataService.php | 48 +++++++++++++++++++++++++++++ 3 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 app/Console/Commands/XiaomiDate.php create mode 100644 app/Services/XiaomiDataService.php diff --git a/app/Console/Commands/XiaomiDate.php b/app/Console/Commands/XiaomiDate.php new file mode 100644 index 0000000..d3fc64b --- /dev/null +++ b/app/Console/Commands/XiaomiDate.php @@ -0,0 +1,45 @@ +fetchData(); + } +} diff --git a/app/Services/FfmpegService.php b/app/Services/FfmpegService.php index af05580..842e6cf 100644 --- a/app/Services/FfmpegService.php +++ b/app/Services/FfmpegService.php @@ -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; } diff --git a/app/Services/XiaomiDataService.php b/app/Services/XiaomiDataService.php new file mode 100644 index 0000000..66f6dbe --- /dev/null +++ b/app/Services/XiaomiDataService.php @@ -0,0 +1,48 @@ + '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; + } +}