Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*******************************************************************************************************
- [Sonarr AutoSubber v3] by Zignature & rednoah
- Scripting by rednoah
- The creator of Filebot - The ultimate tv renamer / subtitle downloader / sfv validator
- https://github.com/rednoah
- http://www.filebot.net/
- Concept & idea and tiny modifications by Zignature
- DESCRIPTION:
- Custom script for Sonarr for automated multilingual subtitle downloading.
- This script uses Filebot to search for missing subtitles by hash in the given language(s) and
- saves the file with ISO 639-2/B language code(s).
- This is handy for Plex users for instance, since Plex doesn't support ISO 639-3 codes.
- If multiple languages are required add them as a comma-separated list (without spaces!) eg. nl,en,fr,de
- PREREQUISITES:
- - Filebot
- - Filebot added to your system's PATH (Environment Variable) setting
- - If you run Sonarr as a Windows service, DO NOT run it under the Local System Account. Sonarr as a Windows service under the Local System Account doesn't execute custom scripts. Run it as a user. Or you can run Sonarr as an application!
- - An Opensubtitles.org account to login to Opensubtitles in Filebot
- INSTALLATION/SETUP:
- - Install Filebot. You can get it for free at https://www.filebot.net/. Donations are appreciated :)
- - Copy sonarr-subber.groovy to your preferred location on your harddrive
- - In Sonarr navigate to Sonarr -> Settings -> Connect -> [+] -> Custom Script
- - In the Pop-up enter the following:
- Name: Enter a descriptive name to your liking eg. Sonarr Subtitle Downloader
- On Grab: No
- On Download: Yes
- On Upgrade: Yes
- On Rename: No
- Filter Series Tags: Use at your own discretion
- Path: Full path to Filebot. (On Windows systems: C:\Program Files\FileBot\filebot.exe)
- Arguments: -script "FULL-PATH-TO\sonarr-subber.groovy" --lang [2-letter ISO 639-1 language code(s)]
- - Click on the Test button.
- - If the test succeeded click on the Save button.
- This script also runs after manual imports.
- ARGUMENTS EXAMPLES:
- In these examples it's assumed you copied sonarr-subber.groovy to C:\MyScripts\ on a Windows system.
- Search for Dutch subtitles:
- -script "C:\MyScripts\sonarr-subber.groovy" --lang nl
- Search for Dutch, English and French subtitles:
- -script "C:\MyScripts\sonarr-subber.groovy" --lang nl,en,fr
- *******************************************************************************************************/
- // select input language(s)
- def languages = _args.lang.split(/\W/) as List
- // select input video
- def env = System.getenv()
- def episodeFile = env['sonarr_episodefile_path'] as String
- // fetch subtitles
- def subtitleFiles = languages.findResults{
- getSubtitles(lang: it, file: episodeFile, output: 'srt', encoding: 'UTF-8')
- }.flatten()
- // rename subtitles
- rename(map: subtitleFiles.collectEntries{
- [it, getMediaInfo(it, '{fn[0..-5]}.{lang.ISO3B}.{ext}')]
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement