From 5bf32293b8f8c2305d467345e71db08fb2fcccff Mon Sep 17 00:00:00 2001 From: "Abdulmhsen B. A. A" Date: Thu, 5 May 2022 22:56:38 +0300 Subject: [PATCH 1/3] Added sort option for db:list --- src/Commands/Database/ListCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Commands/Database/ListCommand.php b/src/Commands/Database/ListCommand.php index 900a124f..98f7a6a2 100644 --- a/src/Commands/Database/ListCommand.php +++ b/src/Commands/Database/ListCommand.php @@ -45,6 +45,7 @@ final class ListCommand extends Command ->addOption('season', null, InputOption::VALUE_REQUIRED, 'Select season number') ->addOption('episode', null, InputOption::VALUE_REQUIRED, 'Select episode number') ->addOption('id', null, InputOption::VALUE_REQUIRED, 'Select db record number') + ->addOption('sort', null, InputOption::VALUE_REQUIRED, 'sort order by [id, updated]', 'updated') ->setDescription('List Database entries.'); foreach (array_keys(Guid::SUPPORTED) as $guid) { @@ -138,7 +139,8 @@ final class ListCommand extends Command $sql .= 'WHERE ' . implode(' AND ', $where); } - $sql .= " ORDER BY updated DESC LIMIT :limit"; + $sort = $input->getOption('sort') === 'id' ? 'id' : 'updated'; + $sql .= " ORDER BY {$sort} DESC LIMIT :limit"; $stmt = $this->pdo->prepare($sql); $stmt->execute($params); From 0c23282b8dfcba02f684b42fdedb95a38f854acd Mon Sep 17 00:00:00 2001 From: "Abdulmhsen B. A. A" Date: Thu, 5 May 2022 22:58:11 +0300 Subject: [PATCH 2/3] Updated to include missing fields in emby default response. --- src/Libs/Servers/JellyfinServer.php | 9 ++++----- src/Libs/Servers/PlexServer.php | 5 +---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/Libs/Servers/JellyfinServer.php b/src/Libs/Servers/JellyfinServer.php index 128e121a..a6c03f86 100644 --- a/src/Libs/Servers/JellyfinServer.php +++ b/src/Libs/Servers/JellyfinServer.php @@ -582,6 +582,7 @@ class JellyfinServer implements ServerInterface 'enableUserData' => 'false', 'enableImages' => 'false', 'Fields' => 'ProviderIds,DateCreated,OriginalTitle', + 'ExcludeLocationTypes' => 'Virtual', ] ) ); @@ -648,7 +649,8 @@ class JellyfinServer implements ServerInterface 'enableUserData' => 'true', 'enableImages' => 'false', 'includeItemTypes' => 'Movie,Episode', - 'Fields' => 'ProviderIds,DateCreated,OriginalTitle,SeasonUserData,DateLastSaved', + 'Fields' => 'ProviderIds,DateCreated,OriginalTitle,SeasonUserData,DateLastSaved,PremiereDate,ProductionYear', + 'ExcludeLocationTypes' => 'Virtual', ] ) ); @@ -1554,10 +1556,7 @@ class JellyfinServer implements ServerInterface $message .= ' Most likely unmatched item.'; } - $this->logger->info($message, [ - 'guids' => empty($guids) ? 'None' : $guids, - 'rGuids' => $entity->hasRelativeGuid() ? $entity->getRelativeGuids() : 'None', - ]); + $this->logger->info($message, ['guids' => empty($guids) ? 'None' : $guids]); Data::increment($this->name, $type . '_ignored_no_supported_guid'); diff --git a/src/Libs/Servers/PlexServer.php b/src/Libs/Servers/PlexServer.php index 72a386f2..4f4f2ae4 100644 --- a/src/Libs/Servers/PlexServer.php +++ b/src/Libs/Servers/PlexServer.php @@ -1625,10 +1625,7 @@ class PlexServer implements ServerInterface $message .= ' Most likely unmatched item.'; } - $this->logger->info($message, [ - 'guids' => empty($item->Guid) ? 'None' : $item->Guid, - 'rGuids' => $entity->hasRelativeGuid() ? $entity->getRelativeGuids() : 'None', - ]); + $this->logger->info($message, ['guids' => empty($item->Guid) ? 'None' : $item->Guid]); Data::increment($this->name, $type . '_ignored_no_supported_guid'); return; From c8398a264c3cd53d586811b4daf444e4ddc7e703 Mon Sep 17 00:00:00 2001 From: "Abdulmhsen B. A. A" Date: Thu, 5 May 2022 22:58:36 +0300 Subject: [PATCH 3/3] sanity checks for episode number for Relative GUIDs. --- src/Libs/Entity/StateEntity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Libs/Entity/StateEntity.php b/src/Libs/Entity/StateEntity.php index cad70eeb..3fd4d352 100644 --- a/src/Libs/Entity/StateEntity.php +++ b/src/Libs/Entity/StateEntity.php @@ -147,7 +147,7 @@ final class StateEntity implements StateInterface $season = ag($this->meta, 'season', null); $episode = ag($this->meta, 'episode', null); - return !(null === $season || null === $episode || empty($parents)); + return !(null === $season || null === $episode || 0 === $episode || empty($parents)); } public function getRelativeGuids(): array @@ -156,7 +156,7 @@ final class StateEntity implements StateInterface $season = ag($this->meta, 'season', null); $episode = ag($this->meta, 'episode', null); - if (null === $season || null === $episode || count($parents) < 1) { + if (null === $season || null === $episode || 0 === $episode || empty($parents)) { return []; }