fix: updates episode air date for existing monitors
This commit is contained in:
@@ -5,7 +5,6 @@ namespace App\Monitor\Action\Handler;
|
|||||||
use App\Base\Util\EpisodeId;
|
use App\Base\Util\EpisodeId;
|
||||||
use App\Download\Action\Command\DownloadMediaCommand;
|
use App\Download\Action\Command\DownloadMediaCommand;
|
||||||
use App\Download\DownloadOptionEvaluator;
|
use App\Download\DownloadOptionEvaluator;
|
||||||
use App\Download\Framework\Entity\Download;
|
|
||||||
use App\Download\Framework\Repository\DownloadRepository;
|
use App\Download\Framework\Repository\DownloadRepository;
|
||||||
use App\Monitor\Action\Command\MonitorMovieCommand;
|
use App\Monitor\Action\Command\MonitorMovieCommand;
|
||||||
use App\Monitor\Action\Result\MonitorTvEpisodeResult;
|
use App\Monitor\Action\Result\MonitorTvEpisodeResult;
|
||||||
@@ -44,6 +43,11 @@ readonly class MonitorTvEpisodeHandler implements HandlerInterface
|
|||||||
$this->logger->info('> [MonitorTvEpisodeHandler] Executing MonitorTvEpisodeHandler for ' . $monitor->getTitle() . ' season ' . $monitor->getSeason() . ' episode ' . $monitor->getEpisode());
|
$this->logger->info('> [MonitorTvEpisodeHandler] Executing MonitorTvEpisodeHandler for ' . $monitor->getTitle() . ' season ' . $monitor->getSeason() . ' episode ' . $monitor->getEpisode());
|
||||||
|
|
||||||
$episodeData = $this->tmdb->episodeDetails($monitor->getTmdbId(), $monitor->getSeason(), $monitor->getEpisode());
|
$episodeData = $this->tmdb->episodeDetails($monitor->getTmdbId(), $monitor->getSeason(), $monitor->getEpisode());
|
||||||
|
|
||||||
|
if (null === $monitor->getAirDate() && null !== $episodeData->episodeAirDate && "" !== $episodeData->episodeAirDate) {
|
||||||
|
$monitor->setAirDate(Carbon::parse($episodeData->episodeAirDate));
|
||||||
|
}
|
||||||
|
|
||||||
if (Carbon::createFromTimestamp($episodeData->episodeAirDate) > Carbon::today('UTC')) {
|
if (Carbon::createFromTimestamp($episodeData->episodeAirDate) > Carbon::today('UTC')) {
|
||||||
$this->logger->info('> [MonitorTvEpisodeHandler] ...Episode has not aired yet, skipping for now');
|
$this->logger->info('> [MonitorTvEpisodeHandler] ...Episode has not aired yet, skipping for now');
|
||||||
return new MonitorTvEpisodeResult(
|
return new MonitorTvEpisodeResult(
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ class Monitor
|
|||||||
return $this->airDate;
|
return $this->airDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setAirDate(?\DateTimeImmutable $airDate): static
|
public function setAirDate(?\DateTimeInterface $airDate): static
|
||||||
{
|
{
|
||||||
$this->airDate = $airDate;
|
$this->airDate = $airDate;
|
||||||
return $this;
|
return $this;
|
||||||
|
|||||||
@@ -286,13 +286,18 @@ class Tmdb
|
|||||||
|
|
||||||
private function parseTvShow(array $data, string $posterBasePath): TmdbResult
|
private function parseTvShow(array $data, string $posterBasePath): TmdbResult
|
||||||
{
|
{
|
||||||
|
if (!in_array($data['first_air_date'], ['', null,])) {
|
||||||
|
$airDate = (new \DateTime($data['first_air_date']))->format('Y-m-d');
|
||||||
|
} else {
|
||||||
|
$airDate = null;
|
||||||
|
}
|
||||||
return new TmdbResult(
|
return new TmdbResult(
|
||||||
imdbId: $data['external_ids']['imdb_id'],
|
imdbId: $data['external_ids']['imdb_id'],
|
||||||
tmdbId: $data['id'],
|
tmdbId: $data['id'],
|
||||||
title: $data['name'],
|
title: $data['name'],
|
||||||
poster: (null !== $data['poster_path']) ? $posterBasePath . $data['poster_path'] : null,
|
poster: (null !== $data['poster_path']) ? $posterBasePath . $data['poster_path'] : null,
|
||||||
description: $data['overview'],
|
description: $data['overview'],
|
||||||
year: (new \DateTime($data['first_air_date']))->format('Y'),
|
year: $airDate,
|
||||||
mediaType: "tvshows",
|
mediaType: "tvshows",
|
||||||
episodes: $data['episodes'],
|
episodes: $data['episodes'],
|
||||||
);
|
);
|
||||||
@@ -300,6 +305,11 @@ class Tmdb
|
|||||||
|
|
||||||
private function parseEpisode(array $data, string $posterBasePath): TmdbResult
|
private function parseEpisode(array $data, string $posterBasePath): TmdbResult
|
||||||
{
|
{
|
||||||
|
if (!in_array($data['air_date'], ['', null,])) {
|
||||||
|
$airDate = (new \DateTime($data['air_date']))->format('Y-m-d');
|
||||||
|
} else {
|
||||||
|
$airDate = null;
|
||||||
|
}
|
||||||
return new TmdbResult(
|
return new TmdbResult(
|
||||||
imdbId: $data['external_ids']['imdb_id'],
|
imdbId: $data['external_ids']['imdb_id'],
|
||||||
tmdbId: $data['id'],
|
tmdbId: $data['id'],
|
||||||
@@ -309,12 +319,17 @@ class Tmdb
|
|||||||
year: (new \DateTime($data['air_date']))->format('Y'),
|
year: (new \DateTime($data['air_date']))->format('Y'),
|
||||||
mediaType: "tvshows",
|
mediaType: "tvshows",
|
||||||
episodes: null,
|
episodes: null,
|
||||||
episodeAirDate: (new \DateTime($data['air_date']))->format('m/d/Y'),
|
episodeAirDate: $airDate,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseMovie(array $data, string $posterBasePath): TmdbResult
|
private function parseMovie(array $data, string $posterBasePath): TmdbResult
|
||||||
{
|
{
|
||||||
|
if (!in_array($data['release_date'], ['', null,])) {
|
||||||
|
$airDate = (new \DateTime($data['release_date']))->format('Y-m-d');
|
||||||
|
} else {
|
||||||
|
$airDate = null;
|
||||||
|
}
|
||||||
return new TmdbResult(
|
return new TmdbResult(
|
||||||
imdbId: $data['external_ids']['imdb_id'],
|
imdbId: $data['external_ids']['imdb_id'],
|
||||||
tmdbId: $data['id'],
|
tmdbId: $data['id'],
|
||||||
@@ -323,7 +338,7 @@ class Tmdb
|
|||||||
description: $data['overview'],
|
description: $data['overview'],
|
||||||
year: (new \DateTime($data['release_date']))->format('Y'),
|
year: (new \DateTime($data['release_date']))->format('Y'),
|
||||||
mediaType: "movies",
|
mediaType: "movies",
|
||||||
episodeAirDate: (new \DateTime($data['release_date']))->format('m/d/Y'),
|
episodeAirDate: $airDate,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user