Rename and move Subtitles properly?

All about user-defined episode / movie / file name format expressions
Post Reply
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

Rename and move Subtitles properly?

Post by Elamania »

Hi, would like to know how I move all the Subs into an "Sub" Folder and then rename them according to the filename of the movie.
With the end of the Subname being the language or if it´s forced or not.
So that it gets automatically recognised by VLC&KODI.

Here is how I check for subs:

Code: Select all

{isSub={if(ext=~ /sub/ || ext=~ /idx/ || ext=~ /srt/ || ext=~ /ssa/ || ext=~ /sup/|| ext=~/ass/) return true;};null}
...
{isSub() ? "Subs/" : null} 
and here for the language:

Code: Select all

{String result=""; String e=""; String g=""; String f=""; extracted=fn.substring(fn.length()-17,fn.length());  if(isSub()){  if(extracted.toLowerCase().contains("ger") || extracted.toLowerCase().contains("de")) g="-GERMAN";  if(extracted.toLowerCase().contains("eng") ) e="-ENGLISH";  if(extracted.toLowerCase().contains("forced")) f="-FORCED";result=g+e+f; }}{result}
https://imgur.com/a/yFc027g

Why are the last two not properly recognised and is there an way to simplify my language detection in the subfiles?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename and move Subtitles properly?

Post by rednoah »

A simple example might look like this:

Code: Select all

{plex.dir}/{f.subtitle ? 'Subs' : null}/{plex.name}
:idea: Please read the FAQ and How to Request Help.
Elamania
Posts: 39
Joined: 07 Sep 2015, 23:00

Re: Rename and move Subtitles properly?

Post by Elamania »

Lol, well that is short.
Anyway how should I do it with using my naming scheme?
Especially I like that I would not have to build that annoying end part of the Sub.
And I have found that from short Subnames nothing is parsed. ie: 1080p-ger will not be recognised, any idea?

Besides this one has the problem that it adds an CDx to some subs.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename and move Subtitles properly?

Post by rednoah »

What you're asking for might be possible, but it's gonna be overly complicated and difficult to understand or maintain. If something is not working as expected, best to included samples or screenshots to illustrate the problem.

1.
*.ger.sub files will be recognized as German, based on the filename.

2.
You can use {ny} and {subt} if {plex.name} works against you with including CD numbers. You might also need to match custom patterns from the original filename via String.match(...) to ensure unique output paths when movie / language / extension is the same for multiple files.
:idea: Please read the FAQ and How to Request Help.
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Re: Rename and move Subtitles properly?

Post by AbedlaPaille »

How would one go about improving a "is there subs and in what languages?" expression for it to catch attached .srt and their language to parse them on the movie folder name? As of now i can only get internal ones with textLanguages. I feel like i'm coming closer by adding

Code: Select all

{if (ext == 'srt' && fn =~ /.fr|.fra/) 'VOSTFR'}
but it only acts on the srt and his folder, doesn't effect the attached video file.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Rename and move Subtitles properly?

Post by rednoah »

If you want to yield different values depending on what sibling files there are in the same folder, then you'd have to do just that, check the file if it's a video, find the parent folder, find subtitle files within that folder, check subtitles suffixes for these files, etc.

This will get you started:

Code: Select all

{folder.files}

Alternatively, if you process videos and subtitles in the same batch, then {model} can also be used to look at the context.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Rename and move Subtitles properly?

Post by kim »

FYI:
VOSTFR
Stands for "Version Originale Sous-Titrée en FRançais" which means "original version (i.e. not dubbed) with French subtitles".
Often added to video file names.

Sometimes you can also see "VOSTFrench", probably to make it clearer for non-Frenchmen.
Just "VOST" can also be used if it's clear that they're French subtitles (and not for example English subtitles which would be "VOSTA": "Version Originale Sous-Titrée en Anglais").

In French movie theaters usually only "VO" (original version) is written to say that the movie isn't dubbed, since it's obvious that there are French subtitles. This is opposed to movies in "VF" ("version française", French version) which are dubbed.
Lost.S04E10.VOSTFR.HDTV.XViD-LOST.avi
https://www.urbandictionary.com/define.php?term=VOSTFR

so maybe look for VOSTFR and dubbed in filename
AbedlaPaille
Posts: 107
Joined: 12 Apr 2020, 04:02

Re: Rename and move Subtitles properly?

Post by AbedlaPaille »

French scene releases match that yep, but usually those releases use internal subs so they're matched with a textLanguage.

This is my current subs expression:

Code: Select all

{any{audio.language[0] != /fr/ && textLanguages =~ /fra/ ? 'VOSTFR' : ''}
    {textLanguages =~ /fra/ ? 'VOSTFR' : ''}
    {fn.match(/VOSTFR|Vostfr|vostFR|VostFR|vostfr/).upper()}}
Works well! I just wanted to go further and have the movie folder display the same 'VOSTFR' for movies i grabbed from an English scene release and added a french srt manually.

Unfortunately i'm too incompetent to make something out of rednoah's hints :(
Post Reply