Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow plugin apply radarr sonarr naming policy #589

Conversation

Marnalas
Copy link
Contributor

@Marnalas Marnalas commented Jan 25, 2024

Hi there,

This is my proposal for a Flow plugin that does the following for a file :

  1. Gets the id of a serie from Sonarr or a movie from Radarr using the file name;
  2. Uses the id from step 1 to interrogate the preview rename endpoint of Sonarr/Radarr API and retrieve the new name, if there is one;
  3. If a rename is needed then the file is renamed according to the preview obtained at step 2.

This serves the purpose of letting Radarr and Sonarr handle the renaming policies (which they do really well) and let Tdarr handle the rest.

For this plugin to work as intended, it needs to be executed after the original file for a movie or a serie's episode has been replaced and after Sonarr or Radarr has been notified. This way they can determine if a renaming is necessary.
image
image
image

@ivans89
Copy link

ivans89 commented Feb 18, 2024

How i can check if a file is Movie?

@Marnalas
Copy link
Contributor Author

Marnalas commented Feb 18, 2024

@ivans89

In my situation I use the naming conventions given by trash-guides :

  • for sonarr :
    {Series TitleYear} - S{season:00}E{episode:00} - {Episode CleanTitle} [{Custom Formats }{Quality Full}]{[MediaInfo VideoDynamicRangeType]}{[Mediainfo AudioCodec}{ Mediainfo AudioChannels]}{[MediaInfo VideoCodec]}{-Release Group}
  • for radarr :
    {Movie CleanTitle} {(Release Year)} {imdb-{ImdbId}} {edition-{Edition Tags}} {[Custom Formats]}{[Quality Full]}{[MediaInfo 3D]}{[MediaInfo VideoDynamicRangeType]}{[Mediainfo AudioCodec}{ Mediainfo AudioChannels]}{[Mediainfo VideoCodec]}{-Release Group}
    As you can see, all my movies contain {imdb XXXX}, so I can use the "Check file name includes" flow plugin with the following inputs :
    image

An alternative (and probably better) option, is to have two separate libraries, one for the the series, one for the movies. Then you can set a variable named "contentType" (just an example) in each of these libraries. For the movie library you put "movie" as a value and for the series library you put "serie". Then you would be able to use the "Check Flow variable" as follow :
image

Hope this helps!

@ivans89
Copy link

ivans89 commented Feb 19, 2024

@Marnalas Thank you very much!

@tlewis17
Copy link

tlewis17 commented Feb 20, 2024

@ivans89 The way I did it is I do a "Check Flow Variable" for "args.librarySettings._id". Then if it == the id of my movies library, then it is yes else no. But I have my TV and Movies in separate Tdarr libraries.

@Marnalas I downloaded the plugin and have been using it a few days. It is working great. What do you use for the wait timer after the notification? I have been using 10 seconds.

@Marnalas
Copy link
Contributor Author

Hey @tlewis17,

Thanks for the feedback. Happy to know that it's useful to someone else !

I've been using 10 seconds as well. It probably could be less, most of the time the notification is handled in a couple of seconds, but if Radarr/Sonarr is busy, 10 seconds is a safe bet.
As a side note, I thought that it was a waste to wait for these 10 seconds even when the original file has not been replaced. So I modified the "Replace Original File" plugin to have two distinct outputs (you can see it in the screenshot in my first message) : on the left output, the file has been replaced, on the right one the file hasn't been replaced and so there is no point in notifying Radarr/Sonnar and polling for a new name. If you're interested you can find the source code in this branch : https://github.com/Marnalas/Tdarr_Plugins/tree/flowPluginReplaceOriginalFile

@tlewis17
Copy link

Hey @tlewis17,

Thanks for the feedback. Happy to know that it's useful to someone else !

I've been using 10 seconds as well. It probably could be less, most of the time the notification is handled in a couple of seconds, but if Radarr/Sonarr is busy, 10 seconds is a safe bet. As a side note, I thought that it was a waste to wait for these 10 seconds even when the original file has not been replaced. So I modified the "Replace Original File" plugin to have two distinct outputs (you can see it in the screenshot in my first message) : on the left output, the file has been replaced, on the right one the file hasn't been replaced and so there is no point in notifying Radarr/Sonnar and polling for a new name. If you're interested you can find the source code in this branch : https://github.com/Marnalas/Tdarr_Plugins/tree/flowPluginReplaceOriginalFile

That's funny, I did the exact same thing. I copied the Replace Original File and made a custom version with a second output.

@ivans89
Copy link

ivans89 commented Feb 20, 2024

@ivans89 The way I did it is I do a "Check Flow Variable" for "args.librarySettings._id". Then if it == the id of my movies library, then it is yes else no. But I have my TV and Movies in separate Tdarr libraries.

@Marnalas I downloaded the plugin and have been using it a few days. It is working great. What do you use for the wait timer after the notification? I have been using 10 seconds.

What means by id? The name of the library?

Im using it rn with "checkFileName" and {imbd-. Works great.

@tlewis17
Copy link

@ivans89 Each library has an unique ID. You can find it either by looking at the URL when you go to your library settings, or if you look in a job report it will list the library in the logs somewhere. If what you are using works, that's great. There are lots of ways of handling this.

@Marnalas
Copy link
Contributor Author

@HaveAGitGat Hi, I see the checks are failing at "auto_compile_and_push" because of an error while executing a git command. I don't see more detail. Anything I can do on my side ?
(I'll ask this question on any of my PR that has this problem, feel free to answer only to one of them)

@HaveAGitGat
Copy link
Owner

Very nice, thanks. @Marnalas you seem adept with flow plugins/typescript so DM me on Discord if you'd like to to discuss other plugins or perhaps some testing setups we can implement.

@HaveAGitGat HaveAGitGat merged commit 8472813 into HaveAGitGat:master May 8, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants