Sonarr_release_title variable changing and breaking script

I have a script I am trying to write. On grab, it checks the queue via the api and looks to match “title” with the sonarr_release_title variable. The problem I am having is that by the time the download shows up in the queue, the magnet link has downloaded and the title has changed. Looking at the list of variables and what is available in the queue api, this seems to be the only unique identifier. Any ideas on how to solves this?

You should use sonarr_series_id which is the internal db number, comes onGrab and onDownload

for example two different items on the queue

sonarr_api queue

[[{"series":{"title":"Last Week Tonight with John Oliver","sortTitle":"last week tonight with john oliver","seasonCount":4,"status":"continuing","overview":"Last Week Tonight with John Oliver is an American late-night talk and news satire television program. \nL.W.T draws its comedy and satire from recent news stories, political figures, media organizations, pop culture and often aspects of the show itself.","network":"HBO","airTime":"23:00","images":[{"coverType":"fanart","url":"http://thetvdb.com/banners/fanart/original/278518-5.jpg"},{"coverType":"banner","url":"http://thetvdb.com/banners/graphical/278518-g3.jpg"},{"coverType":"poster","url":"http://thetvdb.com/banners/posters/278518-6.jpg"}],"seasons":[{"seasonNumber":0,"monitored":false},{"seasonNumber":1,"monitored":false},{"seasonNumber":2,"monitored":true},{"seasonNumber":3,"monitored":true},{"seasonNumber":4,"monitored":false}],"year":2014,"path":"/downloads/tv-shows/ricardo/Last Week Tonight with John Oliver","profileId":2,"seasonFolder":true,"monitored":true,"useSceneNumbering":false,"runtime":35,"tvdbId":278518,"tvRageId":40882,"tvMazeId":263,"firstAired":"2014-04-26T14:00:00Z","lastInfoSync":"2017-05-06T19:04:52.233237Z","seriesType":"standard","cleanTitle":"lastweektonightwithjohnoliver","imdbId":"tt3530232","titleSlug":"last-week-tonight-with-john-oliver","certification":"TV-MA","genres":["Comedy","News","Talk Show"],"tags":[3],"added":"2015-06-05T04:18:53.597994Z","ratings":{"votes":63,"value":9.3},"qualityProfileId":2,"id":38},"episode":{"seriesId":38,"episodeFileId":0,"seasonNumber":4,"episodeNumber":10,"title":"Episode 99","airDate":"2017-04-23","airDateUtc":"2017-04-24T03:00:00Z","overview":"Main Segment: Ivanka Trump and Jared Kushner.\nOther segments: North Korean missile tests and the Turkish constitutional referendum.","hasFile":false,"monitored":false,"absoluteEpisodeNumber":99,"unverifiedSceneNumbering":false,"id":18842},"quality":{"quality":{"id":1,"name":"SDTV"},"revision":{"version":2,"real":0}},"size":273563861,"title":"Last.Week.Tonight.With.John.Oliver.S04E10.REPACK.HDTV.x264-UAV","sizeleft":273563861,"status":"Queued","trackedDownloadStatus":"Ok","statusMessages":[],"downloadId":"2E37609F1DFDEC24537B9B0F08CEF370404BFA6B","protocol":"torrent","id":1101152395},{"series":{"title":"The Handmaid's Tale","sortTitle":"handmaids tale","seasonCount":1,"status":"continuing","overview":"In a dystopian near-future, the totalitarian and Christian-fundamentalist government of Gilead rules the former United States amidst an ongoing civil war and subjugates women, who are not allowed to work, control money, or even read. Widespread infertility due to environmental contamination has resulted in the conscription of young fertile women—called Handmaids, according to biblical precedent—who are assigned to the homes of the elite, where they must have ritualized sex with the men in order to become pregnant and bear children for those men and their wives.","network":"Hulu","airTime":"09:00","images":[{"coverType":"fanart","url":"http://thetvdb.com/banners/fanart/original/321239-3.jpg"},{"coverType":"banner","url":"http://thetvdb.com/banners/graphical/321239-g2.jpg"},{"coverType":"poster","url":"http://thetvdb.com/banners/posters/321239-3.jpg"}],"seasons":[{"seasonNumber":1,"monitored":false}],"year":2017,"path":"/downloads/tv-shows/ricardo/The Handmaid's Tale","profileId":4,"seasonFolder":true,"monitored":true,"useSceneNumbering":false,"runtime":45,"tvdbId":321239,"tvRageId":0,"tvMazeId":16579,"firstAired":"2017-04-25T14:00:00Z","lastInfoSync":"2017-05-06T19:04:40.280401Z","seriesType":"standard","cleanTitle":"thehandmaidstale","imdbId":"tt5834204","titleSlug":"the-handmaids-tale","genres":["Drama","Science-Fiction"],"tags":[10],"added":"2017-05-02T04:24:32.993838Z","ratings":{"votes":8,"value":9.4},"qualityProfileId":4,"id":219},"episode":{"seriesId":219,"episodeFileId":0,"seasonNumber":1,"episodeNumber":3,"title":"Late","airDate":"2017-04-26","airDateUtc":"2017-04-26T14:30:00Z","overview":"Offred visits Janine’s baby with Serena Joy and remembers the early days of the revolution before Gilead. Ofglen faces a difficult challenge.","hasFile":false,"monitored":true,"absoluteEpisodeNumber":3,"unverifiedSceneNumbering":false,"id":19131},"quality":{"quality":{"id":9,"name":"HDTV-1080p"},"revision":{"version":1,"real":0}},"size":591232228,"title":"The.Handmaids.Tale.S01E03.1080p.HEVC.x265-MeGusta","sizeleft":524730368,"timeleft":"15:15:51","estimatedCompletionTime":"2017-05-07T17:43:56.745062Z","status":"Downloading","trackedDownloadStatus":"Ok","statusMessages":[],"downloadId":"E77E283D95876990ADEA5E0D04D969623FE301AF","protocol":"torrent","id":1651705804}]]

Now i want to select only the “The Handmaid’s Tale” (I use jq here), from the variables in the script you should have series id which is in this case 219

sonarr_api queue | jq -s --compact-output ‘.[]|.[]|.series|select(.id==219)’

{"title":"The Handmaid's Tale","sortTitle":"handmaids tale","seasonCount":1,"status":"continuing","overview":"In a dystopian near-future, the totalitarian and Christian-fundamentalist government of Gilead rules the former United States amidst an ongoing civil war and subjugates women, who are not allowed to work, control money, or even read. Widespread infertility due to environmental contamination has resulted in the conscription of young fertile women—called Handmaids, according to biblical precedent—who are assigned to the homes of the elite, where they must have ritualized sex with the men in order to become pregnant and bear children for those men and their wives.","network":"Hulu","airTime":"09:00","images":[{"coverType":"fanart","url":"http://thetvdb.com/banners/fanart/original/321239-3.jpg"},{"coverType":"banner","url":"http://thetvdb.com/banners/graphical/321239-g2.jpg"},{"coverType":"poster","url":"http://thetvdb.com/banners/posters/321239-3.jpg"}],"seasons":[{"seasonNumber":1,"monitored":false}],"year":2017,"path":"/downloads/tv-shows/ricardo/The Handmaid's Tale","profileId":4,"seasonFolder":true,"monitored":true,"useSceneNumbering":false,"runtime":45,"tvdbId":321239,"tvRageId":0,"tvMazeId":16579,"firstAired":"2017-04-25T14:00:00Z","lastInfoSync":"2017-05-06T19:04:40.280401Z","seriesType":"standard","cleanTitle":"thehandmaidstale","imdbId":"tt5834204","titleSlug":"the-handmaids-tale","genres":["Drama","Science-Fiction"],"tags":[10],"added":"2017-05-02T04:24:32.993838Z","ratings":{"votes":8,"value":9.4},"qualityProfileId":4,"id":219}

The scripted command with variables in this case can use the argjson switch

sonarr_api queue | jq -s --argjson s_id $sonarr_series_id --compact-output '.[]|.[]|.series|select(.id==$s_id)'

If you have two identical titles on the queue, then you should try narrowing down with the season/episode number.

Hope that helps

Just for posterity, an update to Sonarr fixed this by adding sonarr_download_id as a variable to the custom scripts. Before, there was no unique way to identify a download between Sonarr and the torrent client.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.