Help with subtitle processing

Support for Ubuntu and other Desktop Linux distributions
Post Reply
User avatar
rednoah
The Source
Posts: 23926
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with subtitle processing

Post by rednoah »

1.
Yes, you can do that in your format. It looks like you just need to keep the -forced part from the original filename.


2.
I'm fairly sure that the clean logic doesn't care about ignored files, as in, they'll be deleted like any other clutter files.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23926
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with subtitle processing

Post by rednoah »

1.
Plausible, but no. {subt} requires {lang} and {lang} doesn't work in this case, so {subt} doesn't work either.

You can match it manually:

Code: Select all

fn.match(/-forced/)
And you'll probably want to resort to that only if {subt} is undefined:

Code: Select all

any{subt}{fn.match(/-forced/)}

2.
That depends. You can run the cleaner script on a few example files and see how it works:
viewtopic.php?f=4&t=5#p1341

There are many conditions why it might or might not delete certain files. Most likely, it won't delete any files, if there's a video file in the same folder, which makes the folder untouchable as far as the cleaner script is concerned.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23926
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with subtitle processing

Post by rednoah »

1.
You will find useful bits and pieces here and there:
viewtopic.php?f=5&t=1895

:idea: A full reference would include all of Java and Groovy and would be far too large and technical to be useful. Best to learn from the examples here in the forums, or ask questions if you need help with something.


2.
No, the --def options are exclusive to the amc script. Although the amc script does call the cleaner script internally, it does so with default options that can't be modified. Best to call the cleaner script in a separate filebot call if you need customized behaviour.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23926
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with subtitle processing

Post by rednoah »

1.
You can check if the file is a subtitle, and then yield different values accordingly:

Code: Select all

f.subtitle ? ".this.is.a.subtitle" : null

Code: Select all

ext =~ /idx/ ? ".this.is.an.idx.file" : null
:idea: NOTE: String.match() DOES NOT work the way you think. You can't use it as a boolean expression, since it'll either return a match or throw an exception, but never return null.

:idea: Best to prototype with the Format Editor GUI so you get instant feedback.


2.
Conceptually, these two expressions are completely different, although I guess they might give you the same value.


This is 1 groovy expression, that contains 1 function call, that gets passed in 5 closures as arguments:

Code: Select all

{
    allOf
        {ac}
        {channels}
        {vf}
        {source}
        {vc}
}
So you can do things like this:

Code: Select all

{
    def values = allOf{ac}{channels}{vf}{source}{vc}
    values*.upper()*.removeAll(/\W/).join('-')
}

:idea: What is the difference between def values = allOf{ac}{channels}{vf}{source}{vc} and def values = [ac, channels, vf, source, vc] you may ask. And the answer is again the previously linked unwind-on-undefined behaviour, because if we access a undefined variable, our expression will unwind, unless we catch that exception, and allOf(Closure...) and any(Closure...) do just that for each closure that is passed in.


This is 5 groovy expressions, each of which does nothing but reference a variable:

Code: Select all

{ac}{channels}{vf}{source}{vc}

:idea: NOTE: Semantically, the outermost {...} are completely different from any other {...} within the outermost {...} since the outermost {...} merely delimit Groovy code, which itself uses {...} for code blocks, closures, etc.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23926
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with subtitle processing

Post by rednoah »

I wouldn't worry about messy code as long as it works.

You can refactor next time you need to make changes.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 23926
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Help with subtitle processing

Post by rednoah »

Check the file name:

Code: Select all

fn =~ /ger|german/
Check the full file path:

Code: Select all

f =~ /ger|german/
:idea: Please read the FAQ and How to Request Help.
Post Reply