Page 1 of 1

Subtitle naming from cli?

Posted: 03 Jul 2013, 22:11
by dabear
Hi. Is it possible to alter the name for downloaded subtitles when running filebot from the cli?

In this example I don't want the language part:
Fetching [Under the Dome S01E01 HDTV.x264-LOL.HI.srt]
Export [Under the Dome S01E01 HDTV.x264-LOL.HI.srt] as: SubRip / UTF-8
Writing [Under the Dome S01E01 HDTV.x264-LOL.HI.srt] to [Under.the.Dome.S01E01.7
20p.HDTV.X264-DIMENSION.eng.srt]
I tried using the --format parameter when doing filebot -get-subtitles, but without success:

Code: Select all

--format "{n.upperInitial().space('.')}.{y}.{source}.{vc}-{group}.srt"

Re: Subtitle naming from cli?

Posted: 04 Jul 2013, 04:11
by rednoah
No, the -get-subtitles calls always output <filename>.<language>.<ext>

But you can easily post process with this:
http://www.filebot.net/forums/viewtopic ... &t=5#p2100

e.g.

Code: Select all

filebot -script fn:replace --def "e=.eng.srt" "r=.srt" /path/to/files

Re: Subtitle naming from cli?

Posted: 04 Jul 2013, 07:45
by dabear
Ok, thanks. Two follow up questions.

Is there a list of the language mappings? E.g when I specify --lang "en", the subtitle would be named foo.eng.srt
Is there a way to know if filebot successfully downloaded a subtitle? filebot seems to return with return code 0 both whenit finds and when it not finds any subtitle.

I am calling filebot from a python script, and I need to know if it was successfull or not. So far I hacked it by hardcoding "en"->"eng" and checking if the file exists after calling filebot.

Code: Select all

def fetch_subtitle(filename):
    print("fetching subtitle for {0}".format(filename))
    base = os.path.basename(filename)
    noext = filename.rsplit(".", 1)[0]
    result = subprocess.call(["filebot", "-get-subtitles", filename, "--q", base,
                              "--lang", "en", "--output", "srt", "--encoding",
                              "utf8", "-non-strict", "--format", "{n.upperInitial().space('.')}.{y}.{source}.{vc}-{group}.srt" ])

    print("got result from filebot:{0}".format(result))
    
    return has_subtitle_file(filename, langcode="eng")

Re: Subtitle naming from cli?

Posted: 04 Jul 2013, 12:32
by rednoah
If you write your own script the getSubtitles() call will give you a list of downloaded subtitles. So in this case you can the do your own error handling.

You can check the suball script for examples and if you want filebot to return -1 you can just throw any exception in the script.


Language mappings are all standard 2-letter or 3-letter language code and you can use the language name in English as well. No matter the input, the output naming is always 3-letter language code.