Repository: Flexget/Flexget

Issue:
[subliminal] Support downloading subtitles to different directory
Already supported by the subliminal API, patch just adds a config option for it.

```
--- subtitles_subliminal.py.orig    2016-04-20 06:07:33.873933998 -0300
+++ subtitles_subliminal.py 2016-04-20 06:12:29.070504077 -0300
@@ -42,6 +42,7 @@
           exact_match: no
           providers: addic7ed, opensubtitles
           single: no
+          directory: /disk/subtitles
     """

     schema = {
@@ -52,6 +53,7 @@
             'exact_match': {'type': 'boolean', 'default': True},
             'providers': {'type': 'array', 'items': {'type': 'string', 'enum': PROVIDERS}},
             'single': {'type': 'boolean', 'default': True},
+            'directory': {'type:': 'string'},
         },
         'required': ['languages'],
         'additionalProperties': False
@@ -80,6 +82,7 @@
                 exact_match: Use file hash only to search for subs, otherwise Subliminal will try to guess by filename.
                 providers: List of providers from where to download subtitles.
                 single: Download subtitles in single mode (no language code added to subtitle filename).
+                directory: Path to directory where to save the subtitles, default is next to the video.
         """
         if not task.accepted:
             log.debug('nothing accepted, aborting')
@@ -163,7 +166,7 @@
             # save subtitles to disk
             for video, subtitle in downloaded_subtitles.items():
                 if subtitle:
-                    subliminal.save_subtitles(video, subtitle, single=single_mode)
+                    subliminal.save_subtitles(video, subtitle, single=single_mode, directory=config.get('directory', None))


 @event('plugin.register')
```



Discussion:
please issue a PR


Resolving patch:
diff --git a/flexget/plugins/output/subtitles_subliminal.py b/flexget/plugins/output/subtitles_subliminal.py
--- a/flexget/plugins/output/subtitles_subliminal.py
+++ b/flexget/plugins/output/subtitles_subliminal.py
@@ -43,6 +43,7 @@ class PluginSubliminal(object):
           exact_match: no
           providers: addic7ed, opensubtitles
           single: no
+          directory: /disk/subtitles
     """
     
     schema = {
@@ -53,6 +54,7 @@ class PluginSubliminal(object):
             'exact_match': {'type': 'boolean', 'default': True},
             'providers': {'type': 'array', 'items': {'type': 'string', 'enum': PROVIDERS}},
             'single': {'type': 'boolean', 'default': True},
+            'directory': {'type:': 'string'},
         },
         'required': ['languages'],
         'additionalProperties': False
@@ -81,6 +83,7 @@ def on_task_output(self, task, config):
                 exact_match: Use file hash only to search for subs, otherwise Subliminal will try to guess by filename.
                 providers: List of providers from where to download subtitles.
                 single: Download subtitles in single mode (no language code added to subtitle filename).
+                directory: Path to directory where to save the subtitles, default is next to the video.
         """
         if not task.accepted:
             log.debug('nothing accepted, aborting')
@@ -164,7 +167,10 @@ def on_task_output(self, task, config):
             # save subtitles to disk
             for video, subtitle in downloaded_subtitles.items():
                 if subtitle:
-                    subliminal.save_subtitles(video, subtitle, single=single_mode)
+                    _directory = config.get('directory', None)
+                    if _directory:
+                        _directory = os.path.expanduser(_directory)
+                    subliminal.save_subtitles(video, subtitle, single=single_mode, directory=_directory)
 
 
 @event('plugin.register')


Test patch: