Subtitle and renaming

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
Test
Posts: 6
Joined: 20 Mar 2013, 20:08

Subtitle and renaming

Post by Test »

Hi

I am in the process of writing my own groovy script for renaming movies and tv shows. To get some inspiration i have been trying the different scripts and seem to have found a bug or unfortunate implementation of getting subtitles.

Lets look at the following script:

def files = dir.listFiles{ it.isVideo() }
files += getMissingSubtitles(file:files[0])
rename(file:files, db:'TVRage', format:tvFormat, strict:false)

This script will get the subtitle but when calling the rename fuction it will remove the .eng. from the subtitle. Is there any way to fix this? The reason i dont just rename the video file first and then get the subtitle is that then i cant move there new location.

Also I was wondering if i should rename the video file first, then download the subtitle based on the correct name. I mean when you do a search on name it is probably easier to find the subtitle if it search on the correct name?
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Subtitle and renaming

Post by rednoah »

It's all in your format. Just use {'.'+lang} in the format. It'll fail for movies but give u the 3-letter language code for subtitles files.

Also the original release name will help finding the best matching subtitle. If hash-lookup works name doesn't matter, but in general subs are uploaded and match the release name, so filebot will auto-select the best match looking at file/subtitle names.
:idea: Please read the FAQ and How to Request Help.
Test
Posts: 6
Joined: 20 Mar 2013, 20:08

Re: Subtitle and renaming

Post by Test »

Thanks for the anwser :) this is great.
Test
Posts: 6
Joined: 20 Mar 2013, 20:08

Re: Subtitle and renaming

Post by Test »

Hi again

Could you also help me with this. I would like to use getMedieInfo to check if a mkv file contains english subtitles. Is this possible?

Best regards
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Subtitle and renaming

Post by rednoah »

Code: Select all

getMediaInfo(file:f, format:'''{media.TextLanguageList}''') =~ /English/
:idea: Please read the FAQ and How to Request Help.
Test
Posts: 6
Joined: 20 Mar 2013, 20:08

Re: Subtitle and renaming

Post by Test »

Great, thanks :)

Is it possible to get a list of functions on the media type?
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Subtitle and renaming

Post by rednoah »

If you play with the GUI you can see everything. Basically media.* gives access to all the MediaInfo "General" fields.
:idea: Please read the FAQ and How to Request Help.
Test
Posts: 6
Joined: 20 Mar 2013, 20:08

Re: Subtitle and renaming

Post by Test »

Okay great :)

I used your hack and added both nfo and html to sub list in media.types. There is still no other way then doing this if i want filebot to rename them right?
User avatar
rednoah
The Source
Posts: 22899
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Subtitle and renaming

Post by rednoah »

As long as video, nfo, html, etc are processed in the same batch and have exactly the same filename, they will be renamed just the same.

e.g.

Code: Select all

Auto-detect movie from context: [D:\testdata\AMC-TEST\Unforgiven.1992.1080p.BluRay.x264-WPi.avi]
[TEST] Rename [D:\testdata\AMC-TEST\Unforgiven.1992.1080p.BluRay.x264-WPi.avi] to [Unforgiven (1992).avi]
[TEST] Rename [D:\testdata\AMC-TEST\Unforgiven.1992.1080p.BluRay.x264-WPi.any] to [Unforgiven (1992).any]
Processed 2 files
:idea: Please read the FAQ and How to Request Help.
Post Reply