Merge pull request #116 from ArabCoders/dev
Fixed bug in plex webhook push sync.
This commit is contained in:
@@ -9,6 +9,8 @@ use App\Libs\Config;
|
||||
use App\Libs\Servers\ServerInterface;
|
||||
use JsonException;
|
||||
use RuntimeException;
|
||||
use Symfony\Component\Console\Completion\CompletionInput;
|
||||
use Symfony\Component\Console\Completion\CompletionSuggestions;
|
||||
use Symfony\Component\Console\Helper\Table;
|
||||
use Symfony\Component\Console\Helper\TableSeparator;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
@@ -199,4 +201,35 @@ final class RemoteCommand extends Command
|
||||
$output->writeln(Yaml::dump($result, 8, 2));
|
||||
}
|
||||
}
|
||||
|
||||
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
|
||||
{
|
||||
if ($input->mustSuggestOptionValuesFor('search-output')) {
|
||||
$currentValue = $input->getCompletionValue();
|
||||
|
||||
$suggest = [];
|
||||
|
||||
foreach (['yaml', 'json'] as $name) {
|
||||
if (empty($currentValue) || str_starts_with($name, $currentValue)) {
|
||||
$suggest[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$suggestions->suggestValues($suggest);
|
||||
}
|
||||
|
||||
if ($input->mustSuggestArgumentValuesFor('name')) {
|
||||
$currentValue = $input->getCompletionValue();
|
||||
|
||||
$suggest = [];
|
||||
|
||||
foreach (array_keys(Config::get('servers', [])) as $name) {
|
||||
if (empty($currentValue) || str_starts_with($name, $currentValue)) {
|
||||
$suggest[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
$suggestions->suggestValues($suggest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ class PushCommand extends Command
|
||||
protected function process(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
if (!$this->cache->has('queue')) {
|
||||
$output->writeln('<info>No items in the queue.</info>', OutputInterface::VERBOSITY_DEBUG);
|
||||
$output->writeln('<info>No items in the queue.</info>', OutputInterface::VERBOSITY_VERY_VERBOSE);
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ class PushCommand extends Command
|
||||
|
||||
if (empty($entities)) {
|
||||
$this->cache->delete('queue');
|
||||
$output->writeln('<info>No items in the queued.</info>', OutputInterface::VERBOSITY_DEBUG);
|
||||
$output->writeln('<info>No items in the queue.</info>', OutputInterface::VERBOSITY_VERY_VERBOSE);
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
@@ -143,7 +143,7 @@ class PushCommand extends Command
|
||||
$type = strtolower(ag($server, 'type', 'unknown'));
|
||||
|
||||
if (true !== (bool)ag($server, 'webhook.push')) {
|
||||
$this->logger->info(sprintf('%s: Ignoring this backend as requested by user config.', $serverName));
|
||||
$this->logger->info(sprintf('%s: Ignoring backend as requested by user config.', $serverName));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -159,8 +159,13 @@ class PushCommand extends Command
|
||||
continue;
|
||||
}
|
||||
|
||||
if (null === ag($server, 'url') || false === filter_var(ag($server, 'url'), FILTER_VALIDATE_URL)) {
|
||||
$this->logger->error(sprintf('%s: Backend does not have valid URL.', $serverName));
|
||||
if (null === ($url = ag($server, 'url')) || false === filter_var($url, FILTER_VALIDATE_URL)) {
|
||||
$this->logger->error(
|
||||
sprintf('%s: Backend does not have valid url.', $serverName),
|
||||
[
|
||||
'url' => $url ?? 'None'
|
||||
]
|
||||
);
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
@@ -169,7 +174,7 @@ class PushCommand extends Command
|
||||
}
|
||||
|
||||
if (empty($list)) {
|
||||
$output->writeln('No servers were found with \'webhook.push\' enabled.');
|
||||
$output->writeln('No Backends have push via webhook enabled.');
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
|
||||
@@ -675,11 +675,11 @@ class JellyfinServer implements ServerInterface
|
||||
$requests = $stateRequests = [];
|
||||
|
||||
foreach ($entities as $key => $entity) {
|
||||
if (null === $entity) {
|
||||
if (true !== ($entity instanceof StateEntity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false === (ag($this->options, Options::IGNORE_DATE, false))) {
|
||||
if (false === (bool)ag($this->options, Options::IGNORE_DATE, false)) {
|
||||
if (null !== $after && $after->getTimestamp() > $entity->updated) {
|
||||
continue;
|
||||
}
|
||||
@@ -687,8 +687,11 @@ class JellyfinServer implements ServerInterface
|
||||
|
||||
$iName = $entity->getName();
|
||||
|
||||
if (null === ($entity->metadata[$this->name][iFace::COLUMN_ID] ?? null)) {
|
||||
$this->logger->warning(sprintf('%s: Ignoring \'%s\'. No relation map.', $this->name, $iName));
|
||||
if (null === $entity->metadata[$this->name][iFace::COLUMN_ID] ?? null) {
|
||||
$this->logger->warning(
|
||||
sprintf('%s: Ignoring \'%s\'. No relation map.', $this->name, $iName),
|
||||
[$this->name => ag($entity->metadata, $this->name, 'no metadata found')]
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1457,7 +1460,7 @@ class JellyfinServer implements ServerInterface
|
||||
} else {
|
||||
$iName = trim(
|
||||
sprintf(
|
||||
'%s - [%s - (%dx%d)]',
|
||||
'%s - [%s - (%sx%s)]',
|
||||
$library,
|
||||
$item->SeriesName ?? '??',
|
||||
str_pad((string)($item->ParentIndexNumber ?? 0), 2, '0', STR_PAD_LEFT),
|
||||
|
||||
@@ -712,11 +712,11 @@ class PlexServer implements ServerInterface
|
||||
$requests = $stateRequests = [];
|
||||
|
||||
foreach ($entities as $key => $entity) {
|
||||
if (null === $entity) {
|
||||
if (true !== ($entity instanceof StateEntity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (false === (ag($this->options, Options::IGNORE_DATE, false))) {
|
||||
if (false === (bool)ag($this->options, Options::IGNORE_DATE, false)) {
|
||||
if (null !== $after && $after->getTimestamp() > $entity->updated) {
|
||||
continue;
|
||||
}
|
||||
@@ -724,13 +724,15 @@ class PlexServer implements ServerInterface
|
||||
|
||||
$iName = $entity->getName();
|
||||
|
||||
if (null === ($entity->metdata[$this->name][iFace::COLUMN_ID] ?? null)) {
|
||||
$this->logger->warning(sprintf('%s: Ignoring \'%s\'. No relation map.', $this->name, $iName));
|
||||
if (null === $entity->metadata[$this->name][iFace::COLUMN_ID] ?? null) {
|
||||
$this->logger->warning(
|
||||
sprintf('%s: Ignoring \'%s\'. No relation map.', $this->name, $iName),
|
||||
[$this->name => ag($entity->metadata, $this->name, 'no metadata found')]
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
$url = $this->url->withPath('/library/metadata/' . $entity->metdata[$this->name][iFace::COLUMN_ID])
|
||||
$url = $this->url->withPath('/library/metadata/' . $entity->metadata[$this->name][iFace::COLUMN_ID])
|
||||
->withQuery(
|
||||
http_build_query(
|
||||
[
|
||||
@@ -750,7 +752,7 @@ class PlexServer implements ServerInterface
|
||||
'user_data' => [
|
||||
'id' => $key,
|
||||
'state' => &$entity,
|
||||
'suid' => $entity->metdata[$this->name][iFace::COLUMN_ID],
|
||||
'suid' => $entity->metadata[$this->name][iFace::COLUMN_ID],
|
||||
]
|
||||
])
|
||||
);
|
||||
@@ -1358,7 +1360,7 @@ class PlexServer implements ServerInterface
|
||||
} else {
|
||||
$iName = trim(
|
||||
sprintf(
|
||||
'%s - [%s - (%dx%d)]',
|
||||
'%s - [%s - (%sx%s)]',
|
||||
$library,
|
||||
$item->grandparentTitle ?? $item->originalTitle ?? '??',
|
||||
str_pad((string)($item->parentIndex ?? 0), 2, '0', STR_PAD_LEFT),
|
||||
|
||||
Reference in New Issue
Block a user