Plex integration with Sonarr

Sonarr version (exact version): 2.0.0.4427
OS: Windows 10 x64
Description of issue: This is more of a question. I’m planning on installing Plex on the same computer where Sonarr and Couch Potato are installed. Now what happens when I integrate Plex with Sonarr? What does it really achieve? Also, I noticed that there are three Plex options when adding under the “Connect” tab. Which one between PHT, PMS, and PMC is for me and what are their differences? Thanks.

Sonarr can tell Plex to update the series when a new episode is downloaded.

PMS to update the library, PMC is quite old and should be removed from Sonarr in v3. PHT is the now retired client (replaced by Plex Media Player), you can use it to get GUI notifications (similar to Kodi) right in the client.

Doesn’t Plex do the updating by itself? Or would it Sonarr just make it more real-time?

I see. So if it’s really just the server part that I want Sonarr to integrate with, then I just need to add PMS, correct?

If I want GUI notifications in the client, should I add the clients one by one?

Depends if Plex is configured to watch for changes and automatically update (which doesn’t work with network drives and on some systems).

Yes.

Yes.

If my media is local to the PMS, would it be better to let it automatically watch for changes or would I be better off if Sonarr does its thing? What are the pros and cons between the two?

I have PMS set up on the same machine I have Sonarr on. I use some customized conversion scripts to do any conversions from what I consider “unfavorable” file containers and codecs into something a bit more Plex friendly. (Everything gets converted to MP4 with H264 video and AAC stereo audio codecs.) This seems to be the most Direct Playable on most of Plex’s client apps.

I have Sonarr set up to send a download to SABnzb+ via SABnzb+'s API. At the end of the download, SABnzb+ calls a copy of this conversion script, putting the media into a NZBDrone folder that Sonarr watches, deleting the original file after it is done with the conversion. Sonarr sees the newly converted file(s) and assuming the download name is something it can match to, it finds the media, moves it to the proper Show/Season folder. It also is renamed into a much more Plex friendly naming scheme. (Show - SXXEXX - Episode Title.mp4)

PMS is set up to detect media changes, so after the file is put into the correct Show/Season folder and properly renamed PMS detect this change, finds the new episode, matches it based on the naming scheme, and adds the show to the proper library/show/season automatically.

As long as the original download is named fairly closely to the TVDB name this entire process is completely hands free. I just need to get Sonarr set up to find the shows, etc. If the original download’s name is something really off the wall, then I have to manually go in and rename the show in the NZBDrone folder. After that, Sonarr does the rest automatically.

You can do the entire process without the conversion scripts just as easily. (Or you can use the default conversion scripts that come with Sonarr, I suppose.)

Things get a little more difficult when using PMS with your media across a network, though. PMS can’t detect changes automatically, most of the time. In this case, you would probably want to set PMS up to scan for changes on a timed manner. If you open the Web App for PMS, go to Settings -> Server -> Library and turn on “Update my library periodically” to something that fits your needs. 15 minutes might be a bit high, especially if you have a lot of media. 2 hours might work better for some people.

HTH

Thanks for the detailed reply. I understand your setup but have a few questions:

1.) When exactly will the media be put in tue NZBDrone folder? Before, during, or after the conversion?

2.) The conversion done by the custom script is interesting. Where do I get that specific script that converts everything to mp4/aac uniformly?

If you have a Plex Pass you can get the script from a post made by a user there named @cayars. He took the default scripts that came with SickBeard/SickRage and modified them to fit his needs. And then posted them on the Plex forums. Look for a post about his set up. They are set up originally for Windows, but with some editing, you can make them work for Linux as I have. Another way to find them is to look for MikeG6.5 on that forum as well. He has links to the main post in his signature, as well as instructions to modify them for Linux. (If needed.) Basically all that needs to be done is folders and paths to fit the Linux platform.

The conversion scripts start writing the file to the NZB folder as soon as they kick off, but they are locked until the process is done. Sonarr can’t rename/move them until the conversion is completed. ATM these scripts do NOT use any GPU or hardware acceleration. They rely solely on CPU to muscle through. So codecs that can only be converted via one core are going to take a while. Other codecs can be converted in mere minutes… It seems to hang on H265 10-bit, and cayars is working on an update to resolve this.

In some cases, MKV’s already have the H264 codec inside, and in this case, it’s just repackaging the files into an MP4.

As I said, these scripts are already a part of Sonarr, but without the customizing that cayars has done to them. It’s possible to have English as a main track, German as a second, Spanish as a third, by changing a setting in the ini file. Assuming those tracks exist in the original downloads. These scripts will also strip out subs and make srt sidecar files, but Sonarr doesn’t rename these, nor move them, so a bit of a waste doing this with TV shows… :frowning:

You can also get DTS or AC3 5.1, 7.1, etc. embedded into the MP4 with these scripts. But they aren’t going to be the first track, and you may have to select them in your client app. These scripts convert those (and other audio codecs) to AAC Stereo for the first track by default. This ensures that the media is as direct playable as possible on the highest number of client apps/devices. Direct Play on my systems uses about 4% per stream, where 2 or 3 transcodes can literally cripple it… So I ALWAYS aim for Direct Playing media.

Sorry for the late reply. I’m really not a Plex Pass user. Is there any other way to get those scripts by just being a regular Plex user? My intention is just to make sure that the audio format of all TV Shows/Movies are NOT E-AC3 as my media player (Popcorn Hour C300) can’t seem to play the audio of those. Is this something achievable by any of cayar’s scripts?

I think he put them into a general forum once, but it’s been a while. You would have to search for the post. I know there are a few people that have modified them.

Found the post you’re referring to and hopefully it is this: https://forums.plex.tv/discussion/217697/ffmpeg-script . The instructions are pretty clear cut but I have a few more concerns.

1.) I understand that the subtitles will be stripped out and make SRT sidecar files out of them. What is the main purpose of doing this? Is there an advantage to using SRT sidecar files as opposed to embedded ones?

2.) Like you said, Sonarr doesn’t process/move these SRT sidecar files to completed TV show folder so it’s a waste of time letting the script do this but is there any other way of achieving this?

3.) Since you’re using the Drone folder to let Sonarr do the moving and renaming, I’m assuming you disabled the “completed download handling” feature to avoid any conflict, correct?

4.) Any other modifications you’ve personally done on the ini file to improve the script?

The author is @cayars, and he’s got the answered reply in that thread, so yeah, you can get those scripts there.

  1. SRT sidecar subtitles can be streamed alongside the video and audio streams. If they are embedded in an MKV they need to be transcoded, even if they are SRT. (This might have changed recently, though. This was the way it worked when @cayars originally modified the scripts.)

  2. It’s going to do it no matter what, unless you disable subtitles in the script completely. On my system it takes about 2 seconds to strip and write…

  3. Yes, it is disabled, since Sonarr would try to move a file that the script was working on… And neither Sonarr nor these scripts have really good error checking routines for this type of thing, from what I’ve seen…

  4. There are a lot of things you can do with it. I have 2 folders that scripts for conversions are called from. One for TV shows (and the naming of them) and another for movies. The movies use a different “drone” folder, as those come from a seeding torrent… (This would be so much easier if Sonarr did movies…) :slight_smile:

But this depends on folder structures to keep the 2 separate. Since I want to delete TV shows, but keep movies until they have seeded, normally… So the ini files point to different sources/destinations, etc. My edits were specific to make them work in a Linux environment. (@cayars are set up for Windows.) Paths were modified, as well as the specific variables for my use case. (The movie script is set to not delete originals, the TV script is set to delete, and languages of subtitles stripped, etc.)

@cayars is supposed to be releasing a new version soon, with parameter passing, so things can be called within a shell or batch to make it work smoother, etc. He talked about that around Thanksgiving or so, so I would guess pretty soon…

1.) What will happen when you disable subtitles in the script completely? Would it just stop extracting the subtitles from the media file? Or does it do other things with the subtitles that I’m not aware of?

2.) I know Cayar’s script is based off of this: https://github.com/mdhiggins/sickbeard_mp4_automator . That original script has the option of using sub-scripts that are specifically designed for the media managers (Sonarr, CouchPotato, etc.) so that would eliminate the need to use the Drone folder and letting Sonarr do everything in its end. I just don’t know how to properly set it up using that though. I’m thinking you wouldn’t know how to do that too, would you?

3.) How would you specify to source conversion folders and two “Drone” destination folders using the script? Specifying the source folders is easy as you just need to modify the batch file to include two instances of python.exe but for the destination folders it’s not like you can specify multiple “output_directory” parameters inside AutoProcess.ini, right?

I would certainly hope that Cayars post his new script on the public Plex forums. Would you mind updating me when the new version is released so that I can nicely ask Cayers about it?

  1. Don’t know, never tried…

  2. I use SABnzbd+ for TV show downloads, and have a copy of the “bnat” file in that app’s scripts folder, that it calls. My folders are set up with a full copy of the scripts, not counting ffmpeg, for movies and TV shows. Just the “bat” (or sh in my case) is in the scripts folder, paths point to the correct folder for the type of download.

  3. /Convert and /Convert-Movies are the folders I use. The contents are the same, except for the ini file differences. the shell scripts are basically the same, just the ini file differences.

Not sure if he’s going to put it into the general public or general pass. The original posts he had about it were pass, and he had to be the one to post in the public… You can also send him a PM through Plex’s forums, and he might keep you in the loop. He knows about some of us, so he tries to keep people up to date with stuff. (He did take a break for a while, though…)

Yes, if I remember to do this… Some things just seem to slide past at times, so I hope I don’t forget… :slight_smile:

Ok. I understand your setup now. I use SAB as main usenet downloader too. I also use Sonarr to handle TV Shows downloading and CouchPotato for movies.

What I meant by using the original script to get away in using the Drone folder was using the postSonarr.py script. If I understand that correctly, it integrates with Sonarr so that the downloaded media file gets converted to MP4 first before it passes it to Sonarr’s completed download handling (way better than using the old-fashioned Drone folder). I was wondering if you ever tried doing it this way?

Also, can the script be run in multiple instances for batch processing when the succeeding file download completes while there is still an ongoing conversion? Does it intelligently handle this kind of situation?

Yeah, I just PM’d him in the Plex forum and I hope he replies back. Thanks.

I never tried those scripts that came with SAB or Sonarr. I had something that worked before I ever got either of those apps running. I was taught at an early age, don’t fix nothing that ain’t broke. It’s a good way to break it! :slight_smile:

It will convert everything it finds that needs converting… One file at a time, from some random hash the system determines for which is first, second, etc. The problem you might find is multiple instances of ffmpeg running at the same time, and things come to a complete crawl on the system. With Linux you can set up some error checking, but not sure if you can do this in Windows…

@markus101

Can you think of any other way for any SRT sidecar files to be processed by Sonarr?

Not currently, thought they will be in a future release.

How does Sonarr’s drone processing work to get the “release group” information? I’m trying to automate everything with cayar’s script and been running into some problems. I tried converting this release:

Better Call Saul - S01E01 - Uno - [Bluray-1080p - DEFLATE].mkv

And then the destination of the script is Sonar’s drone folder. The output is:

Better Call Saul - S01E01 - Uno - [Bluray-1080p - DEFLATE].mp4 with all metadata removed.

When Sonarr processes it, the outcome is:

Better Call Saul - S01E01 - Uno - [Bluray-1080p - Sonarr].mp4

So obviously, Sonarr doesn’t know what the release group is. Any ideas?

It uses -RlsGroup at the end, your above format won’t work with Sonarr detecting it.