Page 1 of 1

Help with -get-subtitles

Posted: 06 Feb 2015, 14:31
by magefesa
Hi !
I m trying to recover subs via Hazel using this command :

filebot -get-subtitles "$1" --lang en --output srt --encoding utf8 -non-strict

All gets ok, but i need to know if the subtitle has been found or not, i mean, when a sub is not found i need a command flag "false" or "0" return, and actually it returns a a large string "No matches found:xxxxxxxx"

Could somebody help me ??

The idea is to do something like this in Sheel script and Hazel :

k=$(filebot -get-subtitles "$1" --lang en --output srt --encoding utf8 -non-strict)

if ($k=0) then
exit 1
else
exit 0
fi

Thanks in advance !

Re: Help with -get-subtitles

Posted: 08 Feb 2015, 14:21
by skullzy
I'm assuming this is a bash file.. first we need to figure out how to do this.. first we create some random files.. some that will recieve subtitles and ones that won't, then we log our script, but we want to log only the errors.. in this case...

Code: Select all

2>$LogFile (filebot -get-subtitles "$1" --lang en --output srt --encoding utf8 -non-strict )


This shows us that that when there is an error, it outputs something like the following

Code: Select all

No matching subtitles found: [LOCATION OF MEDIA FILES]RandomMovieWithNoSubs.mkv
No matching subtitles found: [LOCATION OF MEDIA FILES]RandomMovieWithNoSubs2.mkv
So the best and perhaps easiest way to do this would be to check a log file for any information, if there is no error then the file would be empty and if it's not empty then you simple echo the results.. after the results are echoed the file gets deleted.

Now I'm more windows/batch/vbscript.. and it would be possible to code this in groovy.. but I've looked online for a way to write what you want in bash.. please note that all testing will be done by you.. I haven't got much of a clue about bash, I just assume it's similar to other languages.

Code: Select all

#!/bin/bash
LogFile="Directory/to/place/file.txt"

2>$LogFile ( filebot -get-subtitles "$1" --lang en --output srt --encoding utf8 -non-strict )

_file="$LogFile"
[ $# -eq 0 ] && { echo "Usage: $0 filename"; exit 1; }
[ ! -f "$_file" ] && { echo "Error: $0 file not found."; exit 2; }
 
if [ -s "$_file" ]
then
	while read line           
	do
		echo-e "$ line \ n"           
	done <$LogFile

	rm $LogFile
else
	rm $LogFile
fi
Please also note that you have to configure filebot for subtitles, so that you can download them, but I assume this has already been done.

So hopefully this helps, good luck.

Re: Help with -get-subtitles

Posted: 09 Feb 2015, 14:31
by rednoah
Yep, you'll probably need to write your own little bash script that calls filebot and then returns 0 or 1 depending on wether you like the output or not. You can probably use `...` and then some substring logic.

Re: Help with -get-subtitles

Posted: 13 Feb 2015, 23:35
by magefesa
First of all, thanks for your answers !!

Maybe very difficult for me, but i ll try....

I ll keep you informed !