✨ Fetch season and episode from file tags
This commit is contained in:
parent
b5e70aec2e
commit
a148fd32d7
1 changed files with 19 additions and 1 deletions
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
namespace App\Data\DataPipes;
|
namespace App\Data\DataPipes;
|
||||||
|
|
||||||
|
use FFMpeg\FFMpeg;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use SimpleXMLElement;
|
use SimpleXMLElement;
|
||||||
use Spatie\LaravelData\DataPipes\DataPipe;
|
use Spatie\LaravelData\DataPipes\DataPipe;
|
||||||
|
|
@ -26,7 +27,7 @@ class GetSeasonEp implements DataPipe
|
||||||
return $this->getEpFromNfo($properties, $nfo);
|
return $this->getEpFromNfo($properties, $nfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $properties;
|
return $this->getEpFromFfprobe($properties);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getEpFromNfo(Collection $properties, string $nfo): Collection
|
protected function getEpFromNfo(Collection $properties, string $nfo): Collection
|
||||||
|
|
@ -41,4 +42,21 @@ class GetSeasonEp implements DataPipe
|
||||||
|
|
||||||
return $properties;
|
return $properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getEpFromFfprobe(Collection $properties): Collection
|
||||||
|
{
|
||||||
|
$ffmpeg = FFMpeg::create();
|
||||||
|
$ffprobe = $ffmpeg->getFFProbe();
|
||||||
|
$tags = $ffprobe->format($properties->get('path'))->get('tags');
|
||||||
|
|
||||||
|
if ($season = $tags['season_number'] ?? $tags['SEASON_NUMBER'] ?? null) {
|
||||||
|
$properties['season'] = (int) $season;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($episode = $tags['episode_sort'] ?? $tags['EPISODE_SORT'] ?? null) {
|
||||||
|
$properties['episode'] = (int) $episode;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $properties;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue