From be788a5b0aeabec2338084d83c05962ef6779633 Mon Sep 17 00:00:00 2001 From: "Abdulmhsen B. A. A" Date: Fri, 20 May 2022 22:52:23 +0300 Subject: [PATCH 1/3] Fixed incorrect episode and season casting for logging. --- src/Libs/Servers/JellyfinServer.php | 2 +- src/Libs/Servers/PlexServer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Libs/Servers/JellyfinServer.php b/src/Libs/Servers/JellyfinServer.php index e07226d5..114583d2 100644 --- a/src/Libs/Servers/JellyfinServer.php +++ b/src/Libs/Servers/JellyfinServer.php @@ -1457,7 +1457,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), diff --git a/src/Libs/Servers/PlexServer.php b/src/Libs/Servers/PlexServer.php index b3fc7f1c..df64e2a7 100644 --- a/src/Libs/Servers/PlexServer.php +++ b/src/Libs/Servers/PlexServer.php @@ -1358,7 +1358,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), From bb2bf852d773a0c3bc58616b9641687b4d35efd5 Mon Sep 17 00:00:00 2001 From: "Abdulmhsen B. A. A" Date: Fri, 20 May 2022 23:08:55 +0300 Subject: [PATCH 2/3] Added value autocompletion for servers:remote --- src/Commands/Servers/RemoteCommand.php | 33 ++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/Commands/Servers/RemoteCommand.php b/src/Commands/Servers/RemoteCommand.php index e63389c3..f6e79902 100644 --- a/src/Commands/Servers/RemoteCommand.php +++ b/src/Commands/Servers/RemoteCommand.php @@ -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); + } + } } From 73b891b53b3bca23e45da0c6b4b8ba67a736718e Mon Sep 17 00:00:00 2001 From: abdulmohsen Date: Sat, 21 May 2022 19:39:39 +0300 Subject: [PATCH 3/3] Fixed bug in plex webhook push sync. --- src/Commands/State/PushCommand.php | 17 +++++++++++------ src/Libs/Servers/JellyfinServer.php | 11 +++++++---- src/Libs/Servers/PlexServer.php | 16 +++++++++------- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/src/Commands/State/PushCommand.php b/src/Commands/State/PushCommand.php index 95b193b3..dca99c94 100644 --- a/src/Commands/State/PushCommand.php +++ b/src/Commands/State/PushCommand.php @@ -83,7 +83,7 @@ class PushCommand extends Command protected function process(InputInterface $input, OutputInterface $output): int { if (!$this->cache->has('queue')) { - $output->writeln('No items in the queue.', OutputInterface::VERBOSITY_DEBUG); + $output->writeln('No items in the queue.', OutputInterface::VERBOSITY_VERY_VERBOSE); return self::SUCCESS; } @@ -103,7 +103,7 @@ class PushCommand extends Command if (empty($entities)) { $this->cache->delete('queue'); - $output->writeln('No items in the queued.', OutputInterface::VERBOSITY_DEBUG); + $output->writeln('No items in the queue.', 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; } diff --git a/src/Libs/Servers/JellyfinServer.php b/src/Libs/Servers/JellyfinServer.php index 114583d2..15c5f8b2 100644 --- a/src/Libs/Servers/JellyfinServer.php +++ b/src/Libs/Servers/JellyfinServer.php @@ -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; } diff --git a/src/Libs/Servers/PlexServer.php b/src/Libs/Servers/PlexServer.php index df64e2a7..4f7dd89b 100644 --- a/src/Libs/Servers/PlexServer.php +++ b/src/Libs/Servers/PlexServer.php @@ -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], ] ]) );