diff --git a/src/VideoInfo.php b/src/VideoInfo.php index d7e9455..31c6ae6 100644 --- a/src/VideoInfo.php +++ b/src/VideoInfo.php @@ -64,13 +64,12 @@ class VideoInfo public function getTitleForHumans(): string { - $title = ucwords(str_replace('-', ' ', $this->getTitle())); - - if ($this->hasEpisode()) { - $title = str_pad($this->getEpisodeNumber(), 2, '0', STR_PAD_LEFT) . ' - ' . $title; - } - - return $title; + return '' + . ($this->hasSeason() ? 'S' . str_pad($this->getSeasonNumber(), 2, '0', STR_PAD_LEFT) : '') + . ($this->hasEpisode() ? 'E' . str_pad($this->getEpisodeNumber(), 2, '0', STR_PAD_LEFT) : '') + . ($this->hasSeason() || $this->hasEpisode() ? ' - ' : '') + . ucwords(str_replace('-', ' ', $this->getTitle())); + ; } public function getTargetFilePath(): string diff --git a/tests/Unit/VideoInfoTest.php b/tests/Unit/VideoInfoTest.php index ffffc65..aaa619b 100644 --- a/tests/Unit/VideoInfoTest.php +++ b/tests/Unit/VideoInfoTest.php @@ -197,13 +197,17 @@ class VideoInfoTest extends TestCase 'filename' => 'Sherlock-Holmes_Der-Vampir-Von-Whitechapel_hq.mp4', 'expectedTargetFilePath' => 'Sherlock-Holmes/Der Vampir Von Whitechapel.mp4', ], - 'Series no seasons' => [ + 'Series no seasons without episode' => [ 'filename' => 'Storage-Hunters_episode-2_trucker-auktion_hq.mp4', - 'expectedTargetFilePath' => 'Storage-Hunters/02 - Trucker Auktion.mp4', + 'expectedTargetFilePath' => 'Storage-Hunters/E02 - Trucker Auktion.mp4', ], - 'Series with seasons' => [ + 'Series with seasons without episode' => [ 'filename' => 'The-Big-Bang-Theory_season-1_episode-12_das-jerusalem-projekt_hq.mp4', - 'expectedTargetFilePath' => 'The-Big-Bang-Theory/Staffel-01/12 - Das Jerusalem Projekt.mp4', + 'expectedTargetFilePath' => 'The-Big-Bang-Theory/Staffel-01/S01E12 - Das Jerusalem Projekt.mp4', + ], + 'Series with seasons and episode' => [ + 'filename' => 'The-Big-Bang-Theory_season-1_episode-12_das-jerusalem-projekt_hq.mp4', + 'expectedTargetFilePath' => 'The-Big-Bang-Theory/Staffel-01/S01E12 - Das Jerusalem Projekt.mp4', ], ]; }