]> Raphaƫl G. Git Repositories - youtubedl/blobdiff - youtube_dl/postprocessor/metadatafromtitle.py
New upstream version 2017.05.18.1
[youtubedl] / youtube_dl / postprocessor / metadatafromtitle.py
index 920573da9d8f472b8fdd8681cab0be1c6331afb7..c73f02447402e74a8eefd52a3c2f72bfd8c919f0 100644 (file)
@@ -9,10 +9,12 @@ class MetadataFromTitlePP(PostProcessor):
     def __init__(self, downloader, titleformat):
         super(MetadataFromTitlePP, self).__init__(downloader)
         self._titleformat = titleformat
-        self._titleregex = self.format_to_regex(titleformat)
+        self._titleregex = (self.format_to_regex(titleformat)
+                            if re.search(r'%\(\w+\)s', titleformat)
+                            else titleformat)
 
     def format_to_regex(self, fmt):
-        """
+        r"""
         Converts a string like
            '%(title)s - %(artist)s'
         to a regex like
@@ -26,7 +28,7 @@ class MetadataFromTitlePP(PostProcessor):
             regex += r'(?P<' + match.group(1) + '>.+)'
             lastpos = match.end()
         if lastpos < len(fmt):
-            regex += re.escape(fmt[lastpos:len(fmt)])
+            regex += re.escape(fmt[lastpos:])
         return regex
 
     def run(self, info):