From 66c1af0555e4376bce2091abf38b30370c70f7d4 Mon Sep 17 00:00:00 2001 From: Qstick Date: Thu, 18 Aug 2022 22:37:15 -0500 Subject: [PATCH] New: (API) Get Collection by TmdbId --- .../Collections/CollectionController.cs | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Radarr.Api.V3/Collections/CollectionController.cs b/src/Radarr.Api.V3/Collections/CollectionController.cs index f1438450bd..8e08067d4f 100644 --- a/src/Radarr.Api.V3/Collections/CollectionController.cs +++ b/src/Radarr.Api.V3/Collections/CollectionController.cs @@ -53,9 +53,25 @@ protected override CollectionResource GetResourceById(int id) } [HttpGet] - public List GetCollections() + public List GetCollections(int? tmdbId) { - return MapToResource(_collectionService.GetAllCollections()).ToList(); + var collectionResources = new List(); + + if (tmdbId.HasValue) + { + var collection = _collectionService.FindByTmdbId(tmdbId.Value); + + if (collection != null) + { + collectionResources.AddIfNotNull(MapToResource(collection)); + } + } + else + { + collectionResources = MapToResource(_collectionService.GetAllCollections()).ToList(); + } + + return collectionResources; } [RestPutById]