src/Controller/IndexController.php line 459

Open in your IDE?
  1. <?php
  2. namespace App\Controller;
  3. use App\Entity\AceTv\AceTvBagsMinutes;
  4. use App\Entity\AceTv\AceTvCategory;
  5. use App\Entity\AceTv\AceTvCourtsCameras;
  6. use App\Entity\AceTv\AceTvCredit;
  7. use App\Entity\AceTv\AceTvEnclosures;
  8. use App\Entity\AceTv\AceTvRecordings;
  9. use App\Entity\App\AppUser;
  10. use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
  11. use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
  12. use Symfony\Component\HttpFoundation\JsonResponse;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\Routing\Annotation\Route;
  16. /**
  17.  * @Route("/")
  18.  */
  19. class IndexController extends AbstractController
  20. {
  21.     private $url "https://fast-acetv.cloudbase.cl:5443/LiveApp/";
  22.     public function __construct()
  23.     {
  24.     }
  25.     /**
  26.      * @Route("/", name="index")
  27.      */
  28.     public function index(): Response
  29.     {
  30.         /*
  31.         $curl = curl_init();
  32.         curl_setopt_array($curl, array(
  33.             CURLOPT_URL => "{$this->url}rest/v2/broadcasts/list/0/10",
  34.             CURLOPT_RETURNTRANSFER => true,
  35.             CURLOPT_ENCODING => '',
  36.             CURLOPT_MAXREDIRS => 10,
  37.             CURLOPT_TIMEOUT => 0,
  38.             CURLOPT_FOLLOWLOCATION => true,
  39.             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  40.             CURLOPT_CUSTOMREQUEST => 'GET',
  41.         ));
  42.         $response = curl_exec($curl);
  43.         curl_close($curl);
  44.         $response = json_decode($response,true);
  45.         $listStreaming = [];
  46.         foreach ($response AS $i) {
  47.             if($i['status'] == 'broadcasting'){
  48.                 $listStreaming[] = [
  49.                     'idStreaming' => $i['streamId'],
  50.                     'name' => $i['name']
  51.                 ];
  52.             }
  53.         }*/
  54.         /*
  55.         $curl = curl_init();
  56.         curl_setopt_array($curl, array(
  57.             CURLOPT_URL => "{$this->url}rest/v2/vods/list/0/10",
  58.             CURLOPT_RETURNTRANSFER => true,
  59.             CURLOPT_ENCODING => '',
  60.             CURLOPT_MAXREDIRS => 10,
  61.             CURLOPT_TIMEOUT => 0,
  62.             CURLOPT_FOLLOWLOCATION => true,
  63.             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  64.             CURLOPT_CUSTOMREQUEST => 'GET',
  65.         ));
  66.         $response2 = curl_exec($curl);
  67.         curl_close($curl);
  68.         $response2 = json_decode($response2,true);
  69.         $listVods = [];
  70.         foreach ($response2 AS $i) {
  71.             dump($i);
  72.             $listVods[] = [
  73.                 'idVod' => $i['vodId'],
  74.                 'name' => $i['streamName'],
  75.                 'vodName' => $i['vodName'],
  76.                 'duration' => $i['duration'],
  77.             ];
  78.         }
  79.         */
  80.         $em $this->getDoctrine()->getManager();
  81.         $aceTvCategory $em->getRepository(AceTvCategory::class)->findAll();
  82.         $aceTvCourtsCameras $em->getRepository(AceTvCourtsCameras::class)->findBy(['flagStatus' => true]);
  83.         $cameras = [];
  84.         foreach ($aceTvCourtsCameras as $i) {
  85.             $curl curl_init();
  86.             curl_setopt_array($curl, array(
  87.                 CURLOPT_URL => "https://fast-acetv.cloudbase.cl:5443/LiveApp/rest/v2/broadcasts/{$i->getStreamId()}",
  88.                 CURLOPT_RETURNTRANSFER => true,
  89.                 CURLOPT_ENCODING => '',
  90.                 CURLOPT_MAXREDIRS => 10,
  91.                 CURLOPT_TIMEOUT => 0,
  92.                 CURLOPT_FOLLOWLOCATION => true,
  93.                 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  94.                 CURLOPT_CUSTOMREQUEST => 'GET',
  95.             ));
  96.             $response curl_exec($curl);
  97.             curl_close($curl);
  98.             $resp json_decode($responsetrue);
  99.             dump($resp);
  100.             if(isset($resp['status'])){
  101.                 if($resp['status'] == 'broadcasting') {
  102.                     if(@getimagesize("https://fast-acetv.cloudbase.cl:5443/LiveApp/previews/{$i->getStreamId()}.png")){
  103.                         $image true;
  104.                     } else {
  105.                         $image false;
  106.                     }
  107.                     $cameras[] = [
  108.                         'id' => $i->getId(),
  109.                         'idStreaming' => $i->getStreamId(),
  110.                         'name' => $i->getName(),
  111.                         'image' => $image
  112.                     ];
  113.                 }
  114.             }
  115.         }
  116.         $aceTvRecordings $em->getRepository(AceTvRecordings::class)->findBy(['flagPublic' => true'flagFinish' => true],['id'=>'DESC']);
  117.         $recordings = [];
  118.         foreach ($aceTvRecordings as $i) {
  119.             $diff $i->getDateStart()->diff($i->getDateEnd());
  120.             $duration '';
  121.             if ($diff->0) {
  122.                 $duration .= "{$diff->h} hr: ";
  123.             }
  124.             if ($diff->0) {
  125.                 $duration .= "{$diff->i} mins";
  126.             }
  127.             $recordings[] = [
  128.                 'id' => $i->getId(),
  129.                 'idVod' => $i->getRecordingsId(),
  130.                 'name' => $i->getName(),
  131.                 'image' => $i->getImage(),
  132.                 'realName' => str_replace('.mp4','',$i->getRealName()),
  133.                 'duration' => $duration
  134.             ];
  135.         }
  136.         return $this->render('BaseFrontEnd/index.html.twig', [
  137.             'listStreaming' => $cameras,
  138.             'listVods' => $recordings,
  139.             ###################################
  140.             'aceTvCategory' => $aceTvCategory,
  141.             'menu' => 'index',
  142.         ]);
  143.     }
  144.     /**
  145.      * @Route("/clubs/{id}", name="index_clubs")
  146.      */
  147.     public function clubs(AceTvEnclosures $aceTvEnclosures): Response
  148.     {
  149.         $em $this->getDoctrine()->getManager();
  150.         $aceTvCategory $em->getRepository(AceTvCategory::class)->findByAceTvEnclosures($aceTvEnclosures->getId());
  151.         $aceTvCourtsCameras $em->getRepository(AceTvCourtsCameras::class)->findBy(['flagStatus' => true'aceTvEnclosures' => $aceTvEnclosures]);
  152.         $cameras = [];
  153.         foreach ($aceTvCourtsCameras as $i) {
  154.             $curl curl_init();
  155.             curl_setopt_array($curl, array(
  156.                 CURLOPT_URL => "https://fast-acetv.cloudbase.cl:5443/LiveApp/rest/v2/broadcasts/{$i->getStreamId()}",
  157.                 CURLOPT_RETURNTRANSFER => true,
  158.                 CURLOPT_ENCODING => '',
  159.                 CURLOPT_MAXREDIRS => 10,
  160.                 CURLOPT_TIMEOUT => 0,
  161.                 CURLOPT_FOLLOWLOCATION => true,
  162.                 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  163.                 CURLOPT_CUSTOMREQUEST => 'GET',
  164.             ));
  165.             $response curl_exec($curl);
  166.             curl_close($curl);
  167.             $resp json_decode($responsetrue);
  168.             if(isset($resp['status'])) {
  169.                 if ($resp['status'] == 'broadcasting') {
  170.                     if (@getimagesize("https://fast-acetv.cloudbase.cl:5443/LiveApp/previews/{$i->getStreamId()}.png")) {
  171.                         $image true;
  172.                     } else {
  173.                         $image false;
  174.                     }
  175.                     $cameras[] = [
  176.                         'id' => $i->getId(),
  177.                         'idStreaming' => $i->getStreamId(),
  178.                         'name' => $i->getName(),
  179.                         'image' => $image
  180.                     ];
  181.                 }
  182.             }
  183.         }
  184.         $aceTvRecordings $em->getRepository(AceTvRecordings::class)->findByAceTvEnclosures($aceTvEnclosures->getId());
  185.         $recordings = [];
  186.         foreach ($aceTvRecordings as $i) {
  187.             $diff $i->getDateStart()->diff($i->getDateEnd());
  188.             $duration '';
  189.             if ($diff->0) {
  190.                 $duration .= "{$diff->h} hr: ";
  191.             }
  192.             if ($diff->0) {
  193.                 $duration .= "{$diff->i} mins";
  194.             }
  195.             $recordings[] = [
  196.                 'id' => $i->getId(),
  197.                 'idVod' => $i->getRecordingsId(),
  198.                 'name' => $i->getName(),
  199.                 'image' => $i->getImage(),
  200.                 'realName' => str_replace('.mp4','',$i->getRealName()),
  201.                 'duration' => $duration
  202.             ];
  203.         }
  204.         return $this->render('BaseFrontEnd/clubs.html.twig', [
  205.             'listStreaming' => $cameras,
  206.             'listVods' => $recordings,
  207.             'aceTvEnclosures' => $aceTvEnclosures,
  208.             ###################################
  209.             'aceTvCategory' => $aceTvCategory,
  210.             'menu' => 'clubs',
  211.         ]);
  212.     }
  213.     /**
  214.      * @Route("/category/{id}/{idClubs}", defaults={"idClubs": null}, name="index_category")
  215.      */
  216.     public function category(AceTvCategory $aceTvCategory$idClubs): Response
  217.     {
  218.         $em $this->getDoctrine()->getManager();
  219.         $aceTvCourtsCameras $em->getRepository(AceTvCourtsCameras::class)->findByAceTvCategory($aceTvCategory->getId(),$idClubs);
  220.         $cameras = [];
  221.         foreach ($aceTvCourtsCameras as $i) {
  222.             $curl curl_init();
  223.             curl_setopt_array($curl, array(
  224.                 CURLOPT_URL => "https://fast-acetv.cloudbase.cl:5443/LiveApp/rest/v2/broadcasts/{$i->getStreamId()}",
  225.                 CURLOPT_RETURNTRANSFER => true,
  226.                 CURLOPT_ENCODING => '',
  227.                 CURLOPT_MAXREDIRS => 10,
  228.                 CURLOPT_TIMEOUT => 0,
  229.                 CURLOPT_FOLLOWLOCATION => true,
  230.                 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  231.                 CURLOPT_CUSTOMREQUEST => 'GET',
  232.             ));
  233.             $response curl_exec($curl);
  234.             curl_close($curl);
  235.             $resp json_decode($responsetrue);
  236.             if(isset($resp['status'])) {
  237.                 if ($resp['status'] == 'broadcasting') {
  238.                     if (@getimagesize("https://fast-acetv.cloudbase.cl:5443/LiveApp/previews/{$i->getStreamId()}.png")) {
  239.                         $image true;
  240.                     } else {
  241.                         $image false;
  242.                     }
  243.                     $cameras[] = [
  244.                         'id' => $i->getId(),
  245.                         'idStreaming' => $i->getStreamId(),
  246.                         'name' => $i->getName(),
  247.                         'image' => $image
  248.                     ];
  249.                 }
  250.             }
  251.         }
  252.         $aceTvRecordings $em->getRepository(AceTvRecordings::class)->findByAceTvCategory($aceTvCategory->getId(),$idClubs);
  253.         $recordings = [];
  254.         foreach ($aceTvRecordings as $i) {
  255.             $diff $i->getDateStart()->diff($i->getDateEnd());
  256.             $duration '';
  257.             if ($diff->0) {
  258.                 $duration .= "{$diff->h} hr: ";
  259.             }
  260.             if ($diff->0) {
  261.                 $duration .= "{$diff->i} mins";
  262.             }
  263.             $recordings[] = [
  264.                 'id' => $i->getId(),
  265.                 'idVod' => $i->getRecordingsId(),
  266.                 'name' => $i->getName(),
  267.                 'image' => $i->getImage(),
  268.                 'realName' => str_replace('.mp4','',$i->getRealName()),
  269.                 'duration' => $duration
  270.             ];
  271.         }
  272.         return $this->render('BaseFrontEnd/category.html.twig', [
  273.             'listStreaming' => $cameras,
  274.             'listVods' => $recordings,
  275.             ###################################
  276.             'aceTvCategory' => $aceTvCategory,
  277.             'menu' => 'clubs',
  278.         ]);
  279.     }
  280.     /**
  281.      * @Route("/myVideo", name="index_myVideo")
  282.      */
  283.     public function myVideo(): Response
  284.     {
  285.         $em $this->getDoctrine()->getManager();
  286.         $aceTvRecordings $em->getRepository(AceTvRecordings::class)->findBy(['appUser' => $this->getUser(), 'flagFinish' => true],['id'=>'DESC']);
  287.         $recordings = [];
  288.         foreach ($aceTvRecordings as $i) {
  289.             if($i->getDateEnd()) {
  290.                 $diff $i->getDateStart()->diff($i->getDateEnd());
  291.                 $duration '';
  292.                 if ($diff->0) {
  293.                     $duration .= "{$diff->h} hr: ";
  294.                 }
  295.                 if ($diff->0) {
  296.                     $duration .= "{$diff->i} mins";
  297.                 }
  298.                 $recordings[] = [
  299.                     'id' => $i->getId(),
  300.                     'idVod' => $i->getRecordingsId(),
  301.                     'name' => $i->getName(),
  302.                     'url' => $i->getUrl(),
  303.                     'image' => $i->getImage(),
  304.                     'realName' => str_replace('.mp4'''$i->getRealName()),
  305.                     'duration' => $duration
  306.                 ];
  307.             }
  308.         }
  309.         return $this->render('BaseFrontEnd/myVideo.html.twig', [
  310.             ###################################
  311.             'listVods' => $recordings,
  312.             'menu' => 'myVideo',
  313.         ]);
  314.     }
  315.     /**
  316.      * @Route("/prices", name="index_bagsMinutes")
  317.      */
  318.     public function bagsMinutes(): Response
  319.     {
  320.         $em $this->getDoctrine()->getManager();
  321.         $aceTvBagsMinutes $em->getRepository(AceTvBagsMinutes::class)->findBy(['flagStatus' => true],['priceMinute'=>'ASC']);
  322.         return $this->render('BaseFrontEnd/bagsminutes.html.twig', [
  323.             ###################################
  324.             'aceTvBagsMinutes' => $aceTvBagsMinutes
  325.         ]);
  326.     }
  327.     /**
  328.      * @Route("/balance", name="index_balance")
  329.      */
  330.     public function balance(): Response
  331.     {
  332.         $em $this->getDoctrine()->getManager();
  333.         $aceTvCredits $em->getRepository(AceTvCredit::class)->findBy(['appUser' => $this->getUser()],['id'=>'DESC']);
  334.         $balance 0;
  335.         foreach ($aceTvCredits AS $i) {
  336.             if($i->getCreditAdd() > 0){
  337.                 $balance += $i->getCreditAdd();
  338.             }
  339.             if($i->getCreditSubstract() > 0){
  340.                 $balance -= $i->getCreditSubstract();
  341.             }
  342.         }
  343.         #exit();
  344.         return $this->render('BaseFrontEnd/balance.html.twig', [
  345.             ###################################
  346.             'balance' => $balance,
  347.             'aceTvCredits' => $aceTvCredits,
  348.         ]);
  349.     }
  350.     /**
  351.      * @Route("/live/{idStreaming}", name="index_live")
  352.      * @Security("is_granted('ROLE_LOGIN_TRUE')")
  353.      */
  354.     public function video($idStreaming): Response
  355.     {
  356.         return $this->redirectToRoute('index_online',['idStreaming'=>$idStreaming]);
  357.     }
  358.     /**
  359.      * @Route("/online/{idStreaming}", name="index_online")
  360.      */
  361.     public function videoOnline($idStreaming): Response
  362.     {
  363.         $em $this->getDoctrine()->getManager();
  364.         $aceTvCourtsCameras $em->getRepository(AceTvCourtsCameras::class)->findOneBy(['streamId' => $idStreaming'flagStatus' => true]);
  365.         $aceTvRecordings $em->getRepository(AceTvRecordings::class)->findOneBy([
  366.             'appUser' => $this->getUser(),
  367.             'flagFinish' => false,
  368.             'aceTvCourtsCameras' => $aceTvCourtsCameras
  369.         ]);
  370.         $isMyVideo false;
  371.         if($aceTvRecordings){
  372.             $isMyVideo true;
  373.         }
  374.         $date null;
  375.         $date2 null;
  376.         $minute null;
  377.         $flagFirstRecording false;
  378.         if($this->getUser()){
  379.             if($this->getUser()->getInitRecording()){
  380.                 $date $this->getUser()->getInitRecording()->format('Y-m-d H:i');
  381.                 $date2 = new \DateTime();
  382.                 $date2 $date2->format('Y-m-d H:i');
  383.                 $minute $this->getUser()->getMinute();
  384.             }
  385.             $aceTvRecordings2 $em->getRepository(AceTvRecordings::class)->findBy(['appUser' => $this->getUser()]);
  386.             $flagFirstRecording count($aceTvRecordings2) == 0;
  387.         }
  388.         return $this->render('BaseFrontEnd/live.html.twig', [
  389.             'idStreaming' => $idStreaming,
  390.             'aceTvCourtsCameras' => $aceTvCourtsCameras,
  391.             'isMyVideo' => $isMyVideo,
  392.             'date' => $date,
  393.             'date2' => $date2,
  394.             'minute' => $minute,
  395.             'flagFirstRecording' => $flagFirstRecording,
  396.         ]);
  397.     }
  398.     /**
  399.      * @Route("/vod/{vodId}", name="index_vod")
  400.      */
  401.     public function vod($vodId): Response
  402.     {
  403.         $curl curl_init();
  404.         curl_setopt_array($curl, array(
  405.             CURLOPT_URL => "{$this->url}rest/v2/vods/{$vodId}",
  406.             CURLOPT_RETURNTRANSFER => true,
  407.             CURLOPT_ENCODING => '',
  408.             CURLOPT_MAXREDIRS => 10,
  409.             CURLOPT_TIMEOUT => 0,
  410.             CURLOPT_FOLLOWLOCATION => true,
  411.             CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  412.             CURLOPT_CUSTOMREQUEST => 'GET',
  413.         ));
  414.         $response2 curl_exec($curl);
  415.         curl_close($curl);
  416.         $response2 json_decode($response2true);
  417.         return $this->render('BaseFrontEnd/vod.html.twig', [
  418.             'vod' => $response2,
  419.             'url' => $this->url,
  420.         ]);
  421.     }
  422.     /**
  423.      * @Route("/termsAndConditions", name="index_termsAndConditions")
  424.      */
  425.     public function termsAndConditions(): Response
  426.     {
  427.         return $this->render('BaseFrontEnd/termsAndConditions.html.twig', [
  428.         ]);
  429.     }
  430.     /**
  431.      * @Route("/privacyPolicy", name="index_privacyPolicy")
  432.      */
  433.     public function privacyPolicy(): Response
  434.     {
  435.         return $this->render('BaseFrontEnd/privacyPolicy.html.twig', [
  436.         ]);
  437.     }
  438.     /**
  439.      * @Route("/startEndVideo/{idStreaming}", name="index_startEndVideo")
  440.      */
  441.     public function startVideo(Request $request$idStreaming): Response
  442.     {
  443.         $em $this->getDoctrine()->getManager();
  444.         $aceTvCourtsCameras $em->getRepository(AceTvCourtsCameras::class)->findOneBy(['streamId' => $idStreaming'flagStatus' => true]);
  445.         $curl curl_init();
  446.         if (!$aceTvCourtsCameras->isFlagRecording()) {
  447.             curl_setopt_array($curl, array(
  448.                 CURLOPT_URL => "https://fast-acetv.cloudbase.cl:5443/LiveApp/rest/v2/broadcasts/{$idStreaming}/recording/true?recordType=mp4",
  449.                 CURLOPT_RETURNTRANSFER => true,
  450.                 CURLOPT_ENCODING => '',
  451.                 CURLOPT_MAXREDIRS => 10,
  452.                 CURLOPT_TIMEOUT => 0,
  453.                 CURLOPT_FOLLOWLOCATION => true,
  454.                 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  455.                 CURLOPT_CUSTOMREQUEST => 'PUT',
  456.             ));
  457.             $aceTvCourtsCameras->setFlagRecording(true);
  458.         } else {
  459.             curl_setopt_array($curl, array(
  460.                 CURLOPT_URL => "https://fast-acetv.cloudbase.cl:5443/LiveApp/rest/v2/broadcasts/{$idStreaming}/recording/false?recordType=mp4",
  461.                 CURLOPT_RETURNTRANSFER => true,
  462.                 CURLOPT_ENCODING => '',
  463.                 CURLOPT_MAXREDIRS => 10,
  464.                 CURLOPT_TIMEOUT => 0,
  465.                 CURLOPT_FOLLOWLOCATION => true,
  466.                 CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  467.                 CURLOPT_CUSTOMREQUEST => 'PUT',
  468.             ));
  469.             $aceTvCourtsCameras->setFlagRecording(false);
  470.         }
  471.         $response curl_exec($curl);
  472.         curl_close($curl);
  473.         $response json_decode($responsetrue);
  474.         if ($response['success']) {
  475.             $em->persist($aceTvCourtsCameras);
  476.             $em->flush();
  477.             $aceTvRecordings $em->getRepository(AceTvRecordings::class)->findOneBy(['recordingsId' => $response['dataId']]);
  478.             if (!$aceTvRecordings) {
  479.                 $totalTimeMinute $request->get('totalTime');
  480.                 $appUser $em->getRepository(AppUser::class)->find($this->getUser()->getId());
  481.                 $appUser
  482.                     ->setInitRecording(new \DateTime())
  483.                     ->setMinute($totalTimeMinute)
  484.                     ->setIdStreaming($idStreaming)
  485.                 ;
  486.                 $em->persist($appUser);
  487.                 $em->flush();
  488.                 $flagPublic = (bool)$request->get('flagPublic');
  489.                 $aceTvRecordings = new AceTvRecordings();
  490.                 $aceTvRecordings
  491.                     ->setAppUser($this->getUser())
  492.                     ->setDateStart(new \DateTime())
  493.                     ->setMinute($totalTimeMinute)
  494.                     ->setRecordingsId($response['dataId'])
  495.                     ->setFlagFinish(false)
  496.                     ->setAceTvCourtsCameras($aceTvCourtsCameras)
  497.                     ->setName($aceTvCourtsCameras->getAceTvEnclosures()->getName() . ' ' $aceTvCourtsCameras->getName(). ' '.date('d/m/Y H:i'))
  498.                     ->setFlagPublic($flagPublic)
  499.                     ->setUrl('?')
  500.                     ->setAceTvCategory($aceTvCourtsCameras->getAceTvCategory())
  501.                 ;
  502.             } else {
  503.                 $appUser $em->getRepository(AppUser::class)->find($this->getUser()->getId());
  504.                 $appUser
  505.                     ->setInitRecording(null)
  506.                     ->setMinute(null)
  507.                     ->setIdStreaming(null)
  508.                 ;
  509.                 $em->persist($appUser);
  510.                 $em->flush();
  511.                 $nameImage uniqid().'.png';
  512.                 $url "https://fast-acetv.cloudbase.cl:5443/LiveApp/previews/{$aceTvRecordings->getAceTvCourtsCameras()->getStreamId()}.png";
  513.                 file_put_contents($this->getParameter('user_directory').'/'.$nameImagefile_get_contents($url));
  514.                 $curl curl_init();
  515.                 curl_setopt_array($curl, array(
  516.                     CURLOPT_URL => "https://fast-acetv.cloudbase.cl:5443/LiveApp/rest/v2/vods/{$aceTvRecordings->getRecordingsId()}",
  517.                     CURLOPT_RETURNTRANSFER => true,
  518.                     CURLOPT_ENCODING => '',
  519.                     CURLOPT_MAXREDIRS => 10,
  520.                     CURLOPT_TIMEOUT => 0,
  521.                     CURLOPT_FOLLOWLOCATION => true,
  522.                     CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  523.                     CURLOPT_CUSTOMREQUEST => 'GET',
  524.                 ));
  525.                 $response curl_exec($curl);
  526.                 curl_close($curl);
  527.                 $response json_decode($responsetrue);
  528.                 $fecha = new \DateTime();
  529.                 $agregarDias 7;
  530.                 $fecha->add(new \DateInterval("P{$agregarDias}D"));
  531.                 $aceTvRecordings
  532.                     ->setDateEnd(new \DateTime())
  533.                     ->setDateDelete($fecha)
  534.                     ->setFlagFinish(true)
  535.                     ->setRealName($response['vodName'])
  536.                     ->setUrl($this->url.$response['filePath'])
  537.                     ->setImage($nameImage)
  538.                 ;
  539.             }
  540.             $em->persist($aceTvRecordings);
  541.             $em->flush();
  542.             if ($aceTvRecordings->getDateEnd()) {
  543.                 $diff $aceTvRecordings->getDateStart()->diff($aceTvRecordings->getDateEnd());
  544.                 $duration 0;
  545.                 if ($diff->0) {
  546.                     $duration += $diff->60;
  547.                 }
  548.                 if ($diff->0) {
  549.                     $duration += $diff->i;
  550.                 }
  551.                 $aceTvCredit = new AceTvCredit();
  552.                 $aceTvCredit
  553.                     ->setDateCreation(new \DateTime())
  554.                     ->setCreditAdd(0)
  555.                     ->setAppUser($this->getUser())
  556.                     ->setCreditSubstract($duration);
  557.                 $em->persist($aceTvCredit);
  558.                 $em->flush();
  559.             }
  560.             return new JsonResponse(['status' => 'ok']);
  561.         }
  562.         return new JsonResponse(['status' => 'error']);
  563.     }
  564. }