PushVideo.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. namespace app\command;
  3. use app\model\star\StarTaskUser;
  4. use app\model\star\StarTaskVideo;
  5. use Symfony\Component\Console\Command\Command;
  6. use Symfony\Component\Console\Input\InputInterface;
  7. use Symfony\Component\Console\Output\OutputInterface;
  8. use yzh52521\EasyHttp\Http;
  9. class PushVideo extends Command
  10. {
  11. protected static string $defaultName = 'push:video';
  12. protected static string $defaultDescription = '星川任务';
  13. protected function execute(InputInterface $input, OutputInterface $output): int
  14. {
  15. try {
  16. $nextPage = 1;
  17. $done = 0;
  18. while (is_numeric($nextPage)) {
  19. $resp = (new StarTaskVideo)->page($nextPage,10)->select();
  20. if ($resp->isEmpty()) {
  21. $output->writeln("没有任务啦==".getDateFull());
  22. $nextPage = null;
  23. return true;
  24. }
  25. foreach ($resp as $key=>$val) {
  26. $resp = Http::asJson()->post("https://api.jiandaoyun.com/api/v1/automation/tenant/69dc899f71c9656940c3db33/hooks/69e07cb9d9016a4ba4737e880bb32ba47135f8c4f8799955",$val->toArray())->array();
  27. if ($resp['code'] <> 0) {
  28. $output->writeln("{$val['video_id']} == 推送数据失败==".getDateFull());
  29. } else {
  30. $output->writeln("{$val['video_id']} == 推送成功==".getDateFull());
  31. }
  32. }
  33. $nextPage = $nextPage+1;
  34. $output->writeln("进入下一页=={$nextPage}==".getDateFull());
  35. }
  36. } catch (\Throwable $throwable) {
  37. echo getDateFull()."==报错啦===".$throwable->getFile()."\n";
  38. echo getDateFull()."==报错啦===".$throwable->getLine()."\n";
  39. echo getDateFull()."==报错啦===".$throwable->getMessage()."\n";
  40. }
  41. return true;
  42. }
  43. }