Rename folder if embedded or external subtitle found
Rename folder if embedded or external subtitle found
I'm sorry for a real newbie question. I've searched the forum and tried in the GUI for two days now without success
I'd like to add 'SWESUB' to the movie's folder name if there is an embedded Swedish subtitle in the movie file or/and and external .srt file in the same folder as the movie file.
I've understood that i should use 'textLanguages' in some way but then I'm lost. Can anyone point me in the right direction on how to proceed?
TIA!
I'd like to add 'SWESUB' to the movie's folder name if there is an embedded Swedish subtitle in the movie file or/and and external .srt file in the same folder as the movie file.
I've understood that i should use 'textLanguages' in some way but then I'm lost. Can anyone point me in the right direction on how to proceed?
TIA!
Re: Rename folder if embedded or external subtitle found
This one should be straight-forward:fvb wrote:add 'SWESUB' to the movie's folder name if there is an embedded Swedish subtitle
Code: Select all
textLanguages =~ /swe/ ? 'SWESUB' : null
This one is tricky:fvb wrote:external .srt file in the same folder as the movie file
Code: Select all
model.any{ id == it.id && it.lang =~ /swe/ } ? 'SWESUB' : null
Please read the FAQ and How to Request Help.
Re: Rename folder if embedded or external subtitle found
Thanks!
Great app and great support! I just bought a license =)
Cheers!
Great app and great support! I just bought a license =)
Cheers!
Re: Rename folder if embedded or external subtitle found
I'd like to take this one step further and add "ENGSUB" if there's an embedded or external English subtitle available. If there are both Swedish and English subtitles available, preferably only SWESUB should be written.
I have this working format tag now for SWESUB looking for embedded or external subtitles:
I have no clue on how to proceed and I'm quite bad at scripting. Any hints or maybe someone has a somewhat working solution?
Tnx!
I have this working format tag now for SWESUB looking for embedded or external subtitles:
Code: Select all
{ any {model.any{ id == it.id && it.lang =~ /swe/ } ? '.SWESUB' : null}{textLanguages =~ /swe/ ? '.SWESUB' : null}}
Tnx!
Re: Rename folder if embedded or external subtitle found
OK, it did some testing myself but without luck. This code adds ".ENGSUB" even if there aren't an English sub (but writes out ".SWESUB" if there's both an English and a Swedish sub so that part works).
Any hints on what to change?
Code: Select all
{ any {model.any{ id == it.id && it.lang =~ /swe/ } ? '.SWESUB' : { id == it.id && it.lang =~ /eng/ } ? '.ENGSUB' : null}{textLanguages =~ /swe/ ? '.SWESUB' : textLanguages =~ /eng/ ? '.ENGSUB' : null}}
Re: Rename folder if embedded or external subtitle found
Which of your conditions that trigger '.ENGSUB' is hit? You have two. I'd start by figuring out which condition is unexpectedly true.
May I ask? Why are you using the model binding? What is your thinking?
May I ask? Why are you using the model binding? What is your thinking?
Please read the FAQ and How to Request Help.
Re: Rename folder if embedded or external subtitle found
Thanks @rednoah for logical reasoning. Test results for the different strings:
File with no embedded sub: ENGSUB
File with embedded eng sub: ENGSUB
File with embedded swe sub: ENGSUB
File with embedded swe + eng sub: ENGSUB
File with external eng sub: ENGSUB
File with external swe sub: SWESUB
File with external swe + eng sub: SWESUB
File with no embedded sub: - (nothing)
File with embedded eng sub: ENGSUB
File with embedded swe sub: SWESUB
File with embedded swe + eng sub: SWESUB
File with external eng sub: - (nothing)
File with external swe sub: - (nothing)
File with external swe + eng sub: - (nothing)
The first part of the code string with "model.any" is your work (the SWESUB part) =)
Code: Select all
{model.any{ id == it.id && it.lang =~ /swe/ } ? '.SWESUB' : { id == it.id && it.lang =~ /eng/ } ? '.ENGSUB' : null}
File with embedded eng sub: ENGSUB
File with embedded swe sub: ENGSUB
File with embedded swe + eng sub: ENGSUB
File with external eng sub: ENGSUB
File with external swe sub: SWESUB
File with external swe + eng sub: SWESUB
Code: Select all
{textLanguages =~ /swe/ ? '.SWESUB' : textLanguages =~ /eng/ ? '.ENGSUB' : null}
File with embedded eng sub: ENGSUB
File with embedded swe sub: SWESUB
File with embedded swe + eng sub: SWESUB
File with external eng sub: - (nothing)
File with external swe sub: - (nothing)
File with external swe + eng sub: - (nothing)
The first part of the code string with "model.any" is your work (the SWESUB part) =)
Re: Rename folder if embedded or external subtitle found
0.
When you post:
You mean this right?
Because otherwise it's just an issue of not copy & pasting correctly?
1.
Does your test case not show that each of these expressions work as expected?
Presumably, since the condition yields true, there are external English subtitles.
2.
I see. You'll need to combine the different expressions. Depending on what exactly you want.
This one is for checking sibling files, i.e. external subtitles:
This one is for checking embedded subtitles:
Note: {textLanguages} when applied to a subtitle file will yield the {textLanguages} value of the closest video file, so we don't have to use model.any() here.
Checking for either embedded subtitles OR sibling subtitle files that are Swedish:
Doing the above for Swedish, and if that's not the case then try English, and if that's not the case yield nothing:
When you post:
Code: Select all
{model.any{ id == it.id && it.lang =~ /swe/ } ? '.SWESUB' : { id == it.id && it.lang =~ /eng/ } ? '.ENGSUB' : null}
Code: Select all
{model.any{ id == it.id && it.lang =~ /swe/ } ? '.SWESUB' : model.any{ id == it.id && it.lang =~ /eng/ } ? '.ENGSUB' : null}
1.
Does your test case not show that each of these expressions work as expected?
Code: Select all
File with no embedded sub: ENGSUB
2.
I see. You'll need to combine the different expressions. Depending on what exactly you want.
This one is for checking sibling files, i.e. external subtitles:
Code: Select all
model.any{ id == it.id && it.lang =~ /swe/ }
Code: Select all
textLanguages =~ /swe/
Checking for either embedded subtitles OR sibling subtitle files that are Swedish:
Code: Select all
textLanguages =~ /swe/ || model.any{ id == it.id && it.lang =~ /swe/ } ? '. SWESUB' : null
Doing the above for Swedish, and if that's not the case then try English, and if that's not the case yield nothing:
Code: Select all
textLanguages =~ /swe/ || model.any{ id == it.id && it.lang =~ /swe/ } ? '. SWESUB' : textLanguages =~ /eng/ || model.any{ id == it.id && it.lang =~ /eng/ } ? '. ENGSUB' : null
Please read the FAQ and How to Request Help.
Re: Rename folder if embedded or external subtitle found
@rednoah, everything seems so easy when you explain =)
I'm a bit ashamed though.. I still must do something wrong, because I can't get this code to pick up any of the external subtitles:
For embedded subtitles it works like a charm =)
EDIT: The code picks up external subtitles only when there is an internal one also
I'm a bit ashamed though.. I still must do something wrong, because I can't get this code to pick up any of the external subtitles:
Code: Select all
{ textLanguages =~ /swe/ || model.any{ id == it.id && it.lang =~ /swe/ } ? '.SWESUB' : textLanguages =~ /eng/ || model.any{ id == it.id && it.lang =~ /eng/ } ? '.ENGSUB' : null }
EDIT: The code picks up external subtitles only when there is an internal one also
Re: Rename folder if embedded or external subtitle found
Does this part work for picking up external subtitles?
Note that the external subtitle must be part of the file set that has been loaded into FileBot. If you just drop in the video file and not the subtitle file then {model} won't include the corresponding subtitle match.
Code: Select all
model.any{ id == it.id && it.lang =~ /swe/ }
Please read the FAQ and How to Request Help.
Re: Rename folder if embedded or external subtitle found
Hi and thanks!rednoah wrote: ↑09 May 2018, 11:15 Does this part work for picking up external subtitles?Note that the external subtitle must be part of the file set that has been loaded into FileBot. If you just drop in the video file and not the subtitle file then {model} won't include the corresponding subtitle match.Code: Select all
model.any{ id == it.id && it.lang =~ /swe/ }
Yes, that code above identifies an external Swedish subtitle. This code finds the Swedish OR the English external subtitles:
Code: Select all
{ model.any{ id == it.id && it.lang =~ /swe/ } ? '.SWESUB' : model.any{ id == it.id && it.lang =~ /eng/ } ? '.ENGSUB' : null }
Casablanca.1942.mkv
Casablanca.1942.en.srt
Casablanca.1942.sv.srt
I've also tested naming with:
Casablanca.1942.swe.srt --but with the same result.
Re: Rename folder if embedded or external subtitle found
I'm actually not quite sure what you want.
Here's what I get:
I'm testing with a sample media file without embedded subtitles.
EDIT:
{textLanguages} will unwind the expression if there are no embedded subtitles at all, so maybe this will more more like the way you want:
{self.textLanguages} will just yield null if {textLanguages} is undefined, instead of unwinding the entire expression.
Here's what I get:
I'm testing with a sample media file without embedded subtitles.
EDIT:
{textLanguages} will unwind the expression if there are no embedded subtitles at all, so maybe this will more more like the way you want:
Code: Select all
{ self.textLanguages =~ /swe/ || model.any{ id == it.id && it.lang =~ /swe/ } ? '.SWESUB' : self.textLanguages =~ /eng/ || model.any{ id == it.id && it.lang =~ /eng/ } ? '.ENGSUB' : null }
Please read the FAQ and How to Request Help.
Re: Rename folder if embedded or external subtitle found
That was sweeet! =)
When dropping a folder with movies both having, and not having Swedish subtitles, all the movies get "SWESUB" suffix. Is this a normal behavior?
When dropping a folder with movies both having, and not having Swedish subtitles, all the movies get "SWESUB" suffix. Is this a normal behavior?
Re: Rename folder if embedded or external subtitle found
I don't know. Should it be? This a custom format, the behaviour is whatever the code says it is.
Please read the FAQ and How to Request Help.