feat: new Discover section shows watch providers for results
Some checks failed
SonarQube Scan / SonarQube Trigger (pull_request) Failing after 24s
SonarQube Scan / SonarQube Trigger (push) Failing after 36s

This commit is contained in:
Brock H Caldwell
2025-11-11 23:08:20 -06:00
parent c2474942a1
commit 2effa0fb07
23 changed files with 616 additions and 80 deletions

View File

@@ -7,6 +7,7 @@ use App\Base\Enum\MediaType;
use App\Tmdb\Dto\CastMemberDto;
use App\Tmdb\Dto\CrewMemberDto;
use App\Tmdb\Dto\GenreDto;
use App\Tmdb\Dto\WatchProviderDto;
use App\Tmdb\TmdbResult;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
@@ -28,6 +29,7 @@ class TmdbResultDenormalizer implements DenormalizerInterface
$result->directors = $this->getDirectors($data);
$result->producers = $this->getProducers($data);
$result->creators = $this->getCreators($data);
$result->watchProviders = $this->getWatchProviders($data);
return $result;
}
@@ -87,6 +89,17 @@ class TmdbResultDenormalizer implements DenormalizerInterface
->toArray();
}
public function getWatchProviders(array $data): ?array
{
if (!array_key_exists('watch/providers', $data)) {
return null;
}
// ToDo: Make region configurable
return Map::from($data['watch/providers']['results']['US']['flatrate'])
->map(fn($item) => $this->normalizer->denormalize($item, WatchProviderDto::class))
->toArray();
}
public function supportsDenormalization(
mixed $data,
string $type,