1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace App\Console\Commands;
- use App\Log;
- use App\Models\Material;
- use App\Service\MaterialService;
- use App\Support\EmailQueue;
- use Illuminate\Console\Command;
- use PharIo\Manifest\Email;
- class AutoUploadMaterialToDouYin extends Command
- {
- /**
- * The name and signature of the console command.
- *
- * @var string
- */
- protected $signature = 'AutoUploadMaterialToDouYin';
- /**
- * The console command description.
- *
- * @var string
- */
- protected $description = '定时上传素材到抖音';
- public function handle()
- {
- \DB::connection()->disableQueryLog();
- $this->info(date('m-d H:i:s') . ' 开始整理');
- try{
- # 查询待同步的素材列表
- $materialList = Material::getUnUploadMaterialList();
- if($materialList->isEmpty()) {
- return false;
- }
- # 上传视频到抖音
- foreach($materialList as $materialInfo) {
- MaterialService::uploadMaterialToDouYin($materialInfo->id, $materialInfo->app_id, $materialInfo->resource_type
- , $materialInfo->oss_url, $materialInfo->title, $materialInfo->desc);
- }
- } catch (\Exception $exception) {
- Log::logError('定时上传素材到抖音程序异常', [
- 'file' => $exception->getFile(),
- 'line' => $exception->getLine(),
- 'msg' => $exception->getMessage(),
- 'trace' => $exception->getTraceAsString()
- ], 'autoUploadMaterialToDouYin-exception');
- EmailQueue::rPush('定时上传素材到抖音程序异常', $exception->getFile().'('.$exception->getLine().')'
- .':'.$exception->getMessage(),['song.shen@kuxuan-inc.com'], '抖音短剧');
- }
- $this->info(date('m-d H:i:s') . ' 整理结束');
- }
- }
|