aboutsummaryrefslogtreecommitdiffstats
path: root/yt_dlp/postprocessor
diff options
context:
space:
mode:
Diffstat (limited to 'yt_dlp/postprocessor')
-rw-r--r--yt_dlp/postprocessor/execafterdownload.py18
-rw-r--r--yt_dlp/postprocessor/metadatafromfield.py6
2 files changed, 11 insertions, 13 deletions
diff --git a/yt_dlp/postprocessor/execafterdownload.py b/yt_dlp/postprocessor/execafterdownload.py
index 9d68583e7..948b3ffb3 100644
--- a/yt_dlp/postprocessor/execafterdownload.py
+++ b/yt_dlp/postprocessor/execafterdownload.py
@@ -1,13 +1,11 @@
from __future__ import unicode_literals
-import re
import subprocess
from .common import PostProcessor
from ..compat import compat_shlex_quote
from ..utils import (
encodeArgument,
- FORMAT_RE,
PostProcessingError,
)
@@ -23,14 +21,14 @@ class ExecAfterDownloadPP(PostProcessor):
return 'Exec'
def parse_cmd(self, cmd, info):
- # If no %(key)s is found, replace {} for backard compatibility
- if not re.search(FORMAT_RE.format(r'[^)]*'), cmd):
- if '{}' not in cmd:
- cmd += ' {}'
- return cmd.replace('{}', compat_shlex_quote(info['filepath']))
-
- tmpl, info_copy = self._downloader.prepare_outtmpl(cmd, info)
- return tmpl % info_copy
+ tmpl, tmpl_dict = self._downloader.prepare_outtmpl(cmd, info)
+ if tmpl_dict: # if there are no replacements, tmpl_dict = {}
+ return tmpl % tmpl_dict
+
+ # If no replacements are found, replace {} for backard compatibility
+ if '{}' not in cmd:
+ cmd += ' {}'
+ return cmd.replace('{}', compat_shlex_quote(info['filepath']))
def run(self, info):
cmd = self.parse_cmd(self.exec_cmd, info)
diff --git a/yt_dlp/postprocessor/metadatafromfield.py b/yt_dlp/postprocessor/metadatafromfield.py
index 1def868e8..8c795586c 100644
--- a/yt_dlp/postprocessor/metadatafromfield.py
+++ b/yt_dlp/postprocessor/metadatafromfield.py
@@ -54,9 +54,9 @@ class MetadataFromFieldPP(PostProcessor):
def run(self, info):
for dictn in self._data:
- tmpl, info_copy = self._downloader.prepare_outtmpl(dictn['tmpl'], info)
- data_to_parse = tmpl % info_copy
- self.write_debug('Searching for r"%s" in %s' % (dictn['regex'], tmpl))
+ tmpl, tmpl_dict = self._downloader.prepare_outtmpl(dictn['tmpl'], info)
+ data_to_parse = tmpl % tmpl_dict
+ self.write_debug('Searching for r"%s" in %s' % (dictn['regex'], dictn['tmpl']))
match = re.search(dictn['regex'], data_to_parse)
if match is None:
self.report_warning('Could not interpret video %s as "%s"' % (dictn['in'], dictn['out']))