Generate file name matching movie database

This allows to auto scrap info for tv show episodes from movie database
on kodi.
This commit is contained in:
Daniel Siepmann 2023-02-08 08:14:36 +01:00
parent 97a389909d
commit 2d411d7160
Signed by: Daniel Siepmann
GPG key ID: 33D6629915560EF4
2 changed files with 14 additions and 11 deletions

View file

@ -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

View file

@ -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',
],
];
}