From 09a1e414d4f8931e9db0d7b77c750388e1e751e0 Mon Sep 17 00:00:00 2001 From: Jess Latimer Date: Sat, 27 May 2023 15:55:47 -0700 Subject: [PATCH] mis tagging bug fixed --- package.json | 2 +- src/index.ts | 29 +++++++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index a90fb36..c270734 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "plex-requester-collections", - "version": "1.1.5", + "version": "1.2.0", "description": "Node app to automatically create Plex Collections for content requested by users in Overseerr.", "main": "dist/index.js", "scripts": { diff --git a/src/index.ts b/src/index.ts index 5ea06af..a811c4e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -149,6 +149,31 @@ const app = async function () { } // We found a request else { + // Remove not requested tag in case it was added before. + await PlexAPI.removeLabelFromItem( + sectionId, + sectionTypeCode, + mediaId, + TAG_NOT_REQUESTED + ); + + // Handle Radarr/Sonarr if applicable. + if (radarrSonarrItem && sectionType === "movie") { + // Remove not requested tag in case it was added before. + radarrSonarrItem = await RadarrAPI.removeTagFromMediaItem( + radarrSonarrItem.id, + TAG_NOT_REQUESTED, + radarrSonarrItem + ); + } else if (radarrSonarrItem && sectionType === "show") { + // Remove not requested tag in case it was added before. + radarrSonarrItem = await SonarrAPI.removeTagFromMediaItem( + radarrSonarrItem.id, + TAG_NOT_REQUESTED, + radarrSonarrItem + ); + } + // Init some values we're going to need. plexUsername = request?.requestedBy?.plexUsername; const displayName = request?.requestedBy?.displayName; @@ -172,14 +197,14 @@ const app = async function () { // Tag the media item with requester username. radarrSonarrItem = await RadarrAPI.addTagToMediaItem( radarrSonarrItem.id, - TAG_NOT_REQUESTED, + requesterTagValue, radarrSonarrItem ); } else if (radarrSonarrItem && sectionType === "show") { // Tag the media item with requester username. radarrSonarrItem = await SonarrAPI.addTagToMediaItem( radarrSonarrItem.id, - TAG_NOT_REQUESTED, + requesterTagValue, radarrSonarrItem ); }