✨ Export films
This commit is contained in:
parent
1295b03c3a
commit
dfc11d7a7f
5 changed files with 71 additions and 14 deletions
|
|
@ -1,7 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Data\DataPipes;
|
||||
|
||||
use App\Data\Enums\Type;
|
||||
use FFMpeg\FFMpeg;
|
||||
use Illuminate\Support\Collection;
|
||||
use SimpleXMLElement;
|
||||
|
|
@ -23,26 +26,49 @@ class GetSeasonEp implements DataPipe
|
|||
$nfo = "{$pi['dirname']}/{$pi['filename']}.nfo";
|
||||
if (file_exists($nfo)) {
|
||||
$properties['epNfo'] = $nfo;
|
||||
$xml = simplexml_load_file($nfo);
|
||||
$type = $xml->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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue