TheCaptain989 / radarr-striptracks

A Docker Mod to Radarr/Sonarr to automatically strip out unwanted audio and subtitle tracks
https://hub.docker.com/r/thecaptain989/radarr-striptracks
GNU General Public License v3.0
20 stars 1 forks source link

What happens if the desired language is not found? #41

Closed Chris230291 closed 2 years ago

Chris230291 commented 2 years ago

What happens if the desired language isn't found? Suppose all of the tracks of a file are und (undetermined), will the file be left alone or will it strip all of the tracks?

Thanks, Chris

TheCaptain989 commented 2 years ago

"Undetermined" is treated like any other language. So, if you don't specify :und as a language then most of those tracks will be stripped.

The exception being that the script will always keep the last audio track if no other audio tracks were selected during processing, regardless of what was specified. See issue #8.

In this way the script will never produce a video with no audio.

Chris230291 commented 2 years ago

Edit: I have it figured out. Is there any way to run it on the existing files?

TheCaptain989 commented 2 years ago

Is there any way to run it on the existing files?

Yes, though it will require light scripting. Before calling striptracks, you have to set two environment variables at a minimum:

So, as an example only, you could enter the following at the command line to keep all English and undetermined audio and English subtitles:

export radarr_eventtype="Remux" radarr_moviefile_path="/movies/Finding Nemo (2003)/Finding Nemo (2003).mkv" radarr_movie_title=$(basename "$file" ".${file##*.}"); /usr/local/bin/striptracks.sh :eng:und :eng

Hopefully that helps.

Chris230291 commented 2 years ago

Thanks for your help

Chris230291 commented 2 years ago

I wonder if you can help me? My bash knowledge is not great. I am trying to run the script on all files

find /movies/ -type f | while read file; do radarr_eventtype="Test";radarr_moviefile_path="$file";/usr/local/bin/striptracks.sh :eng:und :eng; done

I am getting Unknown environment: I am running this inside the Docker container shell using Portainer.

TheCaptain989 commented 2 years ago

I made a mistake in my original example. Try this:

find /movies/ -type f \( -name "*.mkv" -o -name "*.avi" -o -name "*.mp4" \) | while read file; do export radarr_eventtype="BatchRemux" radarr_moviefile_path="$file" radarr_movie_title=$(basename "$file" ".${file##*.}"); /usr/local/bin/striptracks.sh :eng:und :eng; done

The striptracks script will show several errors, but it should remux everything just fine.

Chris230291 commented 2 years ago

Thanks that is working. What would be the equivalent for Sonarr? Would it need the series title?

TheCaptain989 commented 2 years ago

For Sonarr, try the script below. I didn't bother trying to set the title because there are 4 separate variables that striptracks uses to build the title for TV shows, and that's too much to try to scrape from the file name with a simple script. The only impact it will have is the embedded Title in the MKV will be something nonsensical like " x -".

find /tv/ -type f \( -name "*.mkv" -o -name "*.avi" -o -name "*.mp4" \) | while read file; do export sonarr_eventtype="BatchRemux" sonarr_episodefile_path="$file"; /usr/local/bin/striptracks.sh :eng:und :eng; done
TheCaptain989 commented 2 years ago

You've given me a good idea, though, to make striptracks more able to function standalone. That will take a bit of work, but I think it is doable. It will make it easier for the next person anyway!

Chris230291 commented 2 years ago

Thanks. I'm not sure how I feel about having incorrect embedded titles. If that's something you would address in the future I would rather wait. Is it not possible to get the show, season and title from the filename or path? I think the default naming standard is {Series Title} - S{season:00}E{episode:00} - {Episode Title} {Quality Title}.

TheCaptain989 commented 2 years ago

It's possible, it's just not simple to code all the options. I think I have a backup plan, though. Let me work on getting the title fall back to the base file name if the Sonarr/Radarr variables aren't populated.

Chris230291 commented 2 years ago

Thanks. Your script worked well on my movies dir. Freed up almost a terabyte of space. 👍

TheCaptain989 commented 2 years ago

I uploaded my first pass at a batch mode. Try commit aed5d2.

This should set the Title attribute in the MKV to the basename of the video file. I put an example in the README.md file.

I think ultimately I'd like to process the pipeline natively in the script, but after some experimentation, that will take much more rework than I have time at the moment.

Chris230291 commented 2 years ago

Thanks. I was able to run it on all of my tv shows without any issues.