From 57df9f53e0159e99ff8ff55d9f761291b8aaecce Mon Sep 17 00:00:00 2001
From: Unknown <blackjack4494@web.de>
Date: Sun, 13 Sep 2020 11:03:48 +0200
Subject: [PATCH 1/2] [youtube] convert subtitles with --skip-download

---
 youtube_dlc/YoutubeDL.py | 24 ++++++++++++++++++++++++
 youtube_dlc/__init__.py  |  1 +
 2 files changed, 25 insertions(+)

diff --git a/youtube_dlc/YoutubeDL.py b/youtube_dlc/YoutubeDL.py
index f79d31debb..0724f4dbcd 100644
--- a/youtube_dlc/YoutubeDL.py
+++ b/youtube_dlc/YoutubeDL.py
@@ -105,6 +105,7 @@ from .postprocessor import (
     FFmpegFixupStretchedPP,
     FFmpegMergerPP,
     FFmpegPostProcessor,
+    FFmpegSubtitlesConvertorPP,
     get_postprocessor,
 )
 from .version import __version__
@@ -1846,6 +1847,29 @@ class YoutubeDL(object):
                                                 (sub_lang, error_to_compat_str(err)))
                             continue
 
+        if self.params.get('skip_download', False):
+            if self.params.get('convertsubtitles', False):
+                subconv = FFmpegSubtitlesConvertorPP(self, format=self.params.get('convertsubtitles'))
+                filename_real_ext = os.path.splitext(filename)[1][1:]
+                filename_wo_ext = (
+                    os.path.splitext(filename)[0]
+                    if filename_real_ext == info_dict['ext']
+                    else filename)
+                afilename = '%s.%s' % (filename_wo_ext, self.params.get('convertsubtitles'))
+                if subconv.available:
+                    info_dict.setdefault('__postprocessors', [])
+                    # info_dict['__postprocessors'].append(subconv)
+                if os.path.exists(encodeFilename(afilename)):
+                        self.to_screen(
+                            '[download] %s has already been downloaded and '
+                            'converted' % afilename)
+                else:
+                    try:
+                        self.post_process(filename, info_dict)
+                    except (PostProcessingError) as err:
+                        self.report_error('postprocessing: %s' % str(err))
+                        return
+
         if self.params.get('writeinfojson', False):
             infofn = replace_extension(filename, 'info.json', info_dict.get('ext'))
             if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(infofn)):
diff --git a/youtube_dlc/__init__.py b/youtube_dlc/__init__.py
index a663417dab..fc11642b9c 100644
--- a/youtube_dlc/__init__.py
+++ b/youtube_dlc/__init__.py
@@ -315,6 +315,7 @@ def _real_main(argv=None):
         else match_filter_func(opts.match_filter))
 
     ydl_opts = {
+        'convertsubtitles': opts.convertsubtitles,
         'usenetrc': opts.usenetrc,
         'username': opts.username,
         'password': opts.password,

From f791b4197035eaf2ef1daf11f545c38a13a0b1d5 Mon Sep 17 00:00:00 2001
From: Unknown <blackjack4494@web.de>
Date: Sun, 13 Sep 2020 11:08:02 +0200
Subject: [PATCH 2/2] flake8

---
 youtube_dlc/YoutubeDL.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/youtube_dlc/YoutubeDL.py b/youtube_dlc/YoutubeDL.py
index 0724f4dbcd..4cec2298c4 100644
--- a/youtube_dlc/YoutubeDL.py
+++ b/youtube_dlc/YoutubeDL.py
@@ -1860,9 +1860,9 @@ class YoutubeDL(object):
                     info_dict.setdefault('__postprocessors', [])
                     # info_dict['__postprocessors'].append(subconv)
                 if os.path.exists(encodeFilename(afilename)):
-                        self.to_screen(
-                            '[download] %s has already been downloaded and '
-                            'converted' % afilename)
+                    self.to_screen(
+                        '[download] %s has already been downloaded and '
+                        'converted' % afilename)
                 else:
                     try:
                         self.post_process(filename, info_dict)