diff --git a/app/Data/DataPipes/GetSeasonEp.php b/app/Data/DataPipes/GetSeasonEp.php index 57c713c..e62dd3f 100644 --- a/app/Data/DataPipes/GetSeasonEp.php +++ b/app/Data/DataPipes/GetSeasonEp.php @@ -1,7 +1,10 @@ getName(); - return $this->getEpFromNfo($properties, $nfo); + if ($type === 'episodedetails') { + return $this->getEpFromNfo($properties, $xml); + } else if ($type === 'movie') { + return $this->getFilmFromNfo($properties, $xml); + } } return $this->getEpFromFfprobe($properties); } - protected function getEpFromNfo(Collection $properties, string $nfo): Collection + protected function getFilmFromNfo(Collection $properties, SimpleXMLElement $xml): Collection { - $xml = simplexml_load_file($nfo); - if ($xml->season) { - $properties['season'] = (int) $xml->season; - } - if ($xml->episode) { - $properties['episode'] = (int) $xml->episode; + $properties['type'] = Type::Movie; + $properties['showTitle'] = $this->getProp($xml, 'title'); + $properties['movieTmdb'] = $this->getProp($xml, 'tmdbid'); + $properties['movieImdb'] = $this->getProp($xml, 'imdbid'); + if (!is_null($year = $this->getProp($xml, 'year'))) { + $properties['movieYear'] = (int) $year; } return $properties; } + protected function getEpFromNfo(Collection $properties, SimpleXMLElement $xml): Collection + { + if (!is_null($seas = $this->getProp($xml, 'season'))) { + $properties['season'] = (int) $seas; + } + if (!is_null($ep = $this->getProp($xml, 'episode'))) { + $properties['episode'] = (int) $ep; + } + + return $properties; + } + + protected function getProp(SimpleXMLElement $xml, string $prop): ?string + { + return $xml->$prop ? (string) $xml->$prop : null; + } + protected function getEpFromFfprobe(Collection $properties): Collection { $ffmpeg = FFMpeg::create(); diff --git a/app/Data/DataPipes/GetShowTmdb.php b/app/Data/DataPipes/GetShowTmdb.php index 192d729..154c2b1 100644 --- a/app/Data/DataPipes/GetShowTmdb.php +++ b/app/Data/DataPipes/GetShowTmdb.php @@ -1,7 +1,10 @@ getProp($xml, 'tmdbid'); diff --git a/app/Data/DataPipes/ParseWatchFile.php b/app/Data/DataPipes/ParseWatchFile.php index c625eaa..14ac0d9 100644 --- a/app/Data/DataPipes/ParseWatchFile.php +++ b/app/Data/DataPipes/ParseWatchFile.php @@ -1,7 +1,10 @@ sprintf( + '%s-%d.json', + Str::slug($properties['showTitle'] ?? uniqid()), + $properties['movieYear'], + ), + default => sprintf( + '%s-%dx%02d.json', + Str::slug($properties['showTitle'] ?? uniqid()), + $properties['season'], + $properties['episode'] + ), + }; return $properties; } diff --git a/app/Data/Enums/Type.php b/app/Data/Enums/Type.php new file mode 100644 index 0000000..3d2f302 --- /dev/null +++ b/app/Data/Enums/Type.php @@ -0,0 +1,11 @@ +