feat: shows existing files for already downloaded media

This commit is contained in:
2025-06-07 22:19:05 -05:00
parent f9a284cb67
commit 63850e48fd
6 changed files with 44 additions and 5 deletions

View File

@@ -158,4 +158,29 @@ class MediaFiles
return false;
}
public function movieExists(string $title)
{
$filepath = $this->moviesPath . DIRECTORY_SEPARATOR . $title;
$directoryExists = $this->filesystem->exists($filepath);
if (false === $directoryExists) {
return false;
}
if (false === $this->finder->in($filepath)->files()->hasResults()) {
return false;
}
$files = Map::from($this->finder->in($filepath)->files())->filter(function (SplFileInfo $file) {
$validExtensions = ['mkv', 'mp4', 'mpeg'];
return in_array($file->getExtension(), $validExtensions);
})->values();
if (false === $files->isEmpty()) {
return $files[0];
}
return false;
}
}