Extract subtitles
Extract subtitles
Hi,
I've been trying to figure out how to use amc to extract subtitles as well.
They are often places in a subfolder called subs or subtitles containing a rar-file with one idx-file and another rar-file within containing a sub-file.
MOVIE
|
-- SUBS
|
--subs.rar
|
-- Movie.idx
-- Movie.rar
|
-- Movie.sub
suggestions?
I've been trying to figure out how to use amc to extract subtitles as well.
They are often places in a subfolder called subs or subtitles containing a rar-file with one idx-file and another rar-file within containing a sub-file.
MOVIE
|
-- SUBS
|
--subs.rar
|
-- Movie.idx
-- Movie.rar
|
-- Movie.sub
suggestions?
Re: Extract subtitles
Check the extract call. Where the filter argument specifically checks for video files. Just add subtitles to the condition.
Re: Extract subtitles
ok,
I use this:
def tempFiles = extract(file: input.findAll{ it.isArchive() || it.hasExtension('001') }, output: null, conflict: 'override', filter: { it.isVideo() || (music && it.isAudio() || it.hasExtension('rar')) }, forceExtractAll: true) ?: []
It will extract the first rar-file but not the second containing the sub-file.
So I end up with:
movie.avi
movie.nfo
movie.idx
I use this:
def tempFiles = extract(file: input.findAll{ it.isArchive() || it.hasExtension('001') }, output: null, conflict: 'override', filter: { it.isVideo() || (music && it.isAudio() || it.hasExtension('rar')) }, forceExtractAll: true) ?: []
It will extract the first rar-file but not the second containing the sub-file.
So I end up with:
movie.avi
movie.nfo
movie.idx
Re: Extract subtitles
You mean nested archives? So first you'll extract the big archive, and then go check the extracted files for archives and extract those as well.
So after that first call you'll have a loop and another extract call: tempFile.each { ... if is archive => extract ... }
So after that first call you'll have a loop and another extract call: tempFile.each { ... if is archive => extract ... }
Re: Extract subtitles
yes it's a nested archive.
I will give it a go trying to construct a loop then
I will give it a go trying to construct a loop then
Re: Extract subtitles
It's really easy. If you manage to do it by yourself I'll give you a Power User rank. 

Re: Extract subtitles
I kind of give up :/ can't seem to figure out how loops works in filebot.
Is there somewhere I can read up on it?
Is there somewhere I can read up on it?
Re: Extract subtitles
It's Groovy actually:
http://groovy.codehaus.org/Looping
Writing this from the back of my head:
http://groovy.codehaus.org/Looping
Writing this from the back of my head:
Code: Select all
tempFiles.clone().findAll{ it.isArchive() }.each{
tempFiles += extract(file:it)
}
Re: Extract subtitles
Hmm been trying to figure out how groovy works but can't seem to get it to work. 
first I define variable the tempFiles, extract all files that is archives and that also has extension 001 right?
then a closure loop is created, which clones the command to find all archives and the for each found archive run extract on that file?
what is missing?

first I define variable the tempFiles, extract all files that is archives and that also has extension 001 right?
Code: Select all
def tempFiles = extract(file: input.findAll{ it.isArchive() || it.hasExtension('001') }, output: null, conflict: 'override', forceExtractAll: true) ?: []
Code: Select all
tempFiles.clone().findAll{ it.isArchive() }.each{
tempFiles += extract(file:it)
}
Re: Extract subtitles
So what's not working?
extract(...) is doing the extraction, and giving you the extracted files. Then you just check the extracted files for archives again and extract(...) those too, same as you did the first time.
the clone() is just there so we can modify the list. See as we add newly extracted files to the list that we're currently going through.
extract(...) is doing the extraction, and giving you the extracted files. Then you just check the extracted files for archives again and extract(...) those too, same as you did the first time.
the clone() is just there so we can modify the list. See as we add newly extracted files to the list that we're currently going through.
Re: Extract subtitles
Well it only extracts the first archive, do I need some sort of delay so it recognize the other extracted archive?
Re: Extract subtitles
It's that simple, extract(...) and then extract(...) some more. No magic waiting or whatever you may be thinking of. Pass in archives and get extracted files back.
Add some printlns for debugging and see what's going on. It's easy, just play with it. Writing this takes longer.
EDIT: @see r1594
https://sourceforge.net/p/filebot/code/ ... amc.groovy
Add some printlns for debugging and see what's going on. It's easy, just play with it. Writing this takes longer.
EDIT: @see r1594
https://sourceforge.net/p/filebot/code/ ... amc.groovy
Re: Extract subtitles
Ok I've logged and the nested archive is extracted but not in the right folder!
It ends up in the root dir above where the movies is copied to.(!?)
The extraction of the first file (.idx file ) ends up at the right place.
Movie.sub
--MOVIES
|
----MOVIE 1
|
----MOVIE 2
It ends up in the root dir above where the movies is copied to.(!?)
The extraction of the first file (.idx file ) ends up at the right place.
Movie.sub
--MOVIES
|
----MOVIE 1
|
----MOVIE 2
Re: Extract subtitles

Made a dummy-structure to test with.
- \_new\_unpack\the.matrix.1999-coolgroup
\_new\_unpack\the.matrix.1999-coolgroup\the.matrix.1999-coolgroup.sfv
\_new\_unpack\the.matrix.1999-coolgroup\Subs
\_new\_unpack\the.matrix.1999-coolgroup\Sample
\_new\_unpack\the.matrix.1999-coolgroup\Screens
\_new\_unpack\the.matrix.1999-coolgroup\The Matrix.nfo
\_new\_unpack\the.matrix.1999-coolgroup\The Matrix.avi
\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr.rar
\_new\_unpack\the.matrix.1999-coolgroup\Sample\the matrix-sample.avi
\_new\_unpack\the.matrix.1999-coolgroup\Screens\coolgroup.jpg
\_new\_unpack\the.matrix.1999-coolgroup\Screens\screen1.png
Code: Select all
C:\Program Files (x86)\FileBot>filebot -extract -script amc.groovy "\\video\_new\_unpack" --output "\\video\_new" --action copy --conflict override-non-strict --def music=n artwork=n
Parameter: music = n
Parameter: artwork = n
Argument: \\video\_new\_unpack
Read archive [cool-mtr.rar] to [\\video\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr]
Extracting files [\\video\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr\subs.rar, \\video\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr\the matrix.idx]
Read archive [subs.rar] to [\\video\_new]
Extracting files [\\video\_new\the matrix.sub]
[\\video\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr\subs.rar, \\video\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr\the matrix.idx, \\video\_new\the matrix.sub]
Input: \\video\_new\_unpack\the.matrix.1999-coolgroup\Sample\the matrix-sample.avi
Input: \\video\_new\_unpack\the.matrix.1999-coolgroup\The Matrix.nfo
Input: \\video\_new\_unpack\the.matrix.1999-coolgroup\The Matrix.avi
the matrix-sample.avi [series: matrix, movie: The Matrix (1999)]
Exclude Series: matrix
The Matrix.nfo [series: Matrix, movie: The Matrix (1999)]
Exclude Series: Matrix
The Matrix.avi [series: Matrix, movie: The Matrix (1999)]
Exclude Series: Matrix
Group: [tvs:null, mov:The Matrix (1999), anime:null] => [the matrix-sample.avi,
The Matrix.nfo, The Matrix.avi]
Rename movies using [TheMovieDB]
Looking up movie by filehash via [TheMovieDB]
TheMovieDB: Hash lookup not supported
Failed to grep IMDbID: The Matrix.nfo
Auto-detect movie from context: [\\video\_new\_unpack\the.matrix.1999-coolgroup\The Matrix.avi]
Auto-detect movie from context: [\\video\_new\_unpack\the.matrix.1999-coolgroup\The Matrix.nfo]
[COPY] Rename [\\video\_new\_unpack\the.matrix.1999-coolgroup\The Matrix.nfo] to [\\video\_new\Movies\The Matrix (1999)\The Matrix.nfo]
[COPY] Rename [\\video\_new\_unpack\the.matrix.1999-coolgroup\The Matrix.avi] to [\\video\_new\Movies\The Matrix (1999)\The Matrix.avi]
Processed 2 files
Done ?(?????)?
Re: Extract subtitles
Seems to work:
Very odd that in your case, never mind the extract, it's not handling the subtitles at all. No Input lines. No idea, you are using the latest FileBot right? And didn't introduce any bugs yourself?
Use grab latest FileBot form HEAD and grab latest script from svn:
Code: Select all
Read archive [cool-mtr.zip] to [D:\testdata\AMC-TEST\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr]
Extracting files [D:\testdata\AMC-TEST\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr\subs.zip, D:\testdata\AMC-TEST\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr\the matrix.idx]
Read archive [subs.zip] to [D:\testdata\AMC-TEST\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr\subs]
Extracting files [D:\testdata\AMC-TEST\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr\subs\the matrix.sub]
Input: D:\testdata\AMC-TEST\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr\subs\the matrix.sub
Input: D:\testdata\AMC-TEST\_new\_unpack\the.matrix.1999-coolgroup\Subs\cool-mtr\the matrix.idx
Use grab latest FileBot form HEAD and grab latest script from svn:
Code: Select all
filebot -script svn:amc ...
Re: Extract subtitles
I've got the latest version of Filebot and the AMC-script.
and think I know what the mistake is...
I'd commented out: input += tempFiles
But I still don't understand why the nested archive is extracted to the --output directory, the idx file is extracted to the right path.
and think I know what the mistake is...

I'd commented out: input += tempFiles

But I still don't understand why the nested archive is extracted to the --output directory, the idx file is extracted to the right path.
Re: Extract subtitles
I'm resurrecting my old thread.
Using the latest amc.groovy I can't get nested archives to work.
Anyone has a suggestion?
Thanks
Using the latest amc.groovy I can't get nested archives to work.
Anyone has a suggestion?
Thanks
Re: Extract subtitles
Logs? Preferably from a run from an unmodified amc script 
Plus, you could provide a nested archive for testing so I can actually try & test this myself.


Re: Extract subtitles
Ok,
here's the log with untouched amc.groovy file
I couldn't attach the file so here's my dummy archive:
http://www5.zippyshare.com/v/AcKFkemy/file.html
Thanks
here's the log with untouched amc.groovy file
Code: Select all
Parameter: music = n
Parameter: artwork = n
Parameter: deleteAfterExtract = n
Argument: V:\test
Read archive [Subs.rar] and extract to [V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs]
Extracting files [V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup.idx, V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup.rar]
Read archive [the.matrix.1999-coolgroup.rar] and extract to [V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup\Subs]
Input: V:\test\the.matrix.1999-coolgroup\the.matrix.1999-coolgroup.mkv
Exclude: V:\test\the.matrix.1999-coolgroup\the.matrix.1999-coolgroup.sfv
Exclude: V:\test\the.matrix.1999-coolgroup\the.matrix.1999-coolgroup.nfo
Exclude: V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup.idx
Exclude: V:\test\the.matrix.1999-coolgroup\Sample\the matrix-sample.avi
Exclude: V:\test\the.matrix.1999-coolgroup\Screens\coolgroup.jpg
Exclude: V:\test\the.matrix.1999-coolgroup\Screens\screen1.png
the.matrix.1999-coolgroup.mkv [series: null, movie: The Matrix (1999)]
Group: [tvs:null, mov:the matrix 1999, anime:null] => [the.matrix.1999-coolgroup.mkv]
Rename movies using [TheMovieDB]
Failed to grep IMDbID: the.matrix.1999-coolgroup.nfo
Auto-detect movie from context: [V:\test\the.matrix.1999-coolgroup\the.matrix.1999-coolgroup.mkv]
[COPY] Rename [V:\test\the.matrix.1999-coolgroup\the.matrix.1999-coolgroup.mkv] to [V:\Movies\The Matrix (1999)\The Matrix (1999).mkv]
Processed 1 files
Done ...(...............)...
http://www5.zippyshare.com/v/AcKFkemy/file.html
Thanks
Re: Extract subtitles
Fixed with r2809. Use -script dev:amc for testing.
Re: Extract subtitles
Yes that seems to work, thanks!
Is there a default behavior that it extract to a subfolder?
This is the folder tree:
V:.
└───Subs
└───Subs
└───the.matrix.1999-coolgroup
└───Subs
Couldn't it just extract to the same folder as the archive?
Is there a default behavior that it extract to a subfolder?
This is the folder tree:
V:.
└───Subs
└───Subs
└───the.matrix.1999-coolgroup
└───Subs
Couldn't it just extract to the same folder as the archive?
Parameter: music = n
Parameter: artwork = n
Parameter: deleteAfterExtract = n
Argument: V:\test
Read archive [Subs.rar] and extract to [V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs]
Extracting files [V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup.idx, V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup.rar]
Read archive [the.matrix.1999-coolgroup.rar] and extract to [V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup\Subs]
Extracting files [V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup\Subs\the.matrix.1999-coolgroup.sub]
Input: V:\test\the.matrix.1999-coolgroup\the.matrix.1999-coolgroup.mkv
Input: V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup.idx
Input: V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup\Subs\the.matrix.1999-coolgroup.sub
Exclude: V:\test\the.matrix.1999-coolgroup\the.matrix.1999-coolgroup.sfv
Exclude: V:\test\the.matrix.1999-coolgroup\the.matrix.1999-coolgroup.nfo
Exclude: V:\test\the.matrix.1999-coolgroup\Sample\the matrix-sample.avi
Exclude: V:\test\the.matrix.1999-coolgroup\Screens\coolgroup.jpg
Exclude: V:\test\the.matrix.1999-coolgroup\Screens\screen1.png
the.matrix.1999-coolgroup.mkv [series: null, movie: The Matrix (1999)]
the.matrix.1999-coolgroup.idx [series: null, movie: The Matrix (1999)]
the.matrix.1999-coolgroup.sub [series: null, movie: The Matrix (1999)]
Group: [tvs:null, mov:the matrix 1999, anime:null] => [the.matrix.1999-coolgroup.mkv, the.matrix.1999-coolgroup.idx, the.matrix.1999-coolgroup.sub]
Rename movies using [TheMovieDB]
Failed to grep IMDbID: the.matrix.1999-coolgroup.nfo
Auto-detect movie from context: [V:\test\the.matrix.1999-coolgroup\the.matrix.1999-coolgroup.mkv]
[COPY] Rename [V:\test\the.matrix.1999-coolgroup\the.matrix.1999-coolgroup.mkv] to [V:\Movies\The Matrix (1999)\The Matrix (1999).mkv]
[COPY] Rename [V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup.idx] to [V:\Movies\The Matrix (1999)\The Matrix (1999).eng.idx]
[COPY] Rename [V:\test\the.matrix.1999-coolgroup\Subs\Subs\Subs\the.matrix.1999-coolgroup\Subs\the.matrix.1999-coolgroup.sub] to [V:\Movies\The Matrix (1999)\The Matrix (1999).sub]
Processed 3 files
Done ...(...............)...
Re: Extract subtitles
It's creating a new folder based on the original folder and archive name which can be important for movie/series/episode detection.
Also, I don't care about idx/sub bitmap subtitles. It's like a blast from the last century. Use srt or some other text based format.
Also, I don't care about idx/sub bitmap subtitles. It's like a blast from the last century. Use srt or some other text based format.

Re: Extract subtitles
All right thanks,
will this be included in the regular release or do I need to run the dev?
will this be included in the regular release or do I need to run the dev?
Re: Extract subtitles
It'll eventually trickle into the regular release. Usually 1-2 weeks later.