FileBot

From Indie IT Wiki

FileBot is the ultimate tool for organizing and renaming your movies, TV shows or anime, and music well as downloading subtitles and artwork. It's smart and just works.

Installation

Ubuntu Linux

Latest Beta Version 4.9.3

https://get.filebot.net/filebot/BETA/

Latest Stable Version 4.9.2 (requires licence)

https://www.filebot.net/forums/viewtopic.php?f=6&t=6006&p=34454#p34454

https://get.filebot.net/filebot/

License Error: UNREGISTERED FileBot requires a valid license. Please run `filebot --license *.psm` to install your FileBot license.

Old Version 4.7.8

Changelog

Grab the package from http://www.filebot.net/#download, then...

sudo aptitude install openjdk-8-jre-headless
sudo dpkg -i /path/to/filebot_4.7.8_amd64.deb

Test...

filebot -version
FileBot 4.7.2 (r4178) / Java(TM) SE Runtime Environment 1.8.0_91 (headless)
filebot -script fn:sysinfo
FileBot 4.7.2 (r4178)
JNA Native: 4.0.1
MediaInfo: MediaInfoLib - v0.7.69
7-Zip-JBinding: 9.20
Chromaprint: fpcalc version 1.1.0 (/usr/share/filebot/fpcalc)
Extended Attributes: OK
GVFS: OK
Groovy Engine: 2.4.7
JRE: Java(TM) SE Runtime Environment 1.8.0_91 (headless)
JVM: 64-bit Java HotSpot(TM) 64-Bit Server VM
CPU/MEM: 4 Core / 3 GB Max Memory / 22 MB Used Memory
OS: Linux (amd64)
Package: DEB
Data: /home/paully/.filebot
uname: Linux mythbuntu-server3 3.13.0-93-generic #140-Ubuntu SMP Mon Jul 18 21:21:05 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Done ヾ(@⌒ー⌒@)ノ

Naming Files / Format Expressions

{n.space('_')}_{s00e00} = TV_Show_Title_S01E01

http://www.filebot.net/naming.html

Usage

Find Episodes Of TV Show

filebot -list --db TheTVDB --q "Warrior (2019)"

Subtitles

Downloading

Register

http://www.opensubtitles.org/en/

Login

http://www.opensubtitles.org/en/login/

Configure

filebot -script fn:configure

Enter OpenSubtitles username: 
Enter OpenSubtitles password:
Testing OpenSubtitles... OK
Done ヾ(@⌒ー⌒@)ノ

Test

filebot -get-subtitles /path/to/movie --q "Avatar" --lang en --output srt --encoding utf8 -non-strict

Date

filebot -get-subtitles /path/to/movie --q "Avatar" --lang en --output srt --encoding utf8 -non-strict --def maxAgeDays=7

If you have an error, try...

filebot -get-missing-subtitles ~/Videos/TV/The\ Expanse/ --q "The Expanse" --lang en --output srt --encoding utf8 -non-strict

Renaming

When you download subtitles in the manor above the will download in the format: show-name.language.srt i.e. Falling Skies S05E01.eng.srt

To rename them to match the the show name, i.e. show-name.srt undertake the following:

Download the replace.groovy file to your ~/Bin/lib directory.

Then run the following command (which goes on the internet and gets a current version):

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

If you have already downloaded the subtitle file you will need to run it locally using the replace.groovy file:

filebot -script /home/path_to/Bin/lib/replace.groovy --def "e=.eng.srt

Thanks to Filebot Forums.

Archive Extracting

filebot -extract /path/to/rar/files/

Video File Renaming

Test before renaming...

filebot --action test -rename ... etc

With underscores for space...

filebot -rename --format "{n.space('_')}_{s00e00}" /path/to/videos

Simple renaming files in current folder...

filebot -rename --format "{n} {s00e00}" .

With spaces... (optimised for Kodi and Plex)

filebot -rename --format "{n} {s00e00}" /path/to/videos -non-strict

...and if you have a slightly differently named folder...

filebot -rename --format "{n.space('_')}_{s00e00}" --q "Stella 2012" --db thetvdb ~/Videos/TV/Stella/

...full example...

filebot --action test -rename --format "{n} {s00e00}" --output "/path/to/Plex/TV/House" "/path/to/Downloads/Videos/ToDo/House/Season 1/" -non-strict

...full example with recursion...

filebot --action test -rename --format "{n} {s00e00}" --output "/path/to/Plex/TV/House" "/path/to/Downloads/Videos/ToDo/House/" -non-strict -r
filebot --action test -rename --format "{n} {s00e00}" --q "True Detective" --output "/home/user/Emby/TV/True Detective" "/home/user/torrents/completed/tv/True.Detective.Season.1.Complete.720p.WEB.x264/" -non-strict -r

...then, after testing, replace test with move...

filebot --action move -rename --format "{n} {s00e00}" --output "/path/to/Plex/TV/House" "/path/to/Downloads/Videos/ToDo/House/" -non-strict -r

USUAL ROUTINE

filebot --action test --db TheTVDB --q "War of the Worlds 2019" -rename --format "{n} {s00e00}" --output "/home/user/Emby/TV/War of the Worlds (2019) [tvdbid=370139]" "/home/user/Downloads/Videos/ToDo/War.of.the.Worlds.2019.S02.720p.DSNP.WEB-DL.DDP5.1.H.264" -non-strict -r

filebot --action move --db TheTVDB --q "War of the Worlds 2019" -rename --format "{n} {s00e00}" --output "/home/user/Emby/TV/War of the Worlds (2019) [tvdbid=370139]" "/home/user/Downloads/Videos/ToDo/War.of.the.Worlds.2019.S02.720p.DSNP.WEB-DL.DDP5.1.H.264" -non-strict -r

http://www.filebot.net/cli.html

Filters

--filter "!readLines('/path/to/excludes.txt').contains(n)"

https://www.filebot.net/forums/viewtopic.php?f=3&t=2127

https://www.filebot.net/forums/viewtopic.php?f=4&t=9690&sid=ba8ab9dae6363b6f144f539fc8a78d14

Artwork

This script will download all the necessary artwork and information for XBMC to make it index the database a LOT quicker...

banner.jpg
fanart.jpg
folder.jpg
landscape.jpg
logo.png
poster.jpg
tvshow.nfo

TV Show

filebot -script fn:artwork.tvdb /path/to/show/

Movie

filebot -script fn:artwork.tmdb /path/to/movie/

FlexGet + Transmission + Filebot Automation

UPDATE - JANUARY 2021

Tweaks for Emby and multiple versions of movies, thanks to this forum post :-)

Parameter: seriesFormat = TV/{n}/{n} {s00e00}
Parameter: movieFormat = Movies/{ny} - {any{fn.match(/2160p|1080p|720p|480p/)}{vf}.replace('2160p' : '4K', '1080p' : 'FHD', '720p' : 'HD', '480p' : 'SD')}

https://github.com/filebot/scripts

Create the directories and download the scripts...

sudo mkdir -p /usr/local/bin/lib
cd /usr/local/bin/lib
sudo wget https://raw.githubusercontent.com/filebot/scripts/master/lib/htpc.groovy
cd /usr/local/bin
sudo wget https://raw.githubusercontent.com/filebot/scripts/master/amc.groovy
sudo wget https://raw.githubusercontent.com/filebot/scripts/master/replace.groovy

Test...

/usr/bin/filebot -script "/usr/local/bin/amc.groovy" --output "/path/to/Videos" --log-file "/tmp/amc.log" --action copy --conflict override -non-strict --def "seriesFormat=TV/{n}/{n} {s00e00}" "movieFormat=Movies/{n} ({y})/{n} ({y})" subtitles=en artwork=y clean=y "ut_dir=/path/to/Downloads/transmission/tv/TV.Show.S01E06.720p.HDTV" "ut_kind=multi" "ut_title=TV.Show.S01E06.720p.HDTV"

Create the following script called /usr/local/bin/transmission_filebot.sh to run filebot using the amc.groovy file...

#!/bin/bash
HOME=/zfs/zpool1/
/usr/bin/filebot -script "/usr/local/bin/amc.groovy" --output "/zfs/zpool1/Videos" --log-file "/tmp/amc.log" --action copy --conflict override -non-strict --def "seriesFormat=TV/{n}/{n} {s00e00}" "movieFormat=Movies/{n} ({y})/{n} ({y})" artwork=y clean=y "ut_dir=$TR_TORRENT_DIR/$TR_TORRENT_NAME" "ut_kind=multi" "ut_title=$TR_TORRENT_NAME"

Now stop transmission-daemon...

sudo service transmission-daemon stop

Edit the /etc/transmission-daemon/settings.json file...

sudo nano /etc/transmission-daemon/settings.json

Add or edit the lines...

"script-torrent-done-enabled": true, 
"script-torrent-done-filename": "/usr/local/bin/transmission_filebot.sh", 

Now start transmission-daemon...

sudo service transmission-daemon start

http://www.filebot.net/forums/viewtopic.php?f=4&t=215#p3380

FileBot + XBMC

  1. You need to add the xbmc=localhost to the scripting command line.
  2. You need to download https://raw.githubusercontent.com/filebot/scripts/devel/lib/htpc.groovy and add it to a /lib/ folder.

e.g.

~/bin/lib/htpc.groovy

Troubleshooting

WARNING: An illegal reflective access operation has occurred

If you are using the latest FileBot and amc groovy script then you will see the following (harmless) warnings...

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.codehaus.groovy.vmplugin.v7.Java7$1 (file:/usr/share/filebot/jar/groovy.jar) to constructor java.lang.invoke.MethodHandles$Lookup(java.lang.Class,int)
WARNING: Please consider reporting this to the maintainers of org.codehaus.groovy.vmplugin.v7.Java7$1
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

You can safely ignore them, but if you want to hide these warnings - add the following line to your ~/.bashrc and log back in before running your FileBot script again...

export GROOVY_TURN_OFF_JAVA_WARNINGS="true"

ERROR: ClassCastException: Cannot cast java.lang.String to

filebot -clear-cache

Thanks - https://www.filebot.net/forums/viewtopic.php?f=13&t=3815

Environment Variables

filebot -script "g:println System.getProperty('user.name')"

Handy Scripts

Send Email Shell Script