Unmanic / unmanic-plugins

Official plugins for the Unmanic application
21 stars 70 forks source link

Remove audio by language Plugin #39

Open IamRewt opened 3 years ago

IamRewt commented 3 years ago

I would like a plugin that can remove any audio track that is not a specified language.

If English is selected only keep English audio tracks. If English, Spanish is selected only keep English and Spanish audio tracks etc.

The same would be nice for subtitles as well.

Josh5 commented 3 years ago

How would you like to configure this plugin? Would you want a free-form text input. Eg: 2021-08-30_20-15

Also, how would you like the plugin to handle audio streams without a language specified? Possibly just remove them also? Or would you want to skip them? I would estimate that well over half my library has files without "English" in the audio tags. Also, it is worth knowing that different containers support different tags. Not all of them have a "language" tag specified.

IamRewt commented 3 years ago

I like that text input and being able to add in a comma-separated list of languages. As my library also has several files with English tracks that are listed as UND or unknown, I would say just skip those ones. That way we still have sound in the file.

As for the containers that do not define what language it is, I haven't dealt with them in the past, so I'm not really certain how those might need handling.

Josh5 commented 3 years ago

I started writing this plugin tonight. As I was almost done I realised... Why not have a comma separated list of streams that you want removed? Would that work? That is much safer. And you can run it against your library safely as many time as you like.

For example, you add 'fr' to remove all French language streams. Then, after processing your whole library, you find you have a bunch of Japanese streams, so you edit the plugin config and save it as 'fr,jp'. Now you run your library scan again and it removes all Japanese streams and also removes French streams for any newly added files. The removal of a stream on a file around 2GB will take Unmanic around 20 seconds. So this is not really a time consuming process to slow add more and more... In my mind this approach is far safer for not removing audio streams accidentally. What do you think?

IamRewt commented 3 years ago

That does sound a bit safer to me. I do like the idea and would be happy to add the languages I'm good with it deleting. Maybe others could chime in on this if they see it. I know I have some untitled audio tracks and some labeled UND so this might be the best approach.

IamRewt commented 3 years ago

@Josh5 not sure if you had more to do with this plugin, but I ran it against my library and it did the job well.

Just a heads up in the event you would like to close this one.

Josh5 commented 3 years ago

Ah. Yes, thanks. I'll close this off once the plugin is in the official repo

EvilTactician commented 2 years ago

Just a quick note that there is a bug in the plugin. If you specify "hi" (Hindi) to be removed, it will also remove "chi" (Chinese) audio due to a partial match of that string.

You may also wish to build in a safety measure to only remove languages under the condition that a certain language is present (in most cases, English). Right now the plugin is capable of stripping the final language from a file in cases where 99% of your library in in English but you have a handful of 'foreign' movies, for example.

Maybe a "don't strip audio if it's the final remaining audio track" option would be a good one?

newb23 commented 1 year ago

Hiya! Thank you for adding this plugin to the repo, and it seems to work great! I do have a feature request specifically for it if I could, though. Could we get a negation switch? IE: only keep the languages specified? Ditto for subtitles if possible, too!

Now that I'm asking... I'll see if I have the ability to add it myself and make a PR if you don't/won't to add this/these, ha!

Grenwalls commented 1 year ago

Looking for a list of all the language codes supported, but can't find a ISO that treats japanese as "jp" so I dont really know what to write.

I second that being able to negate would be a much better option! I just need english, swedish and undefined. Would be a lot easier! Thanks! :)