feat: shows existing files for already downloaded media
This commit is contained in:
@@ -8,7 +8,7 @@ parameters:
|
|||||||
media.base_path: '/var/download'
|
media.base_path: '/var/download'
|
||||||
media.default_movies_dir: movies
|
media.default_movies_dir: movies
|
||||||
media.default_tvshows_dir: tvshows
|
media.default_tvshows_dir: tvshows
|
||||||
media.movies_path: '%env(default:media.default_movies_dir:MOVIES_PATH)%'
|
media.movies_path: '/var/download/%env(default:media.default_movies_dir:MOVIES_PATH)%'
|
||||||
media.tvshows_path: '/var/download/%env(default:media.default_tvshows_dir:TVSHOWS_PATH)%'
|
media.tvshows_path: '/var/download/%env(default:media.default_tvshows_dir:TVSHOWS_PATH)%'
|
||||||
|
|
||||||
# Mercure
|
# Mercure
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ final class TorrentioController extends AbstractController
|
|||||||
$input->episode,
|
$input->episode,
|
||||||
);
|
);
|
||||||
|
|
||||||
// return $cache->get($cacheId, function (ItemInterface $item) use ($input) {
|
return $cache->get($cacheId, function (ItemInterface $item) use ($input) {
|
||||||
// $item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0));
|
$item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0));
|
||||||
$results = $this->getTvShowOptionsHandler->handle($input->toCommand());
|
$results = $this->getTvShowOptionsHandler->handle($input->toCommand());
|
||||||
return $this->render('torrentio/tvshows.html.twig', [
|
return $this->render('torrentio/tvshows.html.twig', [
|
||||||
'results' => $results,
|
'results' => $results,
|
||||||
]);
|
]);
|
||||||
// });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/torrentio/tvshows/clear/{tmdbId}/{imdbId}/{season?}/{episode?}', name: 'app_clear_torrentio_tvshows')]
|
#[Route('/torrentio/tvshows/clear/{tmdbId}/{imdbId}/{season?}/{episode?}', name: 'app_clear_torrentio_tvshows')]
|
||||||
|
|||||||
@@ -158,4 +158,29 @@ class MediaFiles
|
|||||||
|
|
||||||
return false;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Torrentio\Action\Handler;
|
namespace App\Torrentio\Action\Handler;
|
||||||
|
|
||||||
|
use App\Monitor\Service\MediaFiles;
|
||||||
use App\Tmdb\Tmdb;
|
use App\Tmdb\Tmdb;
|
||||||
use App\Torrentio\Action\Result\GetMovieOptionsResult;
|
use App\Torrentio\Action\Result\GetMovieOptionsResult;
|
||||||
use App\Torrentio\Client\Torrentio;
|
use App\Torrentio\Client\Torrentio;
|
||||||
@@ -14,12 +15,15 @@ class GetMovieOptionsHandler implements HandlerInterface
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly Tmdb $tmdb,
|
private readonly Tmdb $tmdb,
|
||||||
private readonly Torrentio $torrentio,
|
private readonly Torrentio $torrentio,
|
||||||
|
private readonly MediaFiles $mediaFiles
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function handle(CommandInterface $command): ResultInterface
|
public function handle(CommandInterface $command): ResultInterface
|
||||||
{
|
{
|
||||||
|
$media = $this->tmdb->mediaDetails($command->imdbId, 'movies');
|
||||||
return new GetMovieOptionsResult(
|
return new GetMovieOptionsResult(
|
||||||
media: $this->tmdb->mediaDetails($command->imdbId, 'movies'),
|
media: $media,
|
||||||
|
file: $this->mediaFiles->movieExists($media->title),
|
||||||
results: $this->torrentio->search($command->imdbId, 'movies'),
|
results: $this->torrentio->search($command->imdbId, 'movies'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ class GetMovieOptionsResult implements ResultInterface
|
|||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
public TmdbResult $media,
|
public TmdbResult $media,
|
||||||
|
public bool|\SplFileInfo $file,
|
||||||
public array $results
|
public array $results
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,13 @@
|
|||||||
<div class="p-4 flex flex-col gap-6 bg-orange-500 bg-clip-padding backdrop-filter backdrop-blur-md bg-opacity-60 rounded-md">
|
<div class="p-4 flex flex-col gap-6 bg-orange-500 bg-clip-padding backdrop-filter backdrop-blur-md bg-opacity-60 rounded-md">
|
||||||
|
{% if results.file != false %}
|
||||||
|
<div class="p-3 bg-stone-400 p-1 text-black rounded-md m-1 animate-fade">
|
||||||
|
<p class="font-bold text-sm text-left">Existing file(s) for this movie:</p>
|
||||||
|
<ul class="list-disc ml-3">
|
||||||
|
<li class="font-normal">{{ results.file.realPath|strip_media_path }} — <strong>{{ results.file.size|filesize }}</strong></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<div class="overflow-hidden rounded-md">
|
<div class="overflow-hidden rounded-md">
|
||||||
{{ include('torrentio/partial/option-table.html.twig', {controller: 'movie-results'}) }}
|
{{ include('torrentio/partial/option-table.html.twig', {controller: 'movie-results'}) }}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user