From 837629ec471efa6baaf33b3a4045d2a7f85cd603 Mon Sep 17 00:00:00 2001 From: Gauthier Date: Wed, 24 Sep 2025 07:24:12 +0200 Subject: [PATCH] fix(api): remove spaces from tags in *arr (#1913) This PR removes the spaces in the tags sent to *arr when the Tag Requests option is enabled. Spaces in tags are an unintended behavior and are not longer supported. fix #1897 --- server/subscriber/MediaRequestSubscriber.ts | 28 ++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/server/subscriber/MediaRequestSubscriber.ts b/server/subscriber/MediaRequestSubscriber.ts index 530b3a5a2..52c348264 100644 --- a/server/subscriber/MediaRequestSubscriber.ts +++ b/server/subscriber/MediaRequestSubscriber.ts @@ -292,9 +292,17 @@ export class MediaRequestSubscriber } if (radarrSettings.tagRequests) { - let userTag = (await radarr.getTags()).find((v) => + const radarrTags = await radarr.getTags(); + // old tags had space around the hyphen + let userTag = radarrTags.find((v) => v.label.startsWith(entity.requestedBy.id + ' - ') ); + // new tags do not have spaces around the hyphen, since spaces are not allowed anymore + if (!userTag) { + userTag = radarrTags.find((v) => + v.label.startsWith(entity.requestedBy.id + '-') + ); + } if (!userTag) { logger.info(`Requester has no active tag. Creating new`, { label: 'Media Request', @@ -302,11 +310,11 @@ export class MediaRequestSubscriber mediaId: entity.media.id, userId: entity.requestedBy.id, newTag: - entity.requestedBy.id + ' - ' + entity.requestedBy.displayName, + entity.requestedBy.id + '-' + entity.requestedBy.displayName, }); userTag = await radarr.createTag({ label: - entity.requestedBy.id + ' - ' + entity.requestedBy.displayName, + entity.requestedBy.id + '-' + entity.requestedBy.displayName, }); } if (userTag.id) { @@ -601,9 +609,17 @@ export class MediaRequestSubscriber } if (sonarrSettings.tagRequests) { - let userTag = (await sonarr.getTags()).find((v) => + const sonarrTags = await sonarr.getTags(); + // old tags had space around the hyphen + let userTag = sonarrTags.find((v) => v.label.startsWith(entity.requestedBy.id + ' - ') ); + // new tags do not have spaces around the hyphen, since spaces are not allowed anymore + if (!userTag) { + userTag = sonarrTags.find((v) => + v.label.startsWith(entity.requestedBy.id + '-') + ); + } if (!userTag) { logger.info(`Requester has no active tag. Creating new`, { label: 'Media Request', @@ -611,11 +627,11 @@ export class MediaRequestSubscriber mediaId: entity.media.id, userId: entity.requestedBy.id, newTag: - entity.requestedBy.id + ' - ' + entity.requestedBy.displayName, + entity.requestedBy.id + '-' + entity.requestedBy.displayName, }); userTag = await sonarr.createTag({ label: - entity.requestedBy.id + ' - ' + entity.requestedBy.displayName, + entity.requestedBy.id + '-' + entity.requestedBy.displayName, }); } if (userTag.id) {