Advertisement
Zignature

ISO639-2B-subber.groovy

May 27th, 2016
473
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 1.77 KB | None | 0 0
  1. /***************************************************************************************************************************
  2. [Sonarr AutoSubber v2] by Zignature & rednoah
  3.  
  4. Concept & idea by Zignature
  5.  
  6. Scripting by rednoah
  7. The creator of Filebot - The ultimate tv renamer / subtitle downloader / sfv validator
  8. https://github.com/rednoah
  9. http://www.filebot.net/
  10.  
  11. DESCRIPTION:
  12. This script uses Filebot to search for subtitles by hash in the given language(s) and
  13. saves the file with ISO 639-2/B language code(s).
  14. This handy for Plex users for instance, since Plex doesn't support ISO 639-3 codes.
  15.  
  16. If multiple languages are required add them as a comma-separated list (without spaces!) eg. nl,en,fr,de
  17.  
  18. USAGE:
  19. Call from command line:
  20. filebot -script "[PATH\TO\ISO639-2B-subber.groovy]" "[PATH\TO\(FOLDER|FILE)]" --lang [2-letter ISO 639-1 language code(s)]
  21.  
  22. EXAMPLES:
  23. filebot -script "C:\MyScripts\ISO639-2B-subber.groovy" "C:\Movies" --lang nl
  24. filebot -script "C:\MyScripts\ISO639-2B-subber.groovy" "C:\Movies\video.avi" --lang nl
  25. filebot -script "C:\MyScripts\ISO639-2B-subber.groovy" "C:\Movies" --lang nl,en,fr
  26. filebot -script "C:\MyScripts\ISO639-2B-subber.groovy" "C:\Movies\video.avi" --lang nl,en,fr
  27. ***************************************************************************************************************************/
  28.  
  29. // select input language(s)
  30. def languages = _args.lang.split(/\W/) as List
  31.  
  32. // select input videos
  33. def videoFiles = args.getFiles{ it.isVideo() }
  34.  
  35. // fetch missing subtitles
  36. def subtitleFiles = languages.findResults{
  37.     getMissingSubtitles(lang: it, file: videoFiles, output: 'srt', encoding: 'UTF-8')
  38. }.flatten()
  39.  
  40. // rename subtitles
  41. rename(map: subtitleFiles.collectEntries{
  42.     [it, getMediaInfo(it, '{fn[0..-5]}.{lang.ISO3B}.{ext}')]
  43. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement