From 566b73ee04610a2806572425117529db678742b4 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Mon, 5 Oct 2020 10:49:46 +0200 Subject: [PATCH] Add option to remove input file on completion --- cutvideo | 1 + src/Command.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/cutvideo b/cutvideo index 09a629b..ab10f34 100755 --- a/cutvideo +++ b/cutvideo @@ -15,6 +15,7 @@ use Symfony\Component\Console\SingleCommandApplication; ->addArgument('start', InputArgument::REQUIRED, 'The starting point of the video') ->addArgument('end', InputArgument::REQUIRED, 'The end point of the video') ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force generation, even if target already exists.') + ->addOption('remove', 'r', InputOption::VALUE_NONE, 'Remove input file on success.') ->addOption('ad', null, InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'Start and end of ads, separate start and end via "/".', []) ->setCode(new Command()) ->run(); diff --git a/src/Command.php b/src/Command.php index 5a52ea2..7998498 100644 --- a/src/Command.php +++ b/src/Command.php @@ -87,6 +87,10 @@ class Command $videoInfo->getTargetFilePath() )); + if ($input->getOption('remove')) { + $this->removeInputFile($videoInfo); + } + return 0; } @@ -128,4 +132,10 @@ class Command mkdir($target, 0775, true); } + + private function removeInputFile(VideoInfo $videoInfo) + { + $this->executeStep('Remove input file'); + unlink($videoInfo->getOriginalFilename()); + } }