mirror of
https://github.com/AzuraCast/AzuraCast.git
synced 2024-06-14 21:26:37 +00:00
Add optional "path" argument to media reprocess CLI command.
This commit is contained in:
parent
fb5b8e149c
commit
675d53f85b
|
@ -31,7 +31,16 @@ final class ReprocessMediaCommand extends CommandAbstract
|
|||
|
||||
protected function configure(): void
|
||||
{
|
||||
$this->addArgument('station-name', InputArgument::OPTIONAL);
|
||||
$this->addArgument(
|
||||
'station-name',
|
||||
InputArgument::OPTIONAL,
|
||||
'The shortcode for the station (i.e. "my_station_name") to only process one station.'
|
||||
);
|
||||
$this->addArgument(
|
||||
'path',
|
||||
InputArgument::OPTIONAL,
|
||||
'Optionally specify a path (of either a file or a directory) to only process that item.'
|
||||
);
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
|
@ -39,13 +48,16 @@ final class ReprocessMediaCommand extends CommandAbstract
|
|||
$io = new SymfonyStyle($input, $output);
|
||||
|
||||
$stationName = Types::stringOrNull($input->getArgument('station-name'), true);
|
||||
$path = Types::stringOrNull($input->getArgument('path'), true);
|
||||
|
||||
$io->title('Manually Reprocess Media');
|
||||
|
||||
$reprocessMediaQueue = $this->em->createQueryBuilder()
|
||||
->update(StationMedia::class, 'sm')
|
||||
->set('sm.mtime', 'NULL');
|
||||
|
||||
if (null === $stationName) {
|
||||
$io->section('Reprocessing media for all stations...');
|
||||
|
||||
$storageLocation = null;
|
||||
} else {
|
||||
$station = $this->stationRepo->findByIdentifier($stationName);
|
||||
if (!$station instanceof Station) {
|
||||
|
@ -56,15 +68,14 @@ final class ReprocessMediaCommand extends CommandAbstract
|
|||
$storageLocation = $station->getMediaStorageLocation();
|
||||
|
||||
$io->writeln(sprintf('Reprocessing media for station: %s', $station->getName()));
|
||||
|
||||
$reprocessMediaQueue = $reprocessMediaQueue->andWhere('sm.storage_location = :storageLocation')
|
||||
->setParameter('storageLocation', $storageLocation);
|
||||
}
|
||||
|
||||
$reprocessMediaQueue = $this->em->createQueryBuilder()
|
||||
->update(StationMedia::class, 'sm')
|
||||
->set('sm.mtime', 'NULL');
|
||||
|
||||
if (null !== $storageLocation) {
|
||||
$reprocessMediaQueue = $reprocessMediaQueue->where('sm.storage_location = :storageLocation')
|
||||
->setParameter('storageLocation', $storageLocation);
|
||||
if (null !== $path) {
|
||||
$reprocessMediaQueue = $reprocessMediaQueue->andWhere('sm.path LIKE :path')
|
||||
->setParameter('path', $path . '%');
|
||||
}
|
||||
|
||||
$recordsAffected = $reprocessMediaQueue->getQuery()->getSingleScalarResult();
|
||||
|
|
Loading…
Reference in New Issue
Block a user