|
@@ -4,6 +4,7 @@ namespace App\Service;
|
|
|
|
|
|
use App\Entity\Film;
|
|
|
use App\Entity\Genre;
|
|
|
+use App\Entity\MediaVideo;
|
|
|
use App\Entity\Realisateur;
|
|
|
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
|
|
|
|
@@ -89,7 +90,7 @@ class TmdbApiService
|
|
|
public function hydrateFilm($filmTmdbId): Film
|
|
|
{
|
|
|
$filmTmdb = json_decode($this->getDetailMovie($filmTmdbId));
|
|
|
-
|
|
|
+ dump($filmTmdb);
|
|
|
$film = new Film();
|
|
|
$film
|
|
|
->setTitre($filmTmdb->title)
|
|
@@ -120,6 +121,13 @@ class TmdbApiService
|
|
|
$film->addRealisateur($realisateur);
|
|
|
}
|
|
|
|
|
|
+ $videoTmdb = $this->getOneVideo($filmTmdb);
|
|
|
+ if (!empty($videoTmdb)) {
|
|
|
+ $video = new MediaVideo();
|
|
|
+ $video->setFromTmdb($videoTmdb['type'], $videoTmdb['identif']);
|
|
|
+ $film->setMediaVideo($video);
|
|
|
+ }
|
|
|
+
|
|
|
$film = $this->uc->assureUniciteCollections($film);
|
|
|
return $film;
|
|
|
}
|
|
@@ -136,4 +144,23 @@ class TmdbApiService
|
|
|
}
|
|
|
return $directors;
|
|
|
}
|
|
|
+
|
|
|
+ public function getOneVideo($detailMovie): array
|
|
|
+ {
|
|
|
+ foreach($detailMovie->videos->results as $video) {
|
|
|
+ dump($video);
|
|
|
+ if (
|
|
|
+ ($video->site === "YouTube" || $video->site === "Vimeo" || $video->site === "DailyMotion") &&
|
|
|
+ $video->type === "Trailer" &&
|
|
|
+ $video->iso_639_1 === "fr" && $video->iso_3166_1 === "FR"
|
|
|
+ ) {
|
|
|
+ return [
|
|
|
+ 'type' => strtolower($video->site),
|
|
|
+ 'identif' => $video->key
|
|
|
+ ];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
}
|