2024-02-22 14:01:49 -05:00
<!DOCTYPE html>
< html lang = "en" dir = "auto" >
2024-02-22 14:42:02 -05:00
< head > < script src = "/livereload.js?mindelay=10&v=2&port=1313&path=livereload" data-no-instant defer > < / script > < meta charset = "utf-8" >
2024-02-22 14:01:49 -05:00
< meta http-equiv = "X-UA-Compatible" content = "IE=edge" >
< meta name = "viewport" content = "width=device-width, initial-scale=1, shrink-to-fit=no" >
< meta name = "robots" content = "index, follow" >
< title > How To Automate Jellyfin Issue Handling | Mafyuh' s Blog< / title >
< meta name = "keywords" content = "" >
< meta name = "description" content = "I wanted a way to automate when users tell me a video on my Jellyfin server has an issue . After alot of trial and error , ChatGPT , Bard and I came up with this automation .
Requirements My only requirements when making this was that it was free and self-hostable. Not even any NPM extensions are required in AP. Actual Software requirements are:
Sonarr Radarr Overseerr/Jellyseerr Optional
SMTP server or ability to send SMTP messages (can also use discord) ActivePieces or any other automation platform that supports TS.">
< meta name = "author" content = "Mafyuh" >
2024-02-22 14:42:02 -05:00
< link rel = "canonical" href = "http://localhost:1313/post/how-to-automate-jellyfin-issue-handling/" >
2024-02-22 14:01:49 -05:00
< link crossorigin = "anonymous" href = "/assets/css/stylesheet.b609c58d5c11bb90b1a54e04005d74ad1ddf22165eb79f5533967e57df9c3b50.css" integrity = "sha256-tgnFjVwRu5CxpU4EAF10rR3fIhZet59VM5Z+V9+cO1A=" rel = "preload stylesheet" as = "style" >
2024-02-22 14:42:02 -05:00
< link rel = "icon" href = "http://localhost:1313/assets/favicon/favicon.svg" >
< link rel = "icon" type = "image/png" sizes = "16x16" href = "http://localhost:1313/assets/favicon/favicon.svg" >
< link rel = "icon" type = "image/png" sizes = "32x32" href = "http://localhost:1313/assets/favicon/favicon.svg" >
< link rel = "apple-touch-icon" href = "http://localhost:1313/apple-touch-icon.png" >
< link rel = "mask-icon" href = "http://localhost:1313/safari-pinned-tab.svg" >
2024-02-22 14:01:49 -05:00
< meta name = "theme-color" content = "#2e2e33" >
< meta name = "msapplication-TileColor" content = "#2e2e33" >
2024-02-22 14:42:02 -05:00
< link rel = "alternate" hreflang = "en" href = "http://localhost:1313/post/how-to-automate-jellyfin-issue-handling/" >
2024-02-22 14:01:49 -05:00
< noscript >
< style >
#theme-toggle,
.top-link {
display: none;
}
< / style >
< style >
@media (prefers-color-scheme: dark) {
:root {
--theme: rgb(29, 30, 32);
--entry: rgb(46, 46, 51);
--primary: rgb(218, 218, 219);
--secondary: rgb(155, 156, 157);
--tertiary: rgb(65, 66, 68);
--content: rgb(196, 196, 197);
--code-block-bg: rgb(46, 46, 51);
--code-bg: rgb(55, 56, 62);
--border: rgb(51, 51, 51);
}
.list {
background: var(--theme);
}
.list:not(.dark)::-webkit-scrollbar-track {
background: 0 0;
}
.list:not(.dark)::-webkit-scrollbar-thumb {
border-color: var(--theme);
}
}
< / style >
< / noscript > < meta property = "og:title" content = "How To Automate Jellyfin Issue Handling" / >
< meta property = "og:description" content = "I wanted a way to automate when users tell me a video on my Jellyfin server has an issue . After alot of trial and error , ChatGPT , Bard and I came up with this automation .
Requirements My only requirements when making this was that it was free and self-hostable. Not even any NPM extensions are required in AP. Actual Software requirements are:
Sonarr Radarr Overseerr/Jellyseerr Optional
SMTP server or ability to send SMTP messages (can also use discord) ActivePieces or any other automation platform that supports TS." />
< meta property = "og:type" content = "article" / >
2024-02-22 14:42:02 -05:00
< meta property = "og:url" content = "http://localhost:1313/post/how-to-automate-jellyfin-issue-handling/" / > < meta property = "article:section" content = "post" / >
2024-02-22 14:01:49 -05:00
< meta property = "article:published_time" content = "2023-11-11T16:20:00+00:00" / >
< meta property = "article:modified_time" content = "2023-11-11T16:20:00+00:00" / > < meta property = "og:site_name" content = "Mafyuh's Blog" / >
< meta name = "twitter:card" content = "summary" / >
< meta name = "twitter:title" content = "How To Automate Jellyfin Issue Handling" / >
< meta name = "twitter:description" content = "I wanted a way to automate when users tell me a video on my Jellyfin server has an issue . After alot of trial and error , ChatGPT , Bard and I came up with this automation .
Requirements My only requirements when making this was that it was free and self-hostable. Not even any NPM extensions are required in AP. Actual Software requirements are:
Sonarr Radarr Overseerr/Jellyseerr Optional
SMTP server or ability to send SMTP messages (can also use discord) ActivePieces or any other automation platform that supports TS."/>
< script type = "application/ld+json" >
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1 ,
"name": "Posts",
2024-02-22 14:42:02 -05:00
"item": "http://localhost:1313/post/"
2024-02-22 14:01:49 -05:00
},
{
"@type": "ListItem",
"position": 2 ,
"name": "How To Automate Jellyfin Issue Handling",
2024-02-22 14:42:02 -05:00
"item": "http://localhost:1313/post/how-to-automate-jellyfin-issue-handling/"
2024-02-22 14:01:49 -05:00
}
]
}
< / script >
< script type = "application/ld+json" >
{
"@context": "https://schema.org",
"@type": "BlogPosting",
"headline": "How To Automate Jellyfin Issue Handling",
"name": "How To Automate Jellyfin Issue Handling",
"description": "I wanted a way to automate when users tell me a video on my Jellyfin server has an issue. After alot of trial and error, ChatGPT, Bard and I came up with this automation.\nRequirements My only requirements when making this was that it was free and self-hostable. Not even any NPM extensions are required in AP. Actual Software requirements are:\nSonarr Radarr Overseerr/Jellyseerr Optional\nSMTP server or ability to send SMTP messages (can also use discord) ActivePieces or any other automation platform that supports TS.",
"keywords": [
],
"articleBody": "I wanted a way to automate when users tell me a video on my Jellyfin server has an issue. After alot of trial and error, ChatGPT, Bard and I came up with this automation.\nRequirements My only requirements when making this was that it was free and self-hostable. Not even any NPM extensions are required in AP. Actual Software requirements are:\nSonarr Radarr Overseerr/Jellyseerr Optional\nSMTP server or ability to send SMTP messages (can also use discord) ActivePieces or any other automation platform that supports TS. (Zapier, n8n, etc) Here’ s a great AP setup and how-to video:\nNote: I didn’ t do any of the ngrok stuff. I just have Nginx Proxy manager setup with a wildcard certificate. Then just give a domain name and point and its ip:8080. No special Nginx config needed. Make sure you set AP_FRONTEND_URL in .env\nThis blog post is rather long, if you prefer to see the code on git you can find all this code here.\nHow it Works Whenever a user Reports an Issue in Jellyseerr, a webhook is sent to activepieces (AP) with the Issue data, this triggers the automation to mark as failed, delete file, re-search, refresh Jellyfin Libraries and Resolve the original issue with comment. There is an optional feature to approve or deny the automation.\nWorks across Radarr and Sonarr, as the issue reported can be either Movie or TV show.\nOnly caveat is if the issue is an entire Season , we just mark the issue as resolved and leave a comment saying to submit an issue for each episode individually\nWorks on my Jellyfin, Jellyseer, Radarr and Sonarr setup. I dont use Plex but all you would have to change is the Jellyfin Refresh Library Request to match Plex’ s equivalent.\nHere is a pic of the full automation.\nEverything of value is logged to the console so check there for errors. Lets start breaking it down.\n#1 Jellyseer Issue Reported First thing is create a flow in AP, select a trigger, and search for webhook. This will give you the webhook URL for Jellyseerr. Next, in Jellyseerr, under Settings - Users - Default Permissions make sure Report Issues is checked and save changes. Then under Settings - Notifications - Webhook make a webhook notification, with the URL from AP, and just enabling Issue Reported and Issue Reopened. This should look as follows (dont worry about my payload showing mediaId, this has since been deleted)\nHere is my full JSON payload just in case:\n{ \"notification_type\": \"{{notification_type}}\", \"event\": \"{{event}}\", \"subject\": \"{{subject}}\", \"message\": \"{{message}}\", \"image\": \"{{image}}\", \"{{media}}\": { \"media_type\": \"{{media_type}}\", \"tmdbId\": \"{{media_tmdbid}}\", \"tvdbId\": \"{{media_tvdbid}}\", \"status\": \"{{media_status}}\", \"status4k\": \"{{media_status4k}}\" }, \"{{request}}\": { \"request_id\": \"{{request_id}}\", \"requestedBy_email\": \"{{requestedBy_email}}\", \"requestedBy_username\": \"{{requestedBy_username}}\", \"requestedBy_avatar\": \"{{requestedBy_avatar}}\", \"requestedBy_settings_discordId\": \"{{requestedBy_settings_discordId}}\", \"requestedBy_settings_telegramChatId\": \"{{requestedBy_settings_telegramChatId}}\" }, \"{{issue}}\": { \"issue_id\": \"{{issue_id}}\", \"issue_type\": \"{{issue_type}}\", \"issue_status\": \"{{issue_status}}\", \"reportedBy_email\": \"{{reportedBy_email}}\", \"reportedBy_username\": \"{{reportedBy_username}}\", \"reportedBy_avatar\": \"{{reportedBy_avatar}}\", \"reportedBy_settings_discordId\": \"{{reportedBy_settings_discordId}}\", \"reportedBy_settings_telegramChatId\": \"{{reportedBy_settings_telegramChatId}}\" }, \"{{comment}}\": { \"comment_message\": \"{{comment_message}}\", \"commentedBy_email\": \"{{commentedBy_email}}\", \"commentedBy_username\": \"{{commentedBy_username}}\", \"commentedBy_avatar\": \"{{commentedBy_avatar}}\", \"commentedBy_settings_discordId\": \"{{commentedBy_settings_discordId}}\", \"commentedBy_settings_telegramChatId\": \"{{commentedBy_settings_telegramChatId}}\" }, \"{{extra}}\": [] } You should be able to Report an issue on a random movie in Jellyseerr and then go to the webho
"wordCount" : "3952",
"inLanguage": "en",
"datePublished": "2023-11-11T16:20:00Z",
"dateModified": "2023-11-11T16:20:00Z",
"author":{
"@type": "Person",
"name": "Mafyuh"
},
"mainEntityOfPage": {
"@type": "WebPage",
2024-02-22 14:42:02 -05:00
"@id": "http://localhost:1313/post/how-to-automate-jellyfin-issue-handling/"
2024-02-22 14:01:49 -05:00
},
"publisher": {
"@type": "Organization",
"name": "Mafyuh's Blog",
"logo": {
"@type": "ImageObject",
2024-02-22 14:42:02 -05:00
"url": "http://localhost:1313/assets/favicon/favicon.svg"
2024-02-22 14:01:49 -05:00
}
}
}
< / script >
< / head >
< body class = "" id = "top" >
< script >
if (localStorage.getItem("pref-theme") === "dark") {
document.body.classList.add('dark');
} else if (localStorage.getItem("pref-theme") === "light") {
document.body.classList.remove('dark')
} else if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.body.classList.add('dark');
}
< / script >
< header class = "header" >
< nav class = "nav" >
< div class = "logo" >
2024-02-22 14:42:02 -05:00
< a href = "http://localhost:1313/" accesskey = "h" title = "Mafyuh's Blog (Alt + H)" >
< img src = "http://localhost:1313/assets/favicon/favicon.svg" alt = "" aria-label = "logo"
2024-02-22 14:01:49 -05:00
height="35">Mafyuh' s Blog< / a >
< div class = "logo-switches" >
< button id = "theme-toggle" accesskey = "t" title = "(Alt + T)" >
< svg id = "moon" xmlns = "http://www.w3.org/2000/svg" width = "24" height = "18" viewBox = "0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round">
< path d = "M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z" > < / path >
< / svg >
< svg id = "sun" xmlns = "http://www.w3.org/2000/svg" width = "24" height = "18" viewBox = "0 0 24 24"
fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"
stroke-linejoin="round">
< circle cx = "12" cy = "12" r = "5" > < / circle >
< line x1 = "12" y1 = "1" x2 = "12" y2 = "3" > < / line >
< line x1 = "12" y1 = "21" x2 = "12" y2 = "23" > < / line >
< line x1 = "4.22" y1 = "4.22" x2 = "5.64" y2 = "5.64" > < / line >
< line x1 = "18.36" y1 = "18.36" x2 = "19.78" y2 = "19.78" > < / line >
< line x1 = "1" y1 = "12" x2 = "3" y2 = "12" > < / line >
< line x1 = "21" y1 = "12" x2 = "23" y2 = "12" > < / line >
< line x1 = "4.22" y1 = "19.78" x2 = "5.64" y2 = "18.36" > < / line >
< line x1 = "18.36" y1 = "5.64" x2 = "19.78" y2 = "4.22" > < / line >
< / svg >
< / button >
< ul class = "lang-switch" > < li > |< / li >
< / ul >
< / div >
< / div >
< ul id = "menu" >
< li >
2024-02-22 14:42:02 -05:00
< a href = "http://localhost:1313/guides/" title = "Guides" >
2024-02-22 14:01:49 -05:00
< span > Guides< / span >
< / a >
< / li >
< li >
2024-02-22 14:42:02 -05:00
< a href = "http://localhost:1313/tags/" title = "Tags" >
2024-02-22 14:01:49 -05:00
< span > Tags< / span >
< / a >
< / li >
< / ul >
< / nav >
< / header >
< main class = "main" >
< article class = "post-single" >
< header class = "post-header" >
2024-02-22 14:42:02 -05:00
< div class = "breadcrumbs" > < a href = "http://localhost:1313/" > Home< / a > » < a href = "http://localhost:1313/post/" > Posts< / a > < / div >
2024-02-22 14:01:49 -05:00
< h1 class = "post-title entry-hint-parent" >
How To Automate Jellyfin Issue Handling
< / h1 >
< div class = "post-meta" > < span title = '2023-11-11 16:20:00 +0000 UTC' > November 11, 2023< / span > · 19 min · 3952 words · Mafyuh
< / div >
< / header > < div class = "toc" >
< details >
< summary accesskey = "c" title = "(Alt + C)" >
< span class = "details" > Table of Contents< / span >
< / summary >
< div class = "inner" > < nav id = "TableOfContents" >
< ul >
< li > < a href = "#requirements" > Requirements< / a > < / li >
< li > < a href = "#how-it-works" > How it Works< / a > < / li >
< li > < a href = "#1-jellyseer-issue-reported" > #1 Jellyseer Issue Reported< / a > < / li >
< li > < a href = "#optional-2-create-approval-links" > (Optional) #2 Create Approval Links< / a > < / li >
< li > < a href = "#optional-3-send-email" > (Optional) #3 Send Email< / a > < / li >
< li > < a href = "#optional-4-wait-for-approval" > (Optional) #4 Wait for Approval< / a > < / li >
< li > < a href = "#5-radarrsonarr-branch" > #5 Radarr/Sonarr Branch< / a > < / li >
< li > < a href = "#6-radarr-mark-as-failed" > #6 Radarr Mark As Failed< / a > < / li >
< li > < a href = "#7-delay-5-seconds" > #7 Delay 5 seconds< / a > < / li >
< li > < a href = "#8-delete-movie-file" > #8 Delete Movie File< / a > < / li >
< li > < a href = "#9-delay-5-seconds" > #9 Delay 5 seconds< / a > < / li >
< li > < a href = "#10-search-in-radarr" > #10 Search in Radarr< / a > < / li >
< li > < a href = "#11-delay-4-minutes" > #11 Delay 4 minutes< / a > < / li >
< li > < a href = "#12-scan-jf-libraries" > #12 Scan JF Libraries< / a > < / li >
< li > < a href = "#13-add-commentresolve-issue" > #13 Add Comment/Resolve Issue< / a > < / li >
< li > < a href = "#14-branch-episodes-and-seasons" > #14 Branch Episodes and Seasons< / a > < / li >
< li > < a href = "#15-add-commentresolve-issue" > #15 Add Comment/Resolve Issue< / a > < / li >
< li > < a href = "#16-mark-as-failed-sonarr" > #16 Mark as Failed Sonarr< / a > < / li >
< li > < a href = "#17-delete-file-sonarr" > #17 Delete File Sonarr< / a > < / li >
< li > < a href = "#18-re-search-in-sonarr" > #18 Re-search in Sonarr< / a > < / li >
< li > < a href = "#19-delay-for-4-minutes" > #19 Delay for 4 Minutes< / a > < / li >
< li > < a href = "#20-add-commentresolve-issue" > #20 Add Comment/Resolve Issue< / a > < / li >
< li > < a href = "#21-same-as-12" > #21 Same as #12< / a > < / li >
< li > < a href = "#conclusion" > Conclusion< / a > < / li >
< / ul >
< / nav >
< / div >
< / details >
< / div >
< div class = "post-content" > < p > I wanted a way to automate when users tell me a video on my Jellyfin server has an issue. After alot of trial and error, ChatGPT, Bard and I came up with this automation.< / p >
< h2 id = "requirements" > Requirements< a hidden class = "anchor" aria-hidden = "true" href = "#requirements" > #< / a > < / h2 >
< p > My only requirements when making this was that it was free and self-hostable. Not even any NPM extensions are required in AP.
Actual Software requirements are:< / p >
< ol >
< li > Sonarr< / li >
< li > Radarr< / li >
< li > Overseerr/Jellyseerr< / li >
< / ol >
< p > Optional< / p >
< ol >
< li > SMTP server or ability to send SMTP messages (can also use discord)< / li >
< li > ActivePieces or any other automation platform that supports TS. (Zapier, n8n, etc)< / li >
< / ol >
< p > Here’ s a great AP setup and how-to video:< / p >
< div style = "position: relative; padding-bottom: 56.25%; height: 0; overflow: hidden;" >
< iframe src = "https://www.youtube.com/embed/kVaCDc2CXik?si=geKXwgRjU6onDyjS" style = "position: absolute; top: 0; left: 0; width: 100%; height: 100%; border:0;" allowfullscreen title = "YouTube Video" > < / iframe >
< / div >
< p > Note: I didn’ t do any of the ngrok stuff. I just have Nginx Proxy manager setup with a wildcard certificate. Then just give a domain name and point and its ip:8080. No special Nginx config needed. Make sure you set AP_FRONTEND_URL in .env< / p >
< p > This blog post is rather long, if you prefer to see the code on git you can find all this code < a href = "https://git.mafyuh.dev/mafyuh/ActivePieces" > here< / a > .< / p >
< h2 id = "how-it-works" > How it Works< a hidden class = "anchor" aria-hidden = "true" href = "#how-it-works" > #< / a > < / h2 >
< p > Whenever a user Reports an Issue in Jellyseerr, a webhook is sent to activepieces (AP) with the Issue data, this triggers the automation to mark as failed, delete file, re-search, refresh Jellyfin Libraries and Resolve the original issue with comment. There is an optional feature to approve or deny the automation.< / p >
< p > Works across Radarr and Sonarr, as the issue reported can be either Movie or TV show.< / p >
< p > Only caveat is if the issue is an entire Season , we just mark the issue as resolved and leave a comment saying to submit an issue for each episode individually< / p >
< p > Works on my Jellyfin, Jellyseer, Radarr and Sonarr setup. I dont use Plex but all you would have to change is the Jellyfin Refresh Library Request to match Plex’ s equivalent.< / p >
< p > Here is a pic of the full automation.< / p >
< p > < img loading = "lazy" src = "/assets/img/automation.png" alt = "Automation Image" / >
< / p >
< p > Everything of value is logged to the console so check there for errors. Lets start breaking it down.< / p >
< h2 id = "1-jellyseer-issue-reported" > #1 Jellyseer Issue Reported< a hidden class = "anchor" aria-hidden = "true" href = "#1-jellyseer-issue-reported" > #< / a > < / h2 >
< p > First thing is create a flow in AP, select a trigger, and search for webhook. This will give you the webhook URL for Jellyseerr.
Next, in Jellyseerr, under < strong > Settings - Users - Default Permissions< / strong > make sure < strong > Report Issues< / strong > is checked and save changes.
Then under < strong > Settings - Notifications - Webhook< / strong > make a webhook notification, with the URL from AP, and just enabling < strong > Issue Reported< / strong > and < strong > Issue Reopened< / strong > .
This should look as follows (dont worry about my payload showing mediaId, this has since been deleted)< / p >
< p > < img loading = "lazy" src = "/assets/img/seer.png" alt = "Jellyseer Image" / >
< / p >
< p > Here is my full JSON payload just in case:< / p >
< div class = "highlight" > < pre tabindex = "0" class = "chroma" > < code class = "language-json" data-lang = "json" > < span class = "line" > < span class = "cl" > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " notification_type" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{notification_type}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " event" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{event}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " subject" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{subject}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " message" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{message}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " image" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{image}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " {{media}}" < / span > < span class = "p" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " media_type" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{media_type}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " tmdbId" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{media_tmdbid}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " tvdbId" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{media_tvdbid}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " status" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{media_status}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " status4k" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{media_status4k}}" < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " {{request}}" < / span > < span class = "p" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " request_id" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{request_id}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " requestedBy_email" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{requestedBy_email}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " requestedBy_username" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{requestedBy_username}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " requestedBy_avatar" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{requestedBy_avatar}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " requestedBy_settings_discordId" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{requestedBy_settings_discordId}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " requestedBy_settings_telegramChatId" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{requestedBy_settings_telegramChatId}}" < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " {{issue}}" < / span > < span class = "p" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " issue_id" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{issue_id}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " issue_type" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{issue_type}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " issue_status" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{issue_status}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " reportedBy_email" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{reportedBy_email}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " reportedBy_username" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{reportedBy_username}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " reportedBy_avatar" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{reportedBy_avatar}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " reportedBy_settings_discordId" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{reportedBy_settings_discordId}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " reportedBy_settings_telegramChatId" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{reportedBy_settings_telegramChatId}}" < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " {{comment}}" < / span > < span class = "p" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " comment_message" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{comment_message}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " commentedBy_email" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{commentedBy_email}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " commentedBy_username" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{commentedBy_username}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " commentedBy_avatar" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{commentedBy_avatar}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " commentedBy_settings_discordId" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{commentedBy_settings_discordId}}" < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " commentedBy_settings_telegramChatId" < / span > < span class = "p" > :< / span > < span class = "s2" > " {{commentedBy_settings_telegramChatId}}" < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > " {{extra}}" < / span > < span class = "p" > :< / span > < span class = "p" > []< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < / code > < / pre > < / div > < p > You should be able to Report an issue on a random movie in Jellyseerr and then go to the webhook trigger and choose Generate sample data, and you should be able to see the data from the request. I recommend doing this and creating an issue for an example movie, TV series( All Seasons) and a TV Series (1 Season)< / p >
< h2 id = "optional-2-create-approval-links" > (Optional) #2 Create Approval Links< a hidden class = "anchor" aria-hidden = "true" href = "#optional-2-create-approval-links" > #< / a > < / h2 >
< p > In AP add the next step and search Approval, then create approval links.< / p >
< h2 id = "optional-3-send-email" > (Optional) #3 Send Email< a hidden class = "anchor" aria-hidden = "true" href = "#optional-3-send-email" > #< / a > < / h2 >
< p > This is so I can either approve or deny the file from being deleted. Maybe it’ s a client issue and I know for a fact my file is good and I dont want deleted. Thus the links are sent to me along with the some data from the request, so I know what I am approving/denying.< / p >
< p > You can use the core SMTP feature but its limited to text. I wanted some more customizability so I chose Resend (supports html) and set up an acct there with one of my extra domains.< / p >
< p > You don’ t have to use email, you can use Discord, SMS, any generic http request or whatever you want. I just use email since I pay for my domains and pay Proton Mail for emails so might as well use em.< / p >
< p > Not gonna get too into this, I dont care too much about it atm, customize your email to your liking, but I’ ll post my somewhat working HTML body here. I literally just copied what Bard gave me, added in data from response and tested and said looks good enough, glitches on my mobile too.< / p >
< div class = "highlight" > < pre tabindex = "0" class = "chroma" > < code class = "language-html" data-lang = "html" > < span class = "line" > < span class = "cl" > < span class = "cp" > < !DOCTYPE html> < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > html< / span > < span class = "na" > lang< / span > < span class = "o" > =< / span > < span class = "s" > " en" < / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > head< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > meta< / span > < span class = "na" > charset< / span > < span class = "o" > =< / span > < span class = "s" > " UTF-8" < / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > meta< / span > < span class = "na" > name< / span > < span class = "o" > =< / span > < span class = "s" > " viewport" < / span > < span class = "na" > content< / span > < span class = "o" > =< / span > < span class = "s" > " width=device-width, initial-scale=1.0" < / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > title< / span > < span class = "p" > > < / span > Jellyseerr Issue Reported< span class = "p" > < /< / span > < span class = "nt" > title< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > style< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nt" > body< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > font-family< / span > < span class = "p" > :< / span > < span class = "kc" > sans-serif< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > margin< / span > < span class = "p" > :< / span > < span class = "mi" > 0< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > padding< / span > < span class = "p" > :< / span > < span class = "mi" > 0< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > background-color< / span > < span class = "p" > :< / span > < span class = "mh" > #222< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > color< / span > < span class = "p" > :< / span > < span class = "mh" > #fff< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > container< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > width< / span > < span class = "p" > :< / span > < span class = "mi" > 80< / span > < span class = "kt" > %< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > margin< / span > < span class = "p" > :< / span > < span class = "mi" > 0< / span > < span class = "kc" > auto< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > padding< / span > < span class = "p" > :< / span > < span class = "mi" > 20< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > background-color< / span > < span class = "p" > :< / span > < span class = "mh" > #333< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > border-radius< / span > < span class = "p" > :< / span > < span class = "mi" > 10< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > box-shadow< / span > < span class = "p" > :< / span > < span class = "mi" > 0< / span > < span class = "kt" > px< / span > < span class = "mi" > 2< / span > < span class = "kt" > px< / span > < span class = "mi" > 5< / span > < span class = "kt" > px< / span > < span class = "nb" > rgba< / span > < span class = "p" > (< / span > < span class = "mi" > 0< / span > < span class = "p" > ,< / span > < span class = "mi" > 0< / span > < span class = "p" > ,< / span > < span class = "mi" > 0< / span > < span class = "p" > ,< / span > < span class = "mf" > 0.1< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > header< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > display< / span > < span class = "p" > :< / span > < span class = "kc" > flex< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > justify-content< / span > < span class = "p" > :< / span > < span class = "kc" > space-between< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > align-items< / span > < span class = "p" > :< / span > < span class = "kc" > center< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > padding-bottom< / span > < span class = "p" > :< / span > < span class = "mi" > 20< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > border-bottom< / span > < span class = "p" > :< / span > < span class = "mi" > 1< / span > < span class = "kt" > px< / span > < span class = "kc" > solid< / span > < span class = "mh" > #555< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > header< / span > < span class = "nt" > h1< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > font-size< / span > < span class = "p" > :< / span > < span class = "mi" > 24< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > font-weight< / span > < span class = "p" > :< / span > < span class = "kc" > bold< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > margin< / span > < span class = "p" > :< / span > < span class = "mi" > 0< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > color< / span > < span class = "p" > :< / span > < span class = "mh" > #fff< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > header< / span > < span class = "nt" > img< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > width< / span > < span class = "p" > :< / span > < span class = "mi" > 50< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > height< / span > < span class = "p" > :< / span > < span class = "mi" > 50< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > border-radius< / span > < span class = "p" > :< / span > < span class = "mi" > 50< / span > < span class = "kt" > %< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > object-fit< / span > < span class = "p" > :< / span > < span class = "kc" > cover< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > content< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > margin< / span > < span class = "p" > :< / span > < span class = "mi" > 0< / span > < span class = "kc" > auto< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > text-align< / span > < span class = "p" > :< / span > < span class = "kc" > center< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > issue-subject< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > font-size< / span > < span class = "p" > :< / span > < span class = "mi" > 18< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > font-weight< / span > < span class = "p" > :< / span > < span class = "kc" > bold< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > margin-bottom< / span > < span class = "p" > :< / span > < span class = "mi" > 10< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > color< / span > < span class = "p" > :< / span > < span class = "mh" > #fff< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > issue-message< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > font-size< / span > < span class = "p" > :< / span > < span class = "mi" > 16< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > line-height< / span > < span class = "p" > :< / span > < span class = "mf" > 1.5< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > margin-bottom< / span > < span class = "p" > :< / span > < span class = "mi" > 20< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > color< / span > < span class = "p" > :< / span > < span class = "mh" > #ccc< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > issue-image< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > width< / span > < span class = "p" > :< / span > < span class = "mi" > 100< / span > < span class = "kt" > %< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > height< / span > < span class = "p" > :< / span > < span class = "kc" > auto< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > margin-bottom< / span > < span class = "p" > :< / span > < span class = "mi" > 20< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > buttons< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > display< / span > < span class = "p" > :< / span > < span class = "kc" > flex< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > justify-content< / span > < span class = "p" > :< / span > < span class = "kc" > space-between< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > button< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > background-color< / span > < span class = "p" > :< / span > < span class = "mh" > #007bff< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > color< / span > < span class = "p" > :< / span > < span class = "mh" > #fff< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > padding< / span > < span class = "p" > :< / span > < span class = "mi" > 10< / span > < span class = "kt" > px< / span > < span class = "mi" > 20< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > border-radius< / span > < span class = "p" > :< / span > < span class = "mi" > 5< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > cursor< / span > < span class = "p" > :< / span > < span class = "kc" > pointer< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > text-decoration< / span > < span class = "p" > :< / span > < span class = "kc" > none< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > button< / span > < span class = "p" > :< / span > < span class = "nd" > hover< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > background-color< / span > < span class = "p" > :< / span > < span class = "mh" > #0056b3< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > disapprove-button< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > background-color< / span > < span class = "p" > :< / span > < span class = "mh" > #dc3545< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > color< / span > < span class = "p" > :< / span > < span class = "mh" > #fff< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > padding< / span > < span class = "p" > :< / span > < span class = "mi" > 10< / span > < span class = "kt" > px< / span > < span class = "mi" > 20< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > border-radius< / span > < span class = "p" > :< / span > < span class = "mi" > 5< / span > < span class = "kt" > px< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > cursor< / span > < span class = "p" > :< / span > < span class = "kc" > pointer< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > text-decoration< / span > < span class = "p" > :< / span > < span class = "kc" > none< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > .< / span > < span class = "nc" > disapprove-button< / span > < span class = "p" > :< / span > < span class = "nd" > hover< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > background-color< / span > < span class = "p" > :< / span > < span class = "mh" > #bd2830< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < /< / span > < span class = "nt" > style< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < /< / span > < span class = "nt" > head< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > body< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > div< / span > < span class = "na" > class< / span > < span class = "o" > =< / span > < span class = "s" > " container" < / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > div< / span > < span class = "na" > class< / span > < span class = "o" > =< / span > < span class = "s" > " header" < / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > img< / span > < span class = "na" > src< / span > < span class = "o" > =< / span > < span class = "s" > " https://your-logo-url" < / span > < span class = "na" > alt< / span > < span class = "o" > =< / span > < span class = "s" > " Jellyseerr Logo" < / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > h1< / span > < span class = "p" > > < / span > Jellyseerr Issue Reported< span class = "p" > < /< / span > < span class = "nt" > h1< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < /< / span > < span class = "nt" > div< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > div< / span > < span class = "na" > class< / span > < span class = "o" > =< / span > < span class = "s" > " content" < / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > div< / span > < span class = "na" > class< / span > < span class = "o" > =< / span > < span class = "s" > " issue-subject" < / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > Jellyseerr Issue Reported
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < /< / span > < span class = "nt" > div< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > div< / span > < span class = "na" > class< / span > < span class = "o" > =< / span > < span class = "s" > " issue-message" < / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > This issue was submitted by 1. Jellyseerr Issue Reported body issue reportedBy_username.
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > br< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > The reason for the issue:1. Jellyseerr Issue Reported body message
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > br< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > Please review the issue and take appropriate action.
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > br< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > img< / span > < span class = "na" > src< / span > < span class = "o" > =< / span > < span class = "s" > " 1. Jellyseerr Issue Reported body image " < / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < /< / span > < span class = "nt" > div< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > div< / span > < span class = "na" > class< / span > < span class = "o" > =< / span > < span class = "s" > " buttons" < / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > a< / span > < span class = "na" > href< / span > < span class = "o" > =< / span > < span class = "s" > " 2. Create Approval Links approvalLink " < / span > < span class = "p" > > < < / span > < span class = "nt" > button< / span > < span class = "na" > class< / span > < span class = "o" > =< / span > < span class = "s" > " button" < / span > < span class = "p" > > < / span > Approve< span class = "p" > < /< / span > < span class = "nt" > button< / span > < span class = "p" > > < /< / span > < span class = "nt" > a< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < < / span > < span class = "nt" > a< / span > < span class = "na" > href< / span > < span class = "o" > =< / span > < span class = "s" > " 2. Create Approval Links disapprovalLink " < / span > < span class = "p" > > < < / span > < span class = "nt" > button< / span > < span class = "na" > class< / span > < span class = "o" > =< / span > < span class = "s" > " disapprove-button" < / span > < span class = "p" > > < / span > Deny< span class = "p" > < /< / span > < span class = "nt" > button< / span > < span class = "p" > > < /< / span > < span class = "nt" > a< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < /< / span > < span class = "nt" > div< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < /< / span > < span class = "nt" > div< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < /< / span > < span class = "nt" > div< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < /< / span > < span class = "nt" > body< / span > < span class = "p" > > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > < /< / span > < span class = "nt" > html< / span > < span class = "p" > > < / span >
< / span > < / span > < / code > < / pre > < / div > < p > And here’ s what an email looks like:< / p >
< p > < img loading = "lazy" src = "/assets/img/email.png" alt = "Email Look" / >
< / p >
< h2 id = "optional-4-wait-for-approval" > (Optional) #4 Wait for Approval< a hidden class = "anchor" aria-hidden = "true" href = "#optional-4-wait-for-approval" > #< / a > < / h2 >
< p > Pauses flow until I approve or deny.< / p >
< h2 id = "5-radarrsonarr-branch" > #5 Radarr/Sonarr Branch< a hidden class = "anchor" aria-hidden = "true" href = "#5-radarrsonarr-branch" > #< / a > < / h2 >
< p > As stated previously, I wanted this to work regardless if Movie or TV show. So using the core Branch feature we just say that if the media_type value from the issue contains the text movie, its true.< / p >
< p > < img loading = "lazy" src = "/assets/img/radarr-branch.png" alt = "Radarr AP Image" / >
< / p >
< h2 id = "6-radarr-mark-as-failed" > #6 Radarr Mark As Failed< a hidden class = "anchor" aria-hidden = "true" href = "#6-radarr-mark-as-failed" > #< / a > < / h2 >
< p > All I do here is the Code function with 1 input which is the whole body message of the request, this is assigned to inputs.issue in the code (CASE SENSITIVE)< / p >
< p > < img loading = "lazy" src = "/assets/img/radarr-mark-as-failed.png" alt = "Radarr AP Image" / >
< / p >
< p > Here is the code. Just replace api key and base url:< / p >
< div class = "highlight" > < pre tabindex = "0" class = "chroma" > < code class = "language-typescript" data-lang = "typescript" > < span class = "line" > < span class = "cl" > < span class = "kr" > export< / span > < span class = "kr" > const< / span > < span class = "nx" > code< / span > < span class = "o" > =< / span > < span class = "kr" > async< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > )< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > issueSubject< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > subject< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > movieNameRegex< / span > < span class = "o" > =< / span > < span class = "sr" > /(.*)\s\((\d{4})\)/< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > match< / span > < span class = "o" > =< / span > < span class = "nx" > movieNameRegex< / span > < span class = "p" > .< / span > < span class = "nx" > exec< / span > < span class = "p" > (< / span > < span class = "nx" > issueSubject< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > match< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > movieName< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 1< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > year< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 2< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tmdbId< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > media< / span > < span class = "p" > .< / span > < span class = "nx" > tmdbId< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Movie name: < / span > < span class = "si" > ${< / span > < span class = "nx" > movieName< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Year: < / span > < span class = "si" > ${< / span > < span class = "nx" > year< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `TMDB ID: < / span > < span class = "si" > ${< / span > < span class = "nx" > tmdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Define your Radarr API key and base URL
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > radarrApiKey< / span > < span class = "o" > =< / span > < span class = "s1" > ' your-api-key' < / span > < span class = "p" > ;< / span > < span class = "c1" > // Replace with your Radarr API key
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > radarrBaseUrl< / span > < span class = "o" > =< / span > < span class = "s1" > ' https://radarr.example.com/api/v3/' < / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Define a function to make API requests to Radarr
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > makeRadarrRequest< / span > < span class = "o" > =< / span > < span class = "kr" > async< / span > < span class = "p" > (< / span > < span class = "nx" > endpoint< / span > < span class = "p" > ,< / span > < span class = "nx" > method< / span > < span class = "o" > =< / span > < span class = "s1" > ' GET' < / span > < span class = "p" > )< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > apiUrl< / span > < span class = "o" > =< / span > < span class = "nx" > radarrBaseUrl< / span > < span class = "o" > +< / span > < span class = "nx" > endpoint< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Calling Radarr API: < / span > < span class = "si" > ${< / span > < span class = "nx" > apiUrl< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > response< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > apiUrl< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > radarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > response< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "k" > await< / span > < span class = "nx" > response< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "sb" > `Radarr API request failed: < / span > < span class = "si" > ${< / span > < span class = "nx" > response< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "kc" > null< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Use Radarr' s API to look up the movie by TMDB ID
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > radarrApiResponseData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > makeRadarrRequest< / span > < span class = "p" > (< / span > < span class = "sb" > `movie?tmdbId=< / span > < span class = "si" > ${< / span > < span class = "nx" > tmdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > radarrApiResponseData< / span > < span class = "o" > & & < / span > < span class = "nx" > radarrApiResponseData< / span > < span class = "p" > .< / span > < span class = "nx" > length< / span > < span class = "o" > > < / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > movieId< / span > < span class = "o" > =< / span > < span class = "nx" > radarrApiResponseData< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ].< / span > < span class = "nx" > id< / span > < span class = "p" > ;< / span > < span class = "c1" > // Get the Radarr ID of the first movie
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Radarr Movie ID:' < / span > < span class = "p" > ,< / span > < span class = "nx" > movieId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Use the Radarr movie ID to get the history of the movie
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > historyApiResponseData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > makeRadarrRequest< / span > < span class = "p" > (< / span > < span class = "sb" > `history/movie?movieId=< / span > < span class = "si" > ${< / span > < span class = "nx" > movieId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > historyApiResponseData< / span > < span class = "o" > & & < / span > < span class = "nx" > historyApiResponseData< / span > < span class = "p" > .< / span > < span class = "nx" > length< / span > < span class = "o" > > < / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > historyId< / span > < span class = "o" > =< / span > < span class = "nx" > historyApiResponseData< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ].< / span > < span class = "nx" > id< / span > < span class = "p" > ;< / span > < span class = "c1" > // Get the history ID
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' History ID:' < / span > < span class = "p" > ,< / span > < span class = "nx" > historyId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Use the history ID to mark the movie as failed
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > markFailedResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > makeRadarrRequest< / span > < span class = "p" > (< / span > < span class = "sb" > `history/failed/< / span > < span class = "si" > ${< / span > < span class = "nx" > historyId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ,< / span > < span class = "s1" > ' POST' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > markFailedResponse< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Movie successfully marked as failed.' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' Failed to mark movie as failed' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' No history found for movie ID:' < / span > < span class = "p" > ,< / span > < span class = "nx" > movieId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' No movies found for TMDB ID:' < / span > < span class = "p" > ,< / span > < span class = "nx" > tmdbId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < / code > < / pre > < / div > < h2 id = "7-delay-5-seconds" > #7 Delay 5 seconds< a hidden class = "anchor" aria-hidden = "true" href = "#7-delay-5-seconds" > #< / a > < / h2 >
< p > Give time to process.< / p >
< h2 id = "8-delete-movie-file" > #8 Delete Movie File< a hidden class = "anchor" aria-hidden = "true" href = "#8-delete-movie-file" > #< / a > < / h2 >
< p > I didn’ t want to delete the actual movie from Radarr, but just the file itself, thus alot of trial and error, but a working script.
All I do here is the Code function with 1 input which is the whole body message of the request, this is assigned to inputs.issue in the code< / p >
< div class = "highlight" > < pre tabindex = "0" class = "chroma" > < code class = "language-typescript" data-lang = "typescript" > < span class = "line" > < span class = "cl" > < span class = "kr" > export< / span > < span class = "kr" > const< / span > < span class = "nx" > code< / span > < span class = "o" > =< / span > < span class = "kr" > async< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > )< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > issueSubject< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > subject< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > movieNameRegex< / span > < span class = "o" > =< / span > < span class = "sr" > /(.*)\s\((\d{4})\)/< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > match< / span > < span class = "o" > =< / span > < span class = "nx" > movieNameRegex< / span > < span class = "p" > .< / span > < span class = "nx" > exec< / span > < span class = "p" > (< / span > < span class = "nx" > issueSubject< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > match< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > movieName< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 1< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > year< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 2< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tmdbId< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > media< / span > < span class = "p" > .< / span > < span class = "nx" > tmdbId< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Movie name: < / span > < span class = "si" > ${< / span > < span class = "nx" > movieName< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Year: < / span > < span class = "si" > ${< / span > < span class = "nx" > year< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `TMDB ID: < / span > < span class = "si" > ${< / span > < span class = "nx" > tmdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Define your Radarr API key
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > radarrApiKey< / span > < span class = "o" > =< / span > < span class = "s1" > ' your-api-key' < / span > < span class = "p" > ;< / span > < span class = "c1" > // Replace with your Radarr API key
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > radarrBaseUrl< / span > < span class = "o" > =< / span > < span class = "s1" > ' https://radarr.example.com/api/v3' < / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Use Radarr' s API to look up the movie by TMDB ID and get the Radarr ID
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > radarrApiUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > radarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /movie?tmdbId=< / span > < span class = "si" > ${< / span > < span class = "nx" > tmdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Calling Radarr API to look up the movie...' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > radarrApiResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > radarrApiUrl< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' GET' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > radarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > radarrApiResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Radarr API lookup successful.' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > radarrApiResponseData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > radarrApiResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > radarrApiResponseData< / span > < span class = "p" > .< / span > < span class = "nx" > length< / span > < span class = "o" > > < / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // If the response is an array, you should loop through the results
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "c1" > // and access the Radarr ID for each movie.
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "k" > for< / span > < span class = "p" > (< / span > < span class = "kr" > const< / span > < span class = "nx" > movie< / span > < span class = "k" > of< / span > < span class = "nx" > radarrApiResponseData< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > radarrMovieId< / span > < span class = "o" > =< / span > < span class = "nx" > movie< / span > < span class = "p" > .< / span > < span class = "nx" > movieFile< / span > < span class = "p" > .< / span > < span class = "nx" > id< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Radarr Movie ID:' < / span > < span class = "p" > ,< / span > < span class = "nx" > radarrMovieId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Use the Radarr movie ID to delete the corresponding movie file
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > deleteMovieFileUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > radarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /movieFile/< / span > < span class = "si" > ${< / span > < span class = "nx" > radarrMovieId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Calling Radarr API to delete movie file: < / span > < span class = "si" > ${< / span > < span class = "nx" > deleteMovieFileUrl< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > deleteMovieFileResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > deleteMovieFileUrl< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' DELETE' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > radarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > deleteMovieFileResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Movie file successfully deleted.`< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "sb" > `Failed to delete movie file: < / span > < span class = "si" > ${< / span > < span class = "nx" > deleteMovieFileResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' No movies found for TMDB ID:' < / span > < span class = "p" > ,< / span > < span class = "nx" > tmdbId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' Radarr API lookup failed:' < / span > < span class = "p" > ,< / span > < span class = "nx" > radarrApiResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < / code > < / pre > < / div > < h2 id = "9-delay-5-seconds" > #9 Delay 5 seconds< a hidden class = "anchor" aria-hidden = "true" href = "#9-delay-5-seconds" > #< / a > < / h2 >
< h2 id = "10-search-in-radarr" > #10 Search in Radarr< a hidden class = "anchor" aria-hidden = "true" href = "#10-search-in-radarr" > #< / a > < / h2 >
< p > Researches for movie just deleted.< / p >
< p > All I do here is the Code function with 1 input which is the whole body message of the request, this is assigned to inputs.issue in the code< / p >
< div class = "highlight" > < pre tabindex = "0" class = "chroma" > < code class = "language-typescript" data-lang = "typescript" > < span class = "line" > < span class = "cl" > < span class = "kr" > export< / span > < span class = "kr" > const< / span > < span class = "nx" > code< / span > < span class = "o" > =< / span > < span class = "kr" > async< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > )< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > issueSubject< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > subject< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > movieNameRegex< / span > < span class = "o" > =< / span > < span class = "sr" > /(.*)\s\((\d{4})\)/< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > match< / span > < span class = "o" > =< / span > < span class = "nx" > movieNameRegex< / span > < span class = "p" > .< / span > < span class = "nx" > exec< / span > < span class = "p" > (< / span > < span class = "nx" > issueSubject< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > match< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > movieName< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 1< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > year< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 2< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tmdbId< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > media< / span > < span class = "p" > .< / span > < span class = "nx" > tmdbId< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Movie name: < / span > < span class = "si" > ${< / span > < span class = "nx" > movieName< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Year: < / span > < span class = "si" > ${< / span > < span class = "nx" > year< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `TMDB ID: < / span > < span class = "si" > ${< / span > < span class = "nx" > tmdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Define your Radarr API key
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > radarrApiKey< / span > < span class = "o" > =< / span > < span class = "s1" > ' your-api-key' < / span > < span class = "p" > ;< / span > < span class = "c1" > // Replace with your Radarr API key
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > radarrBaseUrl< / span > < span class = "o" > =< / span > < span class = "s1" > ' https://radarr.example.com/api/v3' < / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Use Radarr' s API to look up the movie by TMDB ID and get the Radarr ID
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > radarrApiUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > radarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /movie?tmdbId=< / span > < span class = "si" > ${< / span > < span class = "nx" > tmdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Calling Radarr API to look up the movie...' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > radarrApiResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > radarrApiUrl< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' GET' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > radarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > radarrApiResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Radarr API lookup successful.' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > radarrApiResponseData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > radarrApiResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > radarrApiResponseData< / span > < span class = "p" > .< / span > < span class = "nx" > length< / span > < span class = "o" > > < / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > movieId< / span > < span class = "o" > =< / span > < span class = "nx" > radarrApiResponseData< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ].< / span > < span class = "nx" > id< / span > < span class = "p" > ;< / span > < span class = "c1" > // Get the Radarr ID of the first movie
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Radarr Movie ID:' < / span > < span class = "p" > ,< / span > < span class = "nx" > movieId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Trigger Radarr to search for the movie and download
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > searchUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > radarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /command`< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Calling Radarr API to search for the movie: < / span > < span class = "si" > ${< / span > < span class = "nx" > searchUrl< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > searchRequestBody< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > name< / span > < span class = "o" > :< / span > < span class = "s1" > ' MoviesSearch' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > movieIds< / span > < span class = "o" > :< / span > < span class = "p" > [< / span > < span class = "nx" > movieId< / span > < span class = "p" > ],< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > searchResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > searchUrl< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' POST' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > radarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' Content-Type' < / span > < span class = "o" > :< / span > < span class = "s1" > ' application/json' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > body< / span > : < span class = "kt" > JSON.stringify< / span > < span class = "p" > (< / span > < span class = "nx" > searchRequestBody< / span > < span class = "p" > ),< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > searchResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Radarr movie search initiated.' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "sb" > `Failed to initiate movie search: < / span > < span class = "si" > ${< / span > < span class = "nx" > searchResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' No movies found for TMDB ID:' < / span > < span class = "p" > ,< / span > < span class = "nx" > tmdbId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' Radarr API lookup failed:' < / span > < span class = "p" > ,< / span > < span class = "nx" > radarrApiResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < / code > < / pre > < / div > < h2 id = "11-delay-4-minutes" > #11 Delay 4 minutes< a hidden class = "anchor" aria-hidden = "true" href = "#11-delay-4-minutes" > #< / a > < / h2 >
< p > This gives your download client time to download and transfer file to mapped directory. I have Gig+ internet and 99% of the time everything is done in 4 minutes.< / p >
< h2 id = "12-scan-jf-libraries" > #12 Scan JF Libraries< a hidden class = "anchor" aria-hidden = "true" href = "#12-scan-jf-libraries" > #< / a > < / h2 >
< p > Using core HTTP feature, send a http POST request to < a href = "https://jellyfin.domain.com/Library/Refresh" > https://jellyfin.domain.com/Library/Refresh< / a > with Headers
X-MediaBrowser-Token and value is your Jellyfin API Key< / p >
< p > I only do this as Jellyfin doesn’ t scan my NAS whenever I add a new file.< / p >
< h2 id = "13-add-commentresolve-issue" > #13 Add Comment/Resolve Issue< a hidden class = "anchor" aria-hidden = "true" href = "#13-add-commentresolve-issue" > #< / a > < / h2 >
< p > This just automatically resolves the issue in Jellyseerr and adds a comment letting the user know action was taken.< / p >
< p > All I do here is the Code function with 1 input which is the whole body message of the request, this is assigned to inputs.issue in the code< / p >
< div class = "highlight" > < pre tabindex = "0" class = "chroma" > < code class = "language-typescript" data-lang = "typescript" > < span class = "line" > < span class = "cl" > < span class = "kr" > export< / span > < span class = "kr" > const< / span > < span class = "nx" > code< / span > < span class = "o" > =< / span > < span class = "kr" > async< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > )< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > issueId< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > issue_id< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > apiKey< / span > < span class = "o" > =< / span > < span class = "s1" > ' your-api-key' < / span > < span class = "p" > ;< / span > < span class = "c1" > // Replace with your actual API key
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > baseURL< / span > < span class = "o" > =< / span > < span class = "s1" > ' https://jellyseerr.example.com/api/v1' < / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentApiUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > baseURL< / span > < span class = "si" > }< / span > < span class = "sb" > /issue/< / span > < span class = "si" > ${< / span > < span class = "nx" > issueId< / span > < span class = "si" > }< / span > < span class = "sb" > /comment`< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > statusApiUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > baseURL< / span > < span class = "si" > }< / span > < span class = "sb" > /issue/< / span > < span class = "si" > ${< / span > < span class = "nx" > issueId< / span > < span class = "si" > }< / span > < span class = "sb" > /resolved`< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > headers< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' Content-Type' < / span > < span class = "o" > :< / span > < span class = "s1" > ' application/json' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > apiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentData< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > message< / span > < span class = "o" > :< / span > < span class = "s1" > ' Your issue has been approved and a new version of the content has been automatically downloaded and updated in Jellyfin. Your issue has been set to Resolved. If you are still experiencing problems, re-open your issue.' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentRequestOptions< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' POST' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > : < span class = "kt" > headers< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > body< / span > : < span class = "kt" > JSON.stringify< / span > < span class = "p" > (< / span > < span class = "nx" > commentData< / span > < span class = "p" > ),< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > try< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Post comment
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > commentResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > commentApiUrl< / span > < span class = "p" > ,< / span > < span class = "nx" > commentRequestOptions< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > commentResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "nx" > commentData< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Update status
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > statusRequestOptions< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' POST' < / span > < span class = "p" > ,< / span > < span class = "c1" > // or PUT depending on your API
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "nx" > headers< / span > : < span class = "kt" > headers< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Add any additional data required to update the status
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > statusResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > statusApiUrl< / span > < span class = "p" > ,< / span > < span class = "nx" > statusRequestOptions< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > statusData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > statusResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "nx" > statusData< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "kc" > true< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > catch< / span > < span class = "p" > (< / span > < span class = "nx" > error< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "nx" > error< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "kc" > false< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < / code > < / pre > < / div > < p > We are now done with the Radarr flow. Moving onto Sonarr.< / p >
< h2 id = "14-branch-episodes-and-seasons" > #14 Branch Episodes and Seasons< a hidden class = "anchor" aria-hidden = "true" href = "#14-branch-episodes-and-seasons" > #< / a > < / h2 >
< p > With the issue data, we also get an “ extra” field which is where the requests Affected Episode Number and Affected Season Number are. What this branch does is see if there is an affected Episode Number by seeing if that field in the data exists. You will have to create an issue for a TV show and say an entire season is affected. Then use that sample data, go back to this branch and add the value< / p >
< ol >
< li > Jellyseerr Issue Reported body extra 1 as pictured
< img loading = "lazy" src = "/assets/img/branch-episodes.png" alt = "Episode Branch Images" / >
< / li >
< / ol >
< h2 id = "15-add-commentresolve-issue" > #15 Add Comment/Resolve Issue< a hidden class = "anchor" aria-hidden = "true" href = "#15-add-commentresolve-issue" > #< / a > < / h2 >
< p > This path meant the user reported an issue on an entire season and basically sends a response to them telling them to do it individually. I probably could have gotten a script working for this but I spent a few hours on it and frustratingly gave up. Maybe I will update this in the future but for now idrc.< / p >
< p > Again, all I do here is the code function with 1 input which is the whole body message of the request, this is assigned to inputs.issue in the code< / p >
< div class = "highlight" > < pre tabindex = "0" class = "chroma" > < code class = "language-typescript" data-lang = "typescript" > < span class = "line" > < span class = "cl" > < span class = "kr" > export< / span > < span class = "kr" > const< / span > < span class = "nx" > code< / span > < span class = "o" > =< / span > < span class = "kr" > async< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > )< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > issueId< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > issue_id< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > apiKey< / span > < span class = "o" > =< / span > < span class = "s1" > ' your-api-key' < / span > < span class = "p" > ;< / span > < span class = "c1" > // Replace with your actual API key
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > baseURL< / span > < span class = "o" > =< / span > < span class = "s1" > ' https://jellyseerr.example.com/api/v1' < / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentApiUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > baseURL< / span > < span class = "si" > }< / span > < span class = "sb" > /issue/< / span > < span class = "si" > ${< / span > < span class = "nx" > issueId< / span > < span class = "si" > }< / span > < span class = "sb" > /comment`< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > statusApiUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > baseURL< / span > < span class = "si" > }< / span > < span class = "sb" > /issue/< / span > < span class = "si" > ${< / span > < span class = "nx" > issueId< / span > < span class = "si" > }< / span > < span class = "sb" > /resolved`< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > headers< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' Content-Type' < / span > < span class = "o" > :< / span > < span class = "s1" > ' application/json' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > apiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentData< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > message< / span > < span class = "o" > :< / span > < span class = "s1" > ' Please do not report an entire season as the issue. Specify each Episode number. Please delete this issue and resubmit. Your issue has been automatically marked as Resolved.' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentRequestOptions< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' POST' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > : < span class = "kt" > headers< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > body< / span > : < span class = "kt" > JSON.stringify< / span > < span class = "p" > (< / span > < span class = "nx" > commentData< / span > < span class = "p" > ),< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > try< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Post comment
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > commentResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > commentApiUrl< / span > < span class = "p" > ,< / span > < span class = "nx" > commentRequestOptions< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > commentResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "nx" > commentData< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Update status
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > statusRequestOptions< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' POST' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > : < span class = "kt" > headers< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > statusResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > statusApiUrl< / span > < span class = "p" > ,< / span > < span class = "nx" > statusRequestOptions< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > statusData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > statusResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "nx" > statusData< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "kc" > true< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > catch< / span > < span class = "p" > (< / span > < span class = "nx" > error< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "nx" > error< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "kc" > false< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < / code > < / pre > < / div > < h2 id = "16-mark-as-failed-sonarr" > #16 Mark as Failed Sonarr< a hidden class = "anchor" aria-hidden = "true" href = "#16-mark-as-failed-sonarr" > #< / a > < / h2 >
< p > Again, all I do here is the code function with 1 input which is the whole body message of the request, this is assigned to inputs.issue in the code< / p >
< div class = "highlight" > < pre tabindex = "0" class = "chroma" > < code class = "language-typescript" data-lang = "typescript" > < span class = "line" > < span class = "cl" > < span class = "kr" > export< / span > < span class = "kr" > const< / span > < span class = "nx" > code< / span > < span class = "o" > =< / span > < span class = "kr" > async< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > )< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > issueSubject< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > subject< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tvShowNameRegex< / span > < span class = "o" > =< / span > < span class = "sr" > /(.*)\s\((\d{4})\)/< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > match< / span > < span class = "o" > =< / span > < span class = "nx" > tvShowNameRegex< / span > < span class = "p" > .< / span > < span class = "nx" > exec< / span > < span class = "p" > (< / span > < span class = "nx" > issueSubject< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > match< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tvShowName< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 1< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > year< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 2< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tvdbId< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > media< / span > < span class = "p" > .< / span > < span class = "nx" > tvdbId< / span > < span class = "p" > ;< / span > < span class = "c1" > // Using TVDB ID for TV shows
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `TV Show name: < / span > < span class = "si" > ${< / span > < span class = "nx" > tvShowName< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Year: < / span > < span class = "si" > ${< / span > < span class = "nx" > year< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `TVDB ID: < / span > < span class = "si" > ${< / span > < span class = "nx" > tvdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Define your Sonarr API key and base URL
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "o" > =< / span > < span class = "s1" > ' your-api-key' < / span > < span class = "p" > ;< / span > < span class = "c1" > // Replace with your Sonarr API key
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "o" > =< / span > < span class = "s1" > ' https://sonarr.example.com/api/v3' < / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Use Sonarr' s API to look up the series by TVDB ID and get the Sonarr ID
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > seriesResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /series/lookup?term=tvdb:< / span > < span class = "si" > ${< / span > < span class = "nx" > tvdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' GET' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > seriesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > seriesData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > seriesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > seriesData< / span > < span class = "p" > .< / span > < span class = "nx" > length< / span > < span class = "o" > > < / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > seriesId< / span > < span class = "o" > =< / span > < span class = "nx" > seriesData< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ].< / span > < span class = "nx" > id< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Find the affected season and episode numbers
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > affectedSeason< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > extra< / span > < span class = "p" > .< / span > < span class = "nx" > find< / span > < span class = "p" > (< / span > < span class = "nx" > item< / span > < span class = "o" > => < / span > < span class = "nx" > item< / span > < span class = "p" > .< / span > < span class = "nx" > name< / span > < span class = "o" > ===< / span > < span class = "s1" > ' Affected Season' < / span > < span class = "p" > )< / span > < span class = "o" > ?< / span > < span class = "p" > .< / span > < span class = "nx" > value< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > affectedEpisode< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > extra< / span > < span class = "p" > .< / span > < span class = "nx" > find< / span > < span class = "p" > (< / span > < span class = "nx" > item< / span > < span class = "o" > => < / span > < span class = "nx" > item< / span > < span class = "p" > .< / span > < span class = "nx" > name< / span > < span class = "o" > ===< / span > < span class = "s1" > ' Affected Episode' < / span > < span class = "p" > )< / span > < span class = "o" > ?< / span > < span class = "p" > .< / span > < span class = "nx" > value< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s2" > " Season ID = " < / span > < span class = "o" > +< / span > < span class = "nx" > affectedSeason< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s2" > " Episode ID = " < / span > < span class = "o" > +< / span > < span class = "nx" > affectedEpisode< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Get the history of the series
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > historyResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /history/series?seriesId=< / span > < span class = "si" > ${< / span > < span class = "nx" > seriesId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' GET' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > historyResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > historyData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > historyResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Find the most recent entry that matches the affected season and episode
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > recentEntry< / span > < span class = "o" > =< / span > < span class = "nx" > historyData< / span > < span class = "p" > .< / span > < span class = "nx" > find< / span > < span class = "p" > (< / span > < span class = "nx" > entry< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > sourceTitleMatch< / span > < span class = "o" > =< / span > < span class = "sr" > /S(\d+)E(\d+)/< / span > < span class = "p" > .< / span > < span class = "nx" > exec< / span > < span class = "p" > (< / span > < span class = "nx" > entry< / span > < span class = "p" > .< / span > < span class = "nx" > sourceTitle< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > sourceTitleMatch< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > sourceSeason< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > sourceTitleMatch< / span > < span class = "p" > [< / span > < span class = "mi" > 1< / span > < span class = "p" > ]);< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > sourceEpisode< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > sourceTitleMatch< / span > < span class = "p" > [< / span > < span class = "mi" > 2< / span > < span class = "p" > ]);< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "nx" > sourceSeason< / span > < span class = "o" > ===< / span > < span class = "nx" > affectedSeason< / span > < span class = "o" > & & < / span > < span class = "nx" > sourceEpisode< / span > < span class = "o" > ===< / span > < span class = "nx" > affectedEpisode< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "kc" > false< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > recentEntry< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > episodeId< / span > < span class = "o" > =< / span > < span class = "nx" > recentEntry< / span > < span class = "p" > .< / span > < span class = "nx" > episodeId< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > id< / span > < span class = "o" > =< / span > < span class = "nx" > recentEntry< / span > < span class = "p" > .< / span > < span class = "nx" > id< / span > < span class = "p" > ;< / span > < span class = "c1" > // This is the ID you need for marking as failed
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s2" > " Found Episode ID = " < / span > < span class = "o" > +< / span > < span class = "nx" > episodeId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s2" > " Found Most Recent Download ID = " < / span > < span class = "o" > +< / span > < span class = "nx" > id< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Use the episode ID to mark the episode as failed
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > markFailedUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /history/failed/< / span > < span class = "si" > ${< / span > < span class = "nx" > id< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Calling Sonarr API to mark episode as failed: < / span > < span class = "si" > ${< / span > < span class = "nx" > markFailedUrl< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > markFailedResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > markFailedUrl< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' POST' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > body< / span > : < span class = "kt" > JSON.stringify< / span > < span class = "p" > ({< / span > < span class = "nx" > status< / span > < span class = "o" > :< / span > < span class = "s1" > ' failed' < / span > < span class = "p" > }),< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > markFailedResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Episode successfully marked as failed in Sonarr.' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "sb" > `Failed to mark episode as failed in Sonarr: < / span > < span class = "si" > ${< / span > < span class = "nx" > markFailedResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' No matching entry found in the series history for the affected episode.' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' Failed to fetch series history:' < / span > < span class = "p" > ,< / span > < span class = "nx" > historyResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' No series found for the provided TVDB ID:' < / span > < span class = "p" > ,< / span > < span class = "nx" > tvdbId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' Failed to fetch series data:' < / span > < span class = "p" > ,< / span > < span class = "nx" > seriesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < / code > < / pre > < / div > < p > You may have to play around a bit and see if when you run this it auto searches for the file. My Sonarr does but my Radarr doesn’ t, couldnt find any setting. Regardless I include a search command and even if Sonarr searches 2 times it appears 1 will cancel out. This is why no time delay between this code and file deletion.< / p >
< h2 id = "17-delete-file-sonarr" > #17 Delete File Sonarr< a hidden class = "anchor" aria-hidden = "true" href = "#17-delete-file-sonarr" > #< / a > < / h2 >
< p > Again, all I do here is the code function with 1 input which is the whole body message of the request, this is assigned to inputs.issue in the code< / p >
< div class = "highlight" > < pre tabindex = "0" class = "chroma" > < code class = "language-typescript" data-lang = "typescript" > < span class = "line" > < span class = "cl" > < span class = "kr" > export< / span > < span class = "kr" > const< / span > < span class = "nx" > code< / span > < span class = "o" > =< / span > < span class = "kr" > async< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > )< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > issueSubject< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > subject< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tvShowNameRegex< / span > < span class = "o" > =< / span > < span class = "sr" > /(.*)\s\((\d{4})\)/< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > match< / span > < span class = "o" > =< / span > < span class = "nx" > tvShowNameRegex< / span > < span class = "p" > .< / span > < span class = "nx" > exec< / span > < span class = "p" > (< / span > < span class = "nx" > issueSubject< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > match< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tvShowName< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 1< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > year< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 2< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tvdbId< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > media< / span > < span class = "p" > .< / span > < span class = "nx" > tvdbId< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `TV Show name: < / span > < span class = "si" > ${< / span > < span class = "nx" > tvShowName< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Year: < / span > < span class = "si" > ${< / span > < span class = "nx" > year< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `TVDB ID: < / span > < span class = "si" > ${< / span > < span class = "nx" > tvdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "o" > =< / span > < span class = "s1" > ' your-api-key' < / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "o" > =< / span > < span class = "s1" > ' https://sonarr.example.com/api/v3' < / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > seriesResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /series/lookup?term=tvdb:< / span > < span class = "si" > ${< / span > < span class = "nx" > tvdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' GET' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > seriesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > seriesData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > seriesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > seriesData< / span > < span class = "p" > .< / span > < span class = "nx" > length< / span > < span class = "o" > > < / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > seriesId< / span > < span class = "o" > =< / span > < span class = "nx" > seriesData< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ].< / span > < span class = "nx" > id< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > affectedSeason< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > extra< / span > < span class = "p" > .< / span > < span class = "nx" > find< / span > < span class = "p" > (< / span > < span class = "nx" > item< / span > < span class = "o" > => < / span > < span class = "nx" > item< / span > < span class = "p" > .< / span > < span class = "nx" > name< / span > < span class = "o" > ===< / span > < span class = "s1" > ' Affected Season' < / span > < span class = "p" > )< / span > < span class = "o" > ?< / span > < span class = "p" > .< / span > < span class = "nx" > value< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > affectedEpisode< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > extra< / span > < span class = "p" > .< / span > < span class = "nx" > find< / span > < span class = "p" > (< / span > < span class = "nx" > item< / span > < span class = "o" > => < / span > < span class = "nx" > item< / span > < span class = "p" > .< / span > < span class = "nx" > name< / span > < span class = "o" > ===< / span > < span class = "s1" > ' Affected Episode' < / span > < span class = "p" > )< / span > < span class = "o" > ?< / span > < span class = "p" > .< / span > < span class = "nx" > value< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > episodeFilesResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /episodefile?seriesId=< / span > < span class = "si" > ${< / span > < span class = "nx" > seriesId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' GET' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > episodeFilesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > episodeFilesData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > episodeFilesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > targetEpisode< / span > < span class = "o" > =< / span > < span class = "nx" > episodeFilesData< / span > < span class = "p" > .< / span > < span class = "nx" > find< / span > < span class = "p" > (< / span > < span class = "nx" > episode< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > parsedPath< / span > < span class = "o" > =< / span > < span class = "nx" > episode< / span > < span class = "p" > .< / span > < span class = "nx" > relativePath< / span > < span class = "p" > .< / span > < span class = "nx" > match< / span > < span class = "p" > (< / span > < span class = "sr" > /S(\d+)E(\d+)/< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > parsedPath< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > episodeSeason< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > parsedPath< / span > < span class = "p" > [< / span > < span class = "mi" > 1< / span > < span class = "p" > ]);< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > episodeNumber< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > parsedPath< / span > < span class = "p" > [< / span > < span class = "mi" > 2< / span > < span class = "p" > ]);< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "nx" > episodeSeason< / span > < span class = "o" > ===< / span > < span class = "nx" > affectedSeason< / span > < span class = "o" > & & < / span > < span class = "nx" > episodeNumber< / span > < span class = "o" > ===< / span > < span class = "nx" > affectedEpisode< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "kc" > false< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > targetEpisode< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > targetEpisodeId< / span > < span class = "o" > =< / span > < span class = "nx" > targetEpisode< / span > < span class = "p" > .< / span > < span class = "nx" > id< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s2" > " Found Episode ID = " < / span > < span class = "o" > +< / span > < span class = "nx" > targetEpisodeId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Delete the target episode file
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > deleteEpisodeUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /episodefile/< / span > < span class = "si" > ${< / span > < span class = "nx" > targetEpisodeId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > deleteEpisodeResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > deleteEpisodeUrl< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' DELETE' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > deleteEpisodeResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Episode file successfully deleted in Sonarr.' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "sb" > `Failed to delete episode file in Sonarr: < / span > < span class = "si" > ${< / span > < span class = "nx" > deleteEpisodeResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' No matching episode found in the episode files for the affected season and episode.' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' Failed to fetch episode files:' < / span > < span class = "p" > ,< / span > < span class = "nx" > episodeFilesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' No series found for the provided TVDB ID:' < / span > < span class = "p" > ,< / span > < span class = "nx" > tvdbId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' Failed to fetch series data:' < / span > < span class = "p" > ,< / span > < span class = "nx" > seriesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < / code > < / pre > < / div > < h2 id = "18-re-search-in-sonarr" > #18 Re-search in Sonarr< a hidden class = "anchor" aria-hidden = "true" href = "#18-re-search-in-sonarr" > #< / a > < / h2 >
< p > Again, all I do here is the code function with 1 input which is the whole body message of the request, this is assigned to inputs.issue in the code< / p >
< div class = "highlight" > < pre tabindex = "0" class = "chroma" > < code class = "language-typescript" data-lang = "typescript" > < span class = "line" > < span class = "cl" > < span class = "kr" > export< / span > < span class = "kr" > const< / span > < span class = "nx" > code< / span > < span class = "o" > =< / span > < span class = "kr" > async< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > )< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > issueSubject< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > subject< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tvShowNameRegex< / span > < span class = "o" > =< / span > < span class = "sr" > /(.*)\s\((\d{4})\)/< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > match< / span > < span class = "o" > =< / span > < span class = "nx" > tvShowNameRegex< / span > < span class = "p" > .< / span > < span class = "nx" > exec< / span > < span class = "p" > (< / span > < span class = "nx" > issueSubject< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > match< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tvShowName< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 1< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > year< / span > < span class = "o" > =< / span > < span class = "nx" > match< / span > < span class = "p" > [< / span > < span class = "mi" > 2< / span > < span class = "p" > ];< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > tvdbId< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > media< / span > < span class = "p" > .< / span > < span class = "nx" > tvdbId< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `TV Show name: < / span > < span class = "si" > ${< / span > < span class = "nx" > tvShowName< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `Year: < / span > < span class = "si" > ${< / span > < span class = "nx" > year< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "sb" > `TVDB ID: < / span > < span class = "si" > ${< / span > < span class = "nx" > tvdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "o" > =< / span > < span class = "s1" > ' your-api-key' < / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "o" > =< / span > < span class = "s1" > ' https://sonarr.example.com/api/v3' < / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > seriesResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /series/lookup?term=tvdb:< / span > < span class = "si" > ${< / span > < span class = "nx" > tvdbId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' GET' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > seriesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > seriesData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > seriesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > seriesData< / span > < span class = "p" > .< / span > < span class = "nx" > length< / span > < span class = "o" > > < / span > < span class = "mi" > 0< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > seriesId< / span > < span class = "o" > =< / span > < span class = "nx" > seriesData< / span > < span class = "p" > [< / span > < span class = "mi" > 0< / span > < span class = "p" > ].< / span > < span class = "nx" > id< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > affectedSeason< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > extra< / span > < span class = "p" > .< / span > < span class = "nx" > find< / span > < span class = "p" > (< / span > < span class = "nx" > item< / span > < span class = "o" > => < / span > < span class = "nx" > item< / span > < span class = "p" > .< / span > < span class = "nx" > name< / span > < span class = "o" > ===< / span > < span class = "s1" > ' Affected Season' < / span > < span class = "p" > )< / span > < span class = "o" > ?< / span > < span class = "p" > .< / span > < span class = "nx" > value< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > affectedEpisode< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > extra< / span > < span class = "p" > .< / span > < span class = "nx" > find< / span > < span class = "p" > (< / span > < span class = "nx" > item< / span > < span class = "o" > => < / span > < span class = "nx" > item< / span > < span class = "p" > .< / span > < span class = "nx" > name< / span > < span class = "o" > ===< / span > < span class = "s1" > ' Affected Episode' < / span > < span class = "p" > )< / span > < span class = "o" > ?< / span > < span class = "p" > .< / span > < span class = "nx" > value< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > historyResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /history/series?seriesId=< / span > < span class = "si" > ${< / span > < span class = "nx" > seriesId< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' GET' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > historyResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > historyData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > historyResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > recentEntry< / span > < span class = "o" > =< / span > < span class = "nx" > historyData< / span > < span class = "p" > .< / span > < span class = "nx" > find< / span > < span class = "p" > (< / span > < span class = "nx" > entry< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > sourceTitleMatch< / span > < span class = "o" > =< / span > < span class = "sr" > /S(\d+)E(\d+)/< / span > < span class = "p" > .< / span > < span class = "nx" > exec< / span > < span class = "p" > (< / span > < span class = "nx" > entry< / span > < span class = "p" > .< / span > < span class = "nx" > sourceTitle< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > sourceTitleMatch< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > sourceSeason< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > sourceTitleMatch< / span > < span class = "p" > [< / span > < span class = "mi" > 1< / span > < span class = "p" > ]);< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > sourceEpisode< / span > < span class = "o" > =< / span > < span class = "nb" > parseInt< / span > < span class = "p" > (< / span > < span class = "nx" > sourceTitleMatch< / span > < span class = "p" > [< / span > < span class = "mi" > 2< / span > < span class = "p" > ]);< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "nx" > sourceSeason< / span > < span class = "o" > ===< / span > < span class = "nx" > affectedSeason< / span > < span class = "o" > & & < / span > < span class = "nx" > sourceEpisode< / span > < span class = "o" > ===< / span > < span class = "nx" > affectedEpisode< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "kc" > false< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > recentEntry< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > episodeId< / span > < span class = "o" > =< / span > < span class = "nx" > recentEntry< / span > < span class = "p" > .< / span > < span class = "nx" > episodeId< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s2" > " Found Episode ID = " < / span > < span class = "o" > +< / span > < span class = "nx" > episodeId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Perform the episode search
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > searchPayload< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > name< / span > < span class = "o" > :< / span > < span class = "s1" > ' EpisodeSearch' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > episodeIds< / span > < span class = "o" > :< / span > < span class = "p" > [< / span > < span class = "nx" > episodeId< / span > < span class = "p" > ],< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > searchResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > sonarrBaseUrl< / span > < span class = "si" > }< / span > < span class = "sb" > /command`< / span > < span class = "p" > ,< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' POST' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > < span class = "o" > :< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > sonarrApiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' Content-Type' < / span > < span class = "o" > :< / span > < span class = "s1" > ' application/json' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > },< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > body< / span > : < span class = "kt" > JSON.stringify< / span > < span class = "p" > (< / span > < span class = "nx" > searchPayload< / span > < span class = "p" > ),< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > });< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > if< / span > < span class = "p" > (< / span > < span class = "nx" > searchResponse< / span > < span class = "p" > .< / span > < span class = "nx" > ok< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "s1" > ' Episode search command successfully sent to Sonarr.' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "sb" > `Failed to send episode search command to Sonarr: < / span > < span class = "si" > ${< / span > < span class = "nx" > searchResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "si" > }< / span > < span class = "sb" > `< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' No matching entry found in the series history for the affected episode.' < / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' Failed to fetch series history:' < / span > < span class = "p" > ,< / span > < span class = "nx" > historyResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' No series found for the provided TVDB ID:' < / span > < span class = "p" > ,< / span > < span class = "nx" > tvdbId< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > else< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "s1" > ' Failed to fetch series data:' < / span > < span class = "p" > ,< / span > < span class = "nx" > seriesResponse< / span > < span class = "p" > .< / span > < span class = "nx" > statusText< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < / code > < / pre > < / div > < h2 id = "19-delay-for-4-minutes" > #19 Delay for 4 Minutes< a hidden class = "anchor" aria-hidden = "true" href = "#19-delay-for-4-minutes" > #< / a > < / h2 >
< p > Waiting for media to download and transfer.< / p >
< h2 id = "20-add-commentresolve-issue" > #20 Add Comment/Resolve Issue< a hidden class = "anchor" aria-hidden = "true" href = "#20-add-commentresolve-issue" > #< / a > < / h2 >
< p > Again, all I do here is the code function with 1 input which is the whole body message of the request, this is assigned to inputs.issue in the code< / p >
< div class = "highlight" > < pre tabindex = "0" class = "chroma" > < code class = "language-typescript" data-lang = "typescript" > < span class = "line" > < span class = "cl" > < span class = "kr" > export< / span > < span class = "kr" > const< / span > < span class = "nx" > code< / span > < span class = "o" > =< / span > < span class = "kr" > async< / span > < span class = "p" > (< / span > < span class = "nx" > inputs< / span > < span class = "p" > )< / span > < span class = "o" > => < / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > issueId< / span > < span class = "o" > =< / span > < span class = "nx" > inputs< / span > < span class = "p" > .< / span > < span class = "nx" > issue< / span > < span class = "p" > .< / span > < span class = "nx" > issue_id< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > apiKey< / span > < span class = "o" > =< / span > < span class = "s1" > ' your-api-key' < / span > < span class = "p" > ;< / span > < span class = "c1" > // Replace with your actual API key
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > baseURL< / span > < span class = "o" > =< / span > < span class = "s1" > ' https://jellyseerr.example.com/api/v1' < / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentApiUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > baseURL< / span > < span class = "si" > }< / span > < span class = "sb" > /issue/< / span > < span class = "si" > ${< / span > < span class = "nx" > issueId< / span > < span class = "si" > }< / span > < span class = "sb" > /comment`< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > statusApiUrl< / span > < span class = "o" > =< / span > < span class = "sb" > `< / span > < span class = "si" > ${< / span > < span class = "nx" > baseURL< / span > < span class = "si" > }< / span > < span class = "sb" > /issue/< / span > < span class = "si" > ${< / span > < span class = "nx" > issueId< / span > < span class = "si" > }< / span > < span class = "sb" > /resolved`< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > headers< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' Content-Type' < / span > < span class = "o" > :< / span > < span class = "s1" > ' application/json' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "s1" > ' X-Api-Key' < / span > < span class = "o" > :< / span > < span class = "nx" > apiKey< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentData< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > message< / span > < span class = "o" > :< / span > < span class = "s1" > ' Your issue has been approved and a new version of the content has been automatically downloaded and updated in Jellyfin. Your issue has been set to Resolved. If you are still experiencing problems, re-open your issue.' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentRequestOptions< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' POST' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > : < span class = "kt" > headers< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > body< / span > : < span class = "kt" > JSON.stringify< / span > < span class = "p" > (< / span > < span class = "nx" > commentData< / span > < span class = "p" > ),< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > try< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Post comment
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > commentResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > commentApiUrl< / span > < span class = "p" > ,< / span > < span class = "nx" > commentRequestOptions< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > commentData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > commentResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "nx" > commentData< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > // Update status
< / span > < / span > < / span > < span class = "line" > < span class = "cl" > < span class = "c1" > < / span > < span class = "kr" > const< / span > < span class = "nx" > statusRequestOptions< / span > < span class = "o" > =< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > method< / span > < span class = "o" > :< / span > < span class = "s1" > ' POST' < / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > headers< / span > : < span class = "kt" > headers< / span > < span class = "p" > ,< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > statusResponse< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > fetch< / span > < span class = "p" > (< / span > < span class = "nx" > statusApiUrl< / span > < span class = "p" > ,< / span > < span class = "nx" > statusRequestOptions< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "kr" > const< / span > < span class = "nx" > statusData< / span > < span class = "o" > =< / span > < span class = "k" > await< / span > < span class = "nx" > statusResponse< / span > < span class = "p" > .< / span > < span class = "nx" > json< / span > < span class = "p" > ();< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > log< / span > < span class = "p" > (< / span > < span class = "nx" > statusData< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "kc" > true< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span > < span class = "k" > catch< / span > < span class = "p" > (< / span > < span class = "nx" > error< / span > < span class = "p" > )< / span > < span class = "p" > {< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "nx" > console< / span > < span class = "p" > .< / span > < span class = "nx" > error< / span > < span class = "p" > (< / span > < span class = "nx" > error< / span > < span class = "p" > );< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "k" > return< / span > < span class = "kc" > false< / span > < span class = "p" > ;< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > }< / span >
< / span > < / span > < span class = "line" > < span class = "cl" > < span class = "p" > };< / span >
< / span > < / span > < / code > < / pre > < / div > < h2 id = "21-same-as-12" > #21 Same as #12< a hidden class = "anchor" aria-hidden = "true" href = "#21-same-as-12" > #< / a > < / h2 >
< h2 id = "conclusion" > Conclusion< a hidden class = "anchor" aria-hidden = "true" href = "#conclusion" > #< / a > < / h2 >
< p > Once all this is done you can publish the flow and try it out!< / p >
< p > If you have any feedback you can DM on Reddit. I’ d love to see how you have edited this automation to your exact needs.< / p >
< p > Now the hard part, getting your users to actually report the issues in Jellyseerr and not reach out to you!< / p >
< / div >
< footer class = "post-footer" >
< ul class = "post-tags" >
< / ul >
< nav class = "paginav" >
2024-02-22 14:42:02 -05:00
< a class = "prev" href = "http://localhost:1313/post/proton-mail-authentik-social-login-setup/" >
2024-02-22 14:01:49 -05:00
< span class = "title" > « Prev< / span >
< br >
< span > Proton Mail - SimpleLogin authentik Social Login Setup< / span >
< / a >
2024-02-22 14:42:02 -05:00
< a class = "next" href = "http://localhost:1313/post/how-to-authenticate-guacamole-authentik-nginxproxymanager/" >
2024-02-22 14:01:49 -05:00
< span class = "title" > Next »< / span >
< br >
< span > How to authenticate Guacamole via authentik with Cloudflare and Nginx Proxy Manager< / span >
< / a >
< / nav >
< / footer >
< / article >
< / main >
< footer class = "footer" >
2024-02-22 14:42:02 -05:00
< span > © 2024 < a href = "http://localhost:1313/" > Mafyuh' s Blog< / a > < / span >
2024-02-22 14:01:49 -05:00
< span >
Powered by
< a href = "https://gohugo.io/" rel = "noopener noreferrer" target = "_blank" > Hugo< / a > &
< a href = "https://github.com/adityatelange/hugo-PaperMod/" rel = "noopener" target = "_blank" > PaperMod< / a >
< / span >
< / footer >
< a href = "#top" aria-label = "go to top" title = "Go to Top (Alt + G)" class = "top-link" id = "top-link" accesskey = "g" >
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 12 6" fill = "currentColor" >
< path d = "M12 6H0l6-6z" / >
< / svg >
< / a >
< script >
let menu = document.getElementById('menu')
if (menu) {
menu.scrollLeft = localStorage.getItem("menu-scroll-position");
menu.onscroll = function () {
localStorage.setItem("menu-scroll-position", menu.scrollLeft);
}
}
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener("click", function (e) {
e.preventDefault();
var id = this.getAttribute("href").substr(1);
if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({
behavior: "smooth"
});
} else {
document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView();
}
if (id === "top") {
history.replaceState(null, null, " ");
} else {
history.pushState(null, null, `#${id}`);
}
});
});
< / script >
< script >
var mybutton = document.getElementById("top-link");
window.onscroll = function () {
if (document.body.scrollTop > 800 || document.documentElement.scrollTop > 800) {
mybutton.style.visibility = "visible";
mybutton.style.opacity = "1";
} else {
mybutton.style.visibility = "hidden";
mybutton.style.opacity = "0";
}
};
< / script >
< script >
document.getElementById("theme-toggle").addEventListener("click", () => {
if (document.body.className.includes("dark")) {
document.body.classList.remove('dark');
localStorage.setItem("pref-theme", 'light');
} else {
document.body.classList.add('dark');
localStorage.setItem("pref-theme", 'dark');
}
})
< / script >
< script >
document.querySelectorAll('pre > code').forEach((codeblock) => {
const container = codeblock.parentNode.parentNode;
const copybutton = document.createElement('button');
copybutton.classList.add('copy-code');
copybutton.innerHTML = 'copy';
function copyingDone() {
copybutton.innerHTML = 'copied!';
setTimeout(() => {
copybutton.innerHTML = 'copy';
}, 2000);
}
copybutton.addEventListener('click', (cb) => {
if ('clipboard' in navigator) {
navigator.clipboard.writeText(codeblock.textContent);
copyingDone();
return;
}
const range = document.createRange();
range.selectNodeContents(codeblock);
const selection = window.getSelection();
selection.removeAllRanges();
selection.addRange(range);
try {
document.execCommand('copy');
copyingDone();
} catch (e) { };
selection.removeRange(range);
});
if (container.classList.contains("highlight")) {
container.appendChild(copybutton);
} else if (container.parentNode.firstChild == container) {
} else if (codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.nodeName == "TABLE") {
codeblock.parentNode.parentNode.parentNode.parentNode.parentNode.appendChild(copybutton);
} else {
codeblock.parentNode.appendChild(copybutton);
}
});
< / script >
< / body >
< / html >