diff --git a/composer.json b/composer.json index ae91faa..5a15d20 100644 --- a/composer.json +++ b/composer.json @@ -24,6 +24,7 @@ "symfony/console": "7.2.*", "symfony/doctrine-messenger": "7.2.*", "symfony/dotenv": "7.2.*", + "symfony/filesystem": "7.2.*", "symfony/finder": "7.2.*", "symfony/flex": "^2", "symfony/form": "7.2.*", diff --git a/composer.lock b/composer.lock index 47443a6..438cb8b 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c9b0e6d834b028ec81a8ba1d24005d77", + "content-hash": "7e29123297e1ac72cd417967d2a761b4", "packages": [ { "name": "1tomany/rich-bundle", diff --git a/src/Monitor/Action/Handler/MonitorTvEpisodeHandler.php b/src/Monitor/Action/Handler/MonitorTvEpisodeHandler.php index 1632a92..ab99ec7 100644 --- a/src/Monitor/Action/Handler/MonitorTvEpisodeHandler.php +++ b/src/Monitor/Action/Handler/MonitorTvEpisodeHandler.php @@ -2,7 +2,7 @@ namespace App\Monitor\Action\Handler; -use App\Monitor\Action\Command\DownloadMediaCommand; +use App\Download\Action\Command\DownloadMediaCommand; use App\Monitor\Action\Command\MonitorMovieCommand; use App\Monitor\Action\Result\MonitorMovieResult; use App\Monitor\Framework\Repository\MonitorRepository; diff --git a/src/Monitor/Service/MediaFiles.php b/src/Monitor/Service/MediaFiles.php index 9da8fd5..9ce4c07 100644 --- a/src/Monitor/Service/MediaFiles.php +++ b/src/Monitor/Service/MediaFiles.php @@ -4,6 +4,7 @@ namespace App\Monitor\Service; use Aimeos\Map; use Symfony\Component\DependencyInjection\Attribute\Autowire; +use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Finder\Finder; class MediaFiles @@ -14,16 +15,21 @@ class MediaFiles private string $tvShowsPath; + private Filesystem $filesystem; + public function __construct( #[Autowire(param: 'media.movies_path')] string $moviesPath, #[Autowire(param: 'media.tvshows_path')] string $tvShowsPath, + + Filesystem $filesystem, ) { $this->finder = new Finder(); $this->moviesPath = $moviesPath; $this->tvShowsPath = $tvShowsPath; + $this->filesystem = $filesystem; } public function getMoviesPath(): string @@ -61,7 +67,11 @@ class MediaFiles if (!str_starts_with($path, $this->tvShowsPath)) { $path = $this->tvShowsPath . DIRECTORY_SEPARATOR . $path; } - + + if (false === $this->filesystem->exists($path)) { + $this->filesystem->mkdir($path); + } + $results = []; foreach ($this->finder->in($path)->files() as $file) { if ($onlyFilenames) {